Advertisement
Guest User

Untitled

a guest
Apr 5th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.55 KB | None | 0 0
  1.     def drawCard: GameState => Game = gs => {
  2.       val player = gs(pi)
  3.  
  4.       player.deck match {
  5.         case next +: rest =>
  6.           val newGS = gs.updatePlayer(player.copy(
  7.             hand = player.hand :+ next,
  8.             deck = rest))
  9.           EffectDone(newGS, CardDrawn(pi, next))
  10.         case Nil =>
  11.           //Do nothing if both deck and discard are empty
  12.           if (player.discard.isEmpty) EffectDone(gs)
  13.           //Reshuffle discard into deck, then draw
  14.           else reshufflePlayerDeck(pi)(gs).flatMap(drawCard)
  15.       }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement