Skip to content

Commit

Permalink
Make split take priority over I18
Browse files Browse the repository at this point in the history
  • Loading branch information
mhluska committed Jan 29, 2023
1 parent bfec99a commit a72b961
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ export default class Game extends EventEmitter {
const hiLoResult = HiLoDeviationChecker.check(this, hand, input);
const basicStrategyResult = BasicStrategyChecker.check(this, hand, input);

// If surrender is correct, it should take priority over I18 deviations.
// If surrender/split is correct, it should take priority over I18
// deviations.
// TODO: After we add a game mode for Fab4, we should split those checks out
// into their own checker since we do want to still run those in the
// surrender case.
const checkerResult =
input === Move.Surrender && basicStrategyResult === true
(input === Move.Surrender || input === Move.Split) &&
basicStrategyResult === true
? true
: hiLoResult || basicStrategyResult;

Expand Down
26 changes: 26 additions & 0 deletions test/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,32 @@ describe('Game', function () {
});
});

context('when splitting is allowed', function () {
before(function () {
game = setupGame({
settings: {
deckCount: 6,
mode: GameMode.Illustrious18,
},
dealerCards: [Rank.Two],
playerCards: [Rank.Six, Rank.Six],
});

runGame(game, {
input: [
{
[GameStep.WaitingForPlayInput]: Move.Split,
},
],
});
});

it('should take priority over illustrious 18', function () {
expect(game.state.sessionMovesTotal).to.equal(1);
expect(game.state.sessionMovesCorrect).to.equal(1);
});
});

context('when resplit aces is disabled', function () {
before(function () {
game = setupGame({
Expand Down

0 comments on commit a72b961

Please sign in to comment.