Reset all of player's properties when dealing cards
This commit is contained in:
parent
4d1a2f7fee
commit
46071152a4
1 changed files with 2 additions and 2 deletions
|
@ -45,11 +45,11 @@ get key (Players playersByKey) = playersByKey ! key
|
||||||
set :: Ord key => key -> Player key yakus -> Players key yakus -> Players key yakus
|
set :: Ord key => key -> Player key yakus -> Players key yakus -> Players key yakus
|
||||||
set key player (Players playersByKey) = Players $ insert key player playersByKey
|
set key player (Players playersByKey) = Players $ insert key player playersByKey
|
||||||
|
|
||||||
deal :: Ord key => Players key yakus -> [[Card]] -> Players key yakus
|
deal :: (Ord key, Monoid yakus) => Players key yakus -> [[Card]] -> Players key yakus
|
||||||
deal (Players playersByKey) hands =
|
deal (Players playersByKey) hands =
|
||||||
Players $ snd $ foldl dealTo (fst $ findMin playersByKey, playersByKey) hands
|
Players $ snd $ foldl dealTo (fst $ findMin playersByKey, playersByKey) hands
|
||||||
where
|
where
|
||||||
setHand cards player = player {hand = packOfCards cards}
|
setHand cards (Player {nextPlayer}) = (new nextPlayer) {hand = packOfCards cards}
|
||||||
dealTo (key, m) hand = (nextPlayer $ m ! key, adjust (setHand hand) key m)
|
dealTo (key, m) hand = (nextPlayer $ m ! key, adjust (setHand hand) key m)
|
||||||
|
|
||||||
plays :: Player key yakus -> Card -> Either String (Player key yakus)
|
plays :: Player key yakus -> Card -> Either String (Player key yakus)
|
||||||
|
|
Loading…
Reference in a new issue