1v1排位数据交互完善
This commit is contained in:
31
src/apis.js
31
src/apis.js
@@ -120,10 +120,37 @@ export const readyGameAPI = (battleId) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getGameAPI = (battleId) => {
|
||||
return request("POST", "/user/battle/detail", {
|
||||
export const getGameAPI = async (battleId) => {
|
||||
const result = await request("POST", "/user/battle/detail", {
|
||||
id: battleId,
|
||||
});
|
||||
const { battleStats = {}, playerStats = {} } = result;
|
||||
const data = {
|
||||
winner: battleStats.winner,
|
||||
redTotal: battleStats.redTotal,
|
||||
blueTotal: battleStats.blueTotal,
|
||||
roundsData: {},
|
||||
redPlayers: {},
|
||||
bluePlayers: {},
|
||||
};
|
||||
playerStats.forEach((item) => {
|
||||
const { playerBattleStats = {}, roundRecords = [] } = item;
|
||||
if (playerBattleStats.team === 0) {
|
||||
data.redPlayers[playerBattleStats.playerId] = playerBattleStats;
|
||||
}
|
||||
if (playerBattleStats.team === 1) {
|
||||
data.bluePlayers[playerBattleStats.playerId] = playerBattleStats;
|
||||
}
|
||||
roundRecords.forEach((round) => {
|
||||
data.roundsData[round.roundNumber] = {
|
||||
...data.roundsData[round.roundNumber],
|
||||
[round.playerId]: round.arrowHistory,
|
||||
};
|
||||
});
|
||||
});
|
||||
console.log("game result:", result);
|
||||
console.log("format data:", data);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const simulShootAPI = (device_id, x, y) => {
|
||||
|
||||
Reference in New Issue
Block a user