This repository was archived by the owner on Oct 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mulligan): refine mulligan timing for slightly earlier exit (#43)
* fix(mulligan): refine mulligan timing for slightly earlier exit * refactor: define deck card count as const
- Loading branch information
Showing
10 changed files
with
6,094 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DECK_CARD_COUNT = 30; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {AbstractLineParser} from './AbstractLineParser'; | ||
import {GameState} from '../GameState'; | ||
import {DECK_CARD_COUNT} from '../data/meta'; | ||
|
||
const calcCardsReplaced = (cardsLeft: number, cardCount: number): number => { | ||
return DECK_CARD_COUNT - cardCount - cardsLeft; | ||
}; | ||
|
||
// Detect how many cards are replaced in mulligan | ||
export class MullinganResultParser extends AbstractLineParser { | ||
regex = /\[Power\]\s+GameState\.DebugPrintEntitiesChosen\(\)\s+-\s+id=\w+\s+Player=(.*)\s+EntitiesCount=(\d+)/; | ||
|
||
eventName = 'mulligan-result' as const; | ||
|
||
lineMatched([, name, cardsLeft]: string[], gameState: GameState): void { | ||
if (!gameState.mulliganActive) { | ||
return; | ||
} | ||
|
||
const player = gameState.getPlayerByName(name); | ||
if (!player) { | ||
return; | ||
} | ||
|
||
player.cardsReplacedInMulligan = calcCardsReplaced(parseInt(cardsLeft, 10), player.cardCount); | ||
} | ||
|
||
formatLogMessage([, name, cardsLeft]: string[], gameState: GameState): string | false { | ||
if (!gameState.mulliganActive) { | ||
return false; | ||
} | ||
|
||
const player = gameState.getPlayerByName(name); | ||
if (!player) { | ||
return false; | ||
} | ||
|
||
return `${player.name} replaced ${calcCardsReplaced(parseInt(cardsLeft, 10), player.cardCount)} cards in mulligan`; | ||
} | ||
|
||
shouldEmit(gameState: GameState): boolean { | ||
return gameState.mulliganActive; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.