BUG修复
This commit is contained in:
72
src/apis.js
72
src/apis.js
@@ -270,78 +270,6 @@ export const readyGameAPI = (battleId) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getGameAPI = async (battleId) => {
|
||||
const result = await request("POST", "/user/battle/detail", {
|
||||
id: battleId,
|
||||
});
|
||||
if (!result.battleStats) return {};
|
||||
const {
|
||||
battleStats = {},
|
||||
playerStats = {},
|
||||
goldenRoundRecords = [],
|
||||
} = result;
|
||||
const data = {
|
||||
id: battleId,
|
||||
mode: battleStats.mode, // 1.几V几 2.大乱斗
|
||||
gameMode: battleStats.gameMode, // 1.约战 2.排位
|
||||
teamSize: battleStats.teamSize,
|
||||
};
|
||||
if (battleStats && battleStats.mode === 1) {
|
||||
data.winner = battleStats.winner;
|
||||
data.roundsData = {};
|
||||
data.redPlayers = {};
|
||||
data.bluePlayers = {};
|
||||
data.mvps = [];
|
||||
data.goldenRounds =
|
||||
goldenRoundRecords && goldenRoundRecords.length ? goldenRoundRecords : [];
|
||||
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;
|
||||
}
|
||||
if (playerBattleStats.mvp) {
|
||||
data.mvps.push(playerBattleStats);
|
||||
}
|
||||
roundRecords.forEach((round) => {
|
||||
data.roundsData[round.roundNumber] = {
|
||||
...data.roundsData[round.roundNumber],
|
||||
[round.playerId]: round.arrowHistory,
|
||||
};
|
||||
});
|
||||
});
|
||||
const totalRounds = Object.keys(data.roundsData).length;
|
||||
(goldenRoundRecords || []).forEach((item, index) => {
|
||||
item.arrowHistory.forEach((arrow) => {
|
||||
if (!data.roundsData[totalRounds + index + 1]) {
|
||||
data.roundsData[totalRounds + index + 1] = {};
|
||||
}
|
||||
if (!data.roundsData[totalRounds + index + 1][arrow.playerId]) {
|
||||
data.roundsData[totalRounds + index + 1][arrow.playerId] = [];
|
||||
}
|
||||
data.roundsData[totalRounds + index + 1][arrow.playerId].push(arrow);
|
||||
});
|
||||
});
|
||||
|
||||
data.mvps.sort((a, b) => b.totalRings - a.totalRings);
|
||||
}
|
||||
if (battleStats && battleStats.mode === 2) {
|
||||
data.players = [];
|
||||
playerStats.forEach((item) => {
|
||||
data.players.push({
|
||||
...item.playerBattleStats,
|
||||
arrowHistory: item.roundRecords[0].arrowHistory,
|
||||
});
|
||||
});
|
||||
data.players = data.players.sort((a, b) => b.totalScore - a.totalScore);
|
||||
}
|
||||
// console.log("game result:", result);
|
||||
// console.log("format data:", data);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const simulShootAPI = (device_id, x, y) => {
|
||||
const data = {
|
||||
device_id,
|
||||
|
||||
Reference in New Issue
Block a user