allow player to claim win/draw for abandoned games
This commit is contained in:
@@ -62,13 +62,19 @@ export function initSocket(
|
||||
}: {
|
||||
reason: string;
|
||||
winnerName?: string;
|
||||
winnerSide?: string;
|
||||
winnerSide?: "white" | "black" | "draw";
|
||||
}) => {
|
||||
const m = {
|
||||
author: { name: "server" }
|
||||
} as Message;
|
||||
|
||||
if (reason === "checkmate") {
|
||||
if (reason === "abandoned") {
|
||||
if (!winnerSide) {
|
||||
m.message = `${winnerName} has claimed a draw due to abandonment.`;
|
||||
} else {
|
||||
m.message = `${winnerName} (${winnerSide}) has claimed the win due to abandonment.`;
|
||||
}
|
||||
} else if (reason === "checkmate") {
|
||||
m.message = `${winnerName} (${winnerSide}) has won by checkmate.`;
|
||||
} else {
|
||||
let message = "The game has ended in a draw";
|
||||
@@ -81,6 +87,10 @@ export function initSocket(
|
||||
}
|
||||
m.message = message.concat(".");
|
||||
}
|
||||
actions.updateLobby({
|
||||
type: "updateLobby",
|
||||
payload: { reason, winner: winnerSide || "draw" }
|
||||
});
|
||||
actions.addMessage(m);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user