Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Commit

Permalink
fix: game-over with wrong parts pickup (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoishin authored and Alex Van Camp committed May 23, 2019
1 parent d1e4f4e commit f1dc54b
Show file tree
Hide file tree
Showing 6 changed files with 27,689 additions and 22 deletions.
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/GameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Secret {
export interface Player {
id: number;
name: string;
status: string;
status: 'LOST' | 'WON' | 'TIED' | '';
turn: boolean;
questCounter: number;
timeout: number;
Expand Down
10 changes: 5 additions & 5 deletions src/line-parsers/game-over.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {GameState} from '../GameState';

// Check if the game is over.
export class GameOverLineParser extends AbstractLineParser {
regex = /\[Power\] GameState\.DebugPrintPower\(\) - TAG_CHANGE Entity=(.*) tag=PLAYSTATE value=(LOST|WON|TIED)/;
regex = /\[Power\] GameState\.DebugPrintPower\(\) -\s+TAG_CHANGE Entity=(.*) tag=PLAYSTATE value=(LOST|WON|TIED)/;

eventName = 'game-over' as const;

lineMatched(parts: string[], gameState: GameState): void {
lineMatched([, entity, status]: string[], gameState: GameState): void {
// Set the status for the appropriate player.
const player = gameState.getPlayerByName(parts[0]);
if (player) {
player.status = parts[1];
const player = gameState.getPlayerByName(entity);
if (player && (status === 'WON' || status === 'LOST' || status === 'TIED')) {
player.status = status;
}

gameState.gameOverCount++;
Expand Down
Loading

0 comments on commit f1dc54b

Please sign in to comment.