Commit f83e1901 authored by nanahira's avatar nanahira

fix

parent 218c06c8
Pipeline #2282 passed with stages
in 26 seconds
......@@ -62,7 +62,7 @@ async function checkQuit(round: number, oldPlayerId: number) {
await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, {
responseType: 'json'
});
console.log(`Successfully quitting player ${oldPlayer.name} in round ${round}.`);
console.log(`Successfully quitted player ${oldPlayer.name} in round ${round}.`);
} catch (e) {
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`);
}
......@@ -85,13 +85,13 @@ async function migrateMatch(match: Match) {
return;
}
let winner_id: string | number;
if(oldMatch.winner_id === "tie") {
winner_id = "tie";
console.log(`Migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name} with tie.`);
} else {
if (typeof(oldMatch.winner_id) === "number") {
const winnerName = oldParticipantIdMap.get(oldMatch.winner_id as number).name;
winner_id = newParticipantNameMap.get(winnerName).id;
console.log(`Migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name} with winner ${winnerName}.`);
} else {
winner_id = oldMatch.winner_id;
console.log(`Migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name} with result ${winner_id}.`);
}
const oldPlayerIds = [oldMatch.player1_id, oldMatch.player2_id]
await Promise.all(oldPlayerIds.map(pid => checkQuit(match.round, pid)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment