diff --git a/src/functions/gameReducer.ts b/src/functions/gameReducer.ts index 78875a8..1276e0b 100644 --- a/src/functions/gameReducer.ts +++ b/src/functions/gameReducer.ts @@ -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 @@ -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) { /** @@ -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();