packages feed

wordify 0.4.0.0 → 0.5.0.0

raw patch · 3 files changed

+10/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Wordify.Rules.Move: ExchangeTransition :: Game -> Player -> Player -> GameTransition
+ Wordify.Rules.Move: ExchangeTransition :: Game -> Player -> Player -> [Tile] -> GameTransition

Files

src/Wordify/Rules/Move.hs view
@@ -32,8 +32,8 @@ data GameTransition   = -- | The new player (with their updated letter rack and score), new game state, and the words formed by the move     MoveTransition Player Game FormedWords-  | -- | The new game state, and the player with their rack before and after the exchange respectively.-    ExchangeTransition Game Player Player+  | -- | The new game state, the player with their rack before and after the exchange respectively.and the exchanged tiles+    ExchangeTransition Game Player Player [Tile]   | -- | The new game state with the opportunity to play passed on to the next player.     PassTransition Game   | -- |@@ -102,7 +102,7 @@                 (Left $ PlayerCannotExchange (tilesOnRack player) exchangedTiles)                 ( \exchangedPlayer ->                     let gameState = updateGame game exchangedPlayer (board game) newBag-                     in Right $ ExchangeTransition gameState player exchangedPlayer+                     in Right $ ExchangeTransition gameState player exchangedPlayer exchangedTiles                 )                 newPlayer   where@@ -151,13 +151,13 @@  newGame :: GameTransition -> Game newGame (MoveTransition _ game _) = game-newGame (ExchangeTransition game _ _) = game+newGame (ExchangeTransition game _ _ _) = game newGame (PassTransition game) = game newGame (GameFinished game _) = game  addMoveToHistory :: GameTransition -> Move -> GameTransition addMoveToHistory (MoveTransition player game formedWords) move = MoveTransition player (updateHistory game move) formedWords-addMoveToHistory (ExchangeTransition game oldPlayer newPlayer) move = ExchangeTransition (updateHistory game move) oldPlayer newPlayer+addMoveToHistory (ExchangeTransition game oldPlayer newPlayer exchangedTiles) move = ExchangeTransition (updateHistory game move) oldPlayer newPlayer exchangedTiles addMoveToHistory (PassTransition game) move = PassTransition (updateHistory game move) addMoveToHistory (GameFinished game wordsFormed) move = GameFinished (updateHistory game move) wordsFormed 
test/Tests/FullGameTest.hs view
@@ -154,7 +154,7 @@     let Right testGame = game     let firstPlayer = player1 testGame     let playerTiles = tilesOnRack firstPlayer-    let move = Exchange playerTiles+    let move = Exchange (drop 1 playerTiles)     let outcome = makeMove testGame move      assertBool ("Expected move to be successful. ") $ isValid outcome@@ -164,10 +164,11 @@     let newPlayer1 = player1 nextGame      case transition of-      ExchangeTransition game playerBefore playerAfter ->+      ExchangeTransition game playerBefore playerAfter tiles ->         do           assertEqual "playerBefore in the transition should be the player before making the move" (firstPlayer) playerBefore           assertEqual "playerAfter in the transition should be the player after making the move" (newPlayer1) playerAfter+          assertEqual "Exchanged tiles in the transition should be the tiles exchanged in the move" (drop 1 playerTiles) tiles      assertBool ("Player 1 should have new letters on their rack. Player 1 was: " ++ (show newPlayer1)) (not $ firstPlayer == newPlayer1) @@ -176,7 +177,7 @@     assertBool "Player number and move number incremented" $ (playerNumber nextGame == 2) && (moveNumber nextGame) == 2      let originalLetterBag = bag testGame-    let exchangedLetterBag = fmap snd (exchangeLetters originalLetterBag playerTiles)+    let exchangedLetterBag = fmap snd (exchangeLetters originalLetterBag (drop 1 playerTiles))      assertEqual "The letter bag for the game transition is as expected " exchangedLetterBag (Just $ bag nextGame) 
wordify.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           wordify-version:        0.4.0.0+version:        0.5.0.0 description:    Please see the README on GitHub at <https://github.com/githubuser/wordify#readme> category:       Game homepage:       https://github.com/happy0/wordify#readme