Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def drawCard: GameState => Game = gs => {
- val player = gs(pi)
- player.deck match {
- case next +: rest =>
- val newGS = gs.updatePlayer(player.copy(
- hand = player.hand :+ next,
- deck = rest))
- EffectDone(newGS, CardDrawn(pi, next))
- case Nil =>
- //Do nothing if both deck and discard are empty
- if (player.discard.isEmpty) EffectDone(gs)
- //Reshuffle discard into deck, then draw
- else reshufflePlayerDeck(pi)(gs).flatMap(drawCard)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement