labyrinth 0.1.5.1 → 0.1.6.0
raw patch · 4 files changed
+23/−11 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- labyrinth.cabal +1/−7
- src/Labyrinth/Show.hs +2/−2
- src/LabyrinthServer.hs +5/−2
- src/LabyrinthServer/Data.hs +15/−0
labyrinth.cabal view
@@ -1,5 +1,5 @@ name: labyrinth-version: 0.1.5.1+version: 0.1.6.0 synopsis: A complicated turn-based game description: Players take turns in a labyrinth, competing with each other to pick a treasure and carry it out. They only know@@ -18,10 +18,6 @@ type: git location: git://github.com/koterpillar/labyrinth.git -flag static- description: Link the binary statically- default: False- library build-depends: base >= 4.5 && < 4.7 , mtl ==2.1.*@@ -78,8 +74,6 @@ , json ==0.7.* , monad-loops ==0.3.* hs-source-dirs: src- if (flag(static))- ghc-options: -static -optl-pthread -optl-static test-Suite tests type: exitcode-stdio-1.0
src/Labyrinth/Show.hs view
@@ -171,8 +171,8 @@ show (Move []) = "skip" show (Move acts) = commaSepShow acts show (Query qs) = "query " ++ commaSepShow qs- show (ChoosePosition _) = "[choose position]"- show (ReorderCell _) = "[reorder cell]"+ show (ChoosePosition _) = "choose * *"+ show (ReorderCell _) = "reorder * *" show (Say str) = "say " ++ str instance Show CellTypeResult where
src/LabyrinthServer.hs view
@@ -65,6 +65,7 @@ myApp acid = msum (map ($ acid) actions) `mplus` fileServing where actions = [ createGame , listGames+ , listExampleMoves ] ++ map gameAction gameActions gameActions = [ makeMove@@ -81,8 +82,6 @@ createGame :: AcidState Games -> ServerPart Response createGame acid = dir "add" $ nullDir >> method POST >> do- nullDir- decodeBody bodyPolicy lWidth <- lookRead "width" lHeight <- lookRead "height" pCount <- lookRead "players"@@ -95,6 +94,10 @@ listGames acid = dir "list" $ nullDir >> do games <- query' acid GetGames ok $ toResponse $ J.encode $ gameListJSON games++listExampleMoves :: AcidState Games -> ServerPart Response+listExampleMoves _ = dir "examples" $ nullDir >> method GET >> do+ ok $ toResponse $ J.encode $ exampleMovesJSON showLog :: AcidState Games -> GameId -> ServerPart Response showLog acid gameId = dir "log" $ nullDir >> do
src/LabyrinthServer/Data.hs view
@@ -129,6 +129,21 @@ , 'performMove ] +exampleMoves :: [Move]+exampleMoves = [ ChoosePosition (Pos 2 4)+ , Move [goTowards L]+ , Move [Shoot U]+ , Move [Grenade D, goTowards D]+ , ReorderCell (Pos 3 3)+ , Query [BulletCount, GrenadeCount, PlayerHealth]+ , Say "hello"+ , Move [Conditional "hit a wall" [Grenade D] [Shoot L]]+ , Move [Surrender]+ ]++exampleMovesJSON :: JSValue+exampleMovesJSON = JSArray $ map jsShow $ exampleMoves+ logJSON :: MoveLog -> JSValue logJSON g = JSArray $ map moveJSON g where moveJSON l = jsObject [ ("player", jsInt $ l ^. rplayer)