Skip to content

Commit

Permalink
add case for GameAction.Deal
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsagit committed Apr 19, 2024
1 parent 653f430 commit af99ae7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/functions/gameReducer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PlayerStore, PlayingCard, PlayingCardDeck } from "../classes";
import { gameDefaults } from "../context";
import { defaultplayersArr, playerDefaults } from "../definitions";
import { defaultplayersArr } from "../definitions";
import { GameAction, GameStatus } from "../enums";
import { IGameReducerAction } from "../interfaces";
import { GameState, PlayerStats } from "../types";
import { evaluateGame, endgameTrap } from "./";
import { GameState } from "../types";
import { endgameTrap, evaluateGame } from "./";

/**
* Reducer function for game state
Expand Down Expand Up @@ -33,15 +33,14 @@ export function gameReducer(state: GameState, action: IGameReducerAction) {
// Announce
console.log('## GameAction.' + type, JSON.stringify(action));

// Evaluate game state
// Evaluate game state every time
state = evaluateGame(state, action);


// Mandatory state mutations
state.lastWriteTime = new Date().toISOString();



// Respond to action dispatch
switch (type) {

/**
Expand Down Expand Up @@ -315,6 +314,11 @@ export function gameReducer(state: GameState, action: IGameReducerAction) {
return state;
}

case GameAction.Deal: {
state.deck.deal(2);
return state;
}

// Populate and shuffle the deck
case GameAction.Reset: {
state.deck.reset();
Expand Down

0 comments on commit af99ae7

Please sign in to comment.