Skip to content

Commit

Permalink
Tweaks to reporting results
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Dec 10, 2024
1 parent eca615a commit 50e38f8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion referee/referee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ global.playerConnected = async (addr: number, player: number) => {
global.playerDisconnected = async (addr: number, player: number) => {
console.log(`Someone disconnected, ending the game`);
done = true;
await reportResults(gameId, {
gameId: gameId,
result: "disconnect",
playerOne: {
pkh: Object.values(players).find(p => p.playerNumber === 0)?.ephemeralKey,
kills: hydra.clients[0].kills,
},
playerTwo: {
pkh: Object.values(players).find(p => p.playerNumber === 1)?.ephemeralKey,
kills: hydra.clients[1].kills,
}
})
if (!RECORD_STATS) return;
try {
await fetch("http://localhost:8000/player_left", { method: "POST" });
Expand Down Expand Up @@ -324,7 +336,7 @@ try {
while (!done) {
await new Promise((resolve) => setTimeout(resolve, 1000));
timeout -= 1000;
timer -= 0;
timer -= 1000;
if (timer <= 0) {
console.log("Game ended.");
done = true;
Expand All @@ -347,6 +359,14 @@ while (!done) {
await reportResults(gameId, {
gameId: gameId,
result: "timeout",
playerOne: {
pkh: Object.values(players).find(p => p.playerNumber === 0)?.ephemeralKey,
kills: hydra.clients[0].kills,
},
playerTwo: {
pkh: Object.values(players).find(p => p.playerNumber === 1)?.ephemeralKey,
kills: hydra.clients[1].kills,
}
});
}
}
Expand Down

0 comments on commit 50e38f8

Please sign in to comment.