Support battle outcomes being 3 states

This commit is contained in:
thepaperpilot 2023-02-18 23:42:43 -06:00
parent 1cc254546b
commit bd5ccff23d
2 changed files with 6 additions and 4 deletions

View file

@ -135,10 +135,10 @@ function setupSocket(socket: Socket<ServerToClientEvents, ClientToServerEvents>)
main.team.value[index] = null; main.team.value[index] = null;
main.team.value[otherIndex] = char; main.team.value[otherIndex] = char;
}); });
socket.on("stream", (enemyTeam, enemyNickname, victory) => { socket.on("stream", (enemyTeam, enemyNickname, outcome) => {
if (victory) { if (outcome === "Victory") {
main.wins.value++; main.wins.value++;
} else { } else if (outcome === "Defeat") {
main.lives.value--; main.lives.value--;
} }
main.findingMatch.value = false; main.findingMatch.value = false;

4
src/data/types.d.ts vendored
View file

@ -12,6 +12,8 @@ interface Character {
presence: number; presence: number;
} }
type BattleOutcome = "Victory" | "Defeat" | "Tie";
interface ServerToClientEvents { interface ServerToClientEvents {
"server version": (semver: string) => void; "server version": (semver: string) => void;
nickname: (nickname: string) => void; nickname: (nickname: string) => void;
@ -21,7 +23,7 @@ interface ServerToClientEvents {
buy: (shopIndex: number, teamIndex: number, char: Character) => void; buy: (shopIndex: number, teamIndex: number, char: Character) => void;
move: (index: number, otherIndex: number) => void; move: (index: number, otherIndex: number) => void;
merge: (shopIndex: number, teamIndex: number, char: Character) => void; merge: (shopIndex: number, teamIndex: number, char: Character) => void;
stream: (enemyTeam: Character[], nickname: string, victory: boolean) => void; stream: (enemyTeam: (Character | null)[], nickname: string, outcome: BattleOutcome) => void;
} }
interface ClientToServerEvents { interface ClientToServerEvents {