diff --git a/lib/RPGEngine/Data/Types.hs b/lib/RPGEngine/Data.hs similarity index 80% rename from lib/RPGEngine/Data/Types.hs rename to lib/RPGEngine/Data.hs index af812bd..b91b7f2 100644 --- a/lib/RPGEngine/Data/Types.hs +++ b/lib/RPGEngine/Data.hs @@ -1,13 +1,33 @@ -module RPGEngine.Data.Types where +module RPGEngine.Data where -------------------------------- Game -------------------------------- -- TODO Add more data Game = Game { -- Current state of the game - state :: State + state :: State, + playing :: Level, + levels :: [Level] } +------------------------------- Level -------------------------------- + +data Level = Level { + layout :: Layout, + items :: [Item], + entities :: [Entity] +} + +type Layout = [Strip] +type Strip = [Physical] + +data Physical = Void + | Walkable + | Blocked + | Entrance + | Exit + deriving (Show, Eq) + ------------------------------- Player ------------------------------- data Player = Player { @@ -108,8 +128,9 @@ data Action = Leave ------------------------------ Direction ----------------------------- -data Direction = North - | East - | South +data Direction = North + | East + | South | West - deriving (Show) \ No newline at end of file + | Center -- Equal to 'stay where you are' + deriving (Show, Eq) \ No newline at end of file diff --git a/lib/RPGEngine/Data/Game.hs b/lib/RPGEngine/Data/Game.hs index 9f5bd8a..82750f6 100644 --- a/lib/RPGEngine/Data/Game.hs +++ b/lib/RPGEngine/Data/Game.hs @@ -5,7 +5,7 @@ module RPGEngine.Data.Game ,initGame ) where -import RPGEngine.Data.Types +import RPGEngine.Data import RPGEngine.Data.State ---------------------------------------------------------------------- @@ -13,5 +13,13 @@ import RPGEngine.Data.State -- Initialize the game initGame :: Game initGame = Game { - state = defaultState + state = defaultState, + playing = head levels, + levels = levels } + where levels = [emptyLevel] + emptyLevel = Level { + layout = [], + items = [], + entities = [] + } diff --git a/lib/RPGEngine/Data/State.hs b/lib/RPGEngine/Data/State.hs index 1953d73..42d9d3f 100644 --- a/lib/RPGEngine/Data/State.hs +++ b/lib/RPGEngine/Data/State.hs @@ -9,7 +9,7 @@ module RPGEngine.Data.State , nextState ) where -import RPGEngine.Data.Types +import RPGEngine.Data ----------------------------- Constants ------------------------------ diff --git a/lib/RPGEngine/Input.hs b/lib/RPGEngine/Input.hs index 767a8d4..04b6a6a 100644 --- a/lib/RPGEngine/Input.hs +++ b/lib/RPGEngine/Input.hs @@ -4,7 +4,7 @@ module RPGEngine.Input ( handleAllInput ) where -import RPGEngine.Data.Types +import RPGEngine.Data import RPGEngine.Data.State import RPGEngine.Input.Core diff --git a/lib/RPGEngine/Parse.hs b/lib/RPGEngine/Parse.hs index 477b150..f5838d3 100644 --- a/lib/RPGEngine/Parse.hs +++ b/lib/RPGEngine/Parse.hs @@ -1,8 +1,19 @@ module RPGEngine.Parse where -import RPGEngine.Data.Types +import RPGEngine.Data +import RPGEngine.Parse.StructureElement +import RPGEngine.Parse.Game --- TODO parseFromFile gebruiken +import Text.Parsec.String +import System.IO.Unsafe -parseToGame :: Game -parseToGame = undefined \ No newline at end of file +----------------------------- Constants ------------------------------ + +type FileName = String + +---------------------------------------------------------------------- + +parseToGame :: FileName -> Game +parseToGame filename = structureToGame structure + where (Right structure) = unsafePerformIO io + io = parseFromFile structureElement filename \ No newline at end of file diff --git a/lib/RPGEngine/Parse/Game.hs b/lib/RPGEngine/Parse/Game.hs new file mode 100644 index 0000000..85028f2 --- /dev/null +++ b/lib/RPGEngine/Parse/Game.hs @@ -0,0 +1,22 @@ +module RPGEngine.Parse.Game where + +import RPGEngine.Data +import RPGEngine.Parse.StructureElement (StructureElement) + +-------------------------------- Game -------------------------------- + +-- TODO +structureToGame :: StructureElement -> Game +structureToGame = undefined + +------------------------------- Player ------------------------------- + +-- TODO +structureToPlayer :: StructureElement -> Player +structureToPlayer = undefined + +------------------------------- Levels ------------------------------- + +-- TODO +structureToLevels :: StructureElement -> [Level] +structureToLevels = undefined \ No newline at end of file diff --git a/lib/RPGEngine/Parse/StructureElement.hs b/lib/RPGEngine/Parse/StructureElement.hs index e8f4b34..ce5d8c5 100644 --- a/lib/RPGEngine/Parse/StructureElement.hs +++ b/lib/RPGEngine/Parse/StructureElement.hs @@ -1,6 +1,6 @@ module RPGEngine.Parse.StructureElement where -import RPGEngine.Data.Types (Action(..), Condition(..)) +import RPGEngine.Data (Action(..), Condition(..), Layout, Direction(..), Physical(..), Strip) import RPGEngine.Parse.Core ( ignoreWS ) import Text.Parsec @@ -38,7 +38,7 @@ structureElement = try $ choice [block, entry, regular] block :: Parser StructureElement block = try $ do open <- ignoreWS $ oneOf openingBrackets - middle <- ignoreWS entry `sepBy` ignoreWS (char ',') + middle <- ignoreWS $ choice [entry, block] `sepBy` char ',' let closingBracket = getMatchingClosingBracket open ignoreWS $ char closingBracket return $ Block middle @@ -75,7 +75,7 @@ tag = try $ Tag <$> many1 alphaNum conditionList :: Parser Key conditionList = try $ do open <- ignoreWS $ oneOf openingBrackets - list <- try $ ignoreWS condition `sepBy` ignoreWS (char ',') + list <- ignoreWS condition `sepBy` char ',' let closingBracket = getMatchingClosingBracket open ignoreWS $ char closingBracket return $ ConditionList $ extract list @@ -102,13 +102,14 @@ data Value = String String | Integer Int | Infinite | Action Action - | Layout -- TODO Add element + | Direction Direction + | Layout Layout deriving (Show, Eq) ---------------------------------------------------------------------- value :: Parser Value -value = choice [string, integer, infinite, action] +value = choice [string, integer, infinite, action, direction] string :: Parser Value string = try $ String <$> between (char '\"') (char '\"') reading @@ -134,13 +135,52 @@ action = try $ do | script == "useItem" = UseItem arg | script == "decreaseHp" = DecreaseHp first second | script == "increasePlayerHp" = IncreasePlayerHp arg - | otherwise = RPGEngine.Data.Types.Nothing + | otherwise = RPGEngine.Data.Nothing (first, ',':second) = break (== ',') arg return $ Action answer --- TODO +direction :: Parser Value +direction = try $ do + value <- choice [ + ignoreWS $ P.string "up", + ignoreWS $ P.string "down", + ignoreWS $ P.string "left", + ignoreWS $ P.string "right" + ] + notFollowedBy alphaNum + return $ Direction $ make value + where make "up" = North + make "right" = East + make "down" = South + make "left" = West + make _ = Center + layout :: Parser Value -layout = undefined +layout = try $ do + ignoreWS $ char '|' + list <- ignoreWS strip `sepBy` ignoreWS (char '|') + return $ Layout list + +strip :: Parser Strip +strip = try $ do + physical `sepBy` char ' ' + +physical :: Parser Physical +physical = try $ do + value <- choice [ + char 'x', + char '.', + char '*', + char 's', + char 'e' + ] + return $ make value + where make '.' = Walkable + make '*' = Blocked + make 's' = Entrance + make 'e' = Exit + make _ = Void + ------------------------------ Brackets ------------------------------ diff --git a/lib/RPGEngine/Render.hs b/lib/RPGEngine/Render.hs index ca39b23..03e7855 100644 --- a/lib/RPGEngine/Render.hs +++ b/lib/RPGEngine/Render.hs @@ -7,7 +7,7 @@ module RPGEngine.Render , render ) where -import RPGEngine.Data.Types +import RPGEngine.Data import Graphics.Gloss ----------------------------- Constants ------------------------------ diff --git a/rpg-engine.cabal b/rpg-engine.cabal index 4968079..f6a304b 100644 --- a/rpg-engine.cabal +++ b/rpg-engine.cabal @@ -13,8 +13,8 @@ library exposed-modules: RPGEngine + RPGEngine.Data RPGEngine.Data.Game - RPGEngine.Data.Types RPGEngine.Data.State RPGEngine.Input @@ -22,6 +22,7 @@ library RPGEngine.Parse RPGEngine.Parse.Core + RPGEngine.Parse.Game RPGEngine.Parse.StructureElement RPGEngine.Render @@ -39,6 +40,5 @@ test-suite rpg-engine-test default-language: Haskell2010 build-depends: base >=4.7 && <5, hspec <= 2.10.6, hspec-discover, rpg-engine other-modules: - InteractionSpec, -- Parsing - ParsedToGameSpec, ParserSpec + ParseGameSpec, ParseStructureElementSpec diff --git a/test/InteractionSpec.hs b/test/InteractionSpec.hs deleted file mode 100644 index 63801af..0000000 --- a/test/InteractionSpec.hs +++ /dev/null @@ -1,9 +0,0 @@ -module InteractionSpec where - -import Test.Hspec - -spec :: Spec -spec = do - describe "Player with Inventory" $ do - it "TODO: Simple test" $ do - pending \ No newline at end of file diff --git a/test/ParsedToGameSpec.hs b/test/ParseGameSpec.hs similarity index 93% rename from test/ParsedToGameSpec.hs rename to test/ParseGameSpec.hs index 9a6aec6..a162246 100644 --- a/test/ParsedToGameSpec.hs +++ b/test/ParseGameSpec.hs @@ -1,7 +1,7 @@ -module ParsedToGameSpec where +module ParseGameSpec where import Test.Hspec -import RPGEngine.Internals.Parse.StructureElement +import RPGEngine.Parse.StructureElement spec :: Spec spec = do diff --git a/test/ParseStructureElementSpec.hs b/test/ParseStructureElementSpec.hs new file mode 100644 index 0000000..bc70837 --- /dev/null +++ b/test/ParseStructureElementSpec.hs @@ -0,0 +1,282 @@ +module ParseStructureElementSpec where + +import Test.Hspec + +import RPGEngine.Data +import RPGEngine.Parse.Core +import RPGEngine.Parse.StructureElement + +spec :: Spec +spec = do + describe "StructureElement" $ do + it "can parse blocks" $ do + let input = "{}" + correct = Right $ Block [] + parseWith structureElement input `shouldBe` correct + + let input = "{{}}" + correct = Right $ Block [Block []] + parseWith structureElement input `shouldBe` correct + + let input = "{{}, {}}" + correct = Right $ Block [Block [], Block []] + parseWith structureElement input `shouldBe` correct + + let input = "{ id: 1 }" + correct = Right (Block [ + Entry (Tag "id") $ Regular $ Integer 1 + ], "") + parseWithRest structureElement input `shouldBe` correct + + let input = "{ id: \"key\", x: 3, y: 1}" + correct = Right $ Block [ + Entry (Tag "id") $ Regular $ String "key", + Entry (Tag "x") $ Regular $ Integer 3, + Entry (Tag "y") $ Regular $ Integer 1 + ] + parseWith structureElement input `shouldBe` correct + + let input = "actions: { [not(inventoryFull())] retrieveItem(key), [] leave()}" + correct = Right (Entry (Tag "actions") $ Block [ + Entry (ConditionList [Not InventoryFull]) $ Regular $ Action $ RetrieveItem "key", + Entry (ConditionList []) $ Regular $ Action Leave + ], "") + parseWithRest structureElement input `shouldBe` correct + + let input = "entities: [ { id: \"door\", x: 4, name:\"Secret door\", description: \"This secret door can only be opened with a key\", direction: left, y: 1}]" + correct = Right (Entry (Tag "entities") $ Block [ Block [ + Entry (Tag "id") $ Regular $ String "door", + Entry (Tag "x") $ Regular $ Integer 4, + Entry (Tag "name") $ Regular $ String "Secret door", + Entry (Tag "description") $ Regular $ String "This secret door can only be opened with a key", + Entry (Tag "direction") $ Regular $ Direction West, + Entry (Tag "y") $ Regular $ Integer 1 + ]], "") + parseWithRest structureElement input `shouldBe` correct + + let input = "entities: [ { id: \"door\", x: 4, y: 1, name:\"Secret door\", description: \"This secret door can only be opened with a key\", actions: { [inventoryContains(key)] useItem(key), [] leave() } } ]" + correct = Right (Entry (Tag "entities") $ Block [ Block [ + Entry (Tag "id") $ Regular $ String "door", + Entry (Tag "x") $ Regular $ Integer 4, + Entry (Tag "y") $ Regular $ Integer 1, + Entry (Tag "name") $ Regular $ String "Secret door", + Entry (Tag "description") $ Regular $ String "This secret door can only be opened with a key", + Entry (Tag "actions") $ Block [ + Entry (ConditionList [InventoryContains "key"]) $ Regular $ Action $ UseItem "key", + Entry (ConditionList []) $ Regular $ Action Leave + ] + ]], "") + parseWithRest structureElement input `shouldBe` correct + + let input = "entities: [ { id: \"door\", x: 4, y: 1, name:\"Secret door\", description: \"This secret door can only be opened with a key\", direction: left , actions: { [inventoryContains(key)] useItem(key), [] leave() } } ]" + correct = Right (Entry (Tag "entities") $ Block [ Block [ + Entry (Tag "id") $ Regular $ String "door", + Entry (Tag "x") $ Regular $ Integer 4, + Entry (Tag "y") $ Regular $ Integer 1, + Entry (Tag "name") $ Regular $ String "Secret door", + Entry (Tag "description") $ Regular $ String "This secret door can only be opened with a key", + Entry (Tag "direction") $ Regular $ Direction West, + Entry (Tag "actions") $ Block [ + Entry (ConditionList [InventoryContains "key"]) $ Regular $ Action $ UseItem "key", + Entry (ConditionList []) $ Regular $ Action Leave + ] + ]], "") + parseWithRest structureElement input `shouldBe` correct + + it "can parse entries" $ do + let input = "id: \"dagger\"" + correct = Right $ Entry (Tag "id") $ Regular $ String "dagger" + parseWith entry input `shouldBe` correct + + let input = "x: 0" + correct = Right $ Entry (Tag "x") $ Regular $ Integer 0 + parseWith entry input `shouldBe` correct + + let input = "useTimes: infinite" + correct = Right $ Entry (Tag "useTimes") $ Regular Infinite + parseWith entry input `shouldBe` correct + + let input = "direction: up" + correct = Right $ Entry (Tag "direction") $ Regular $ Direction North + parseWith entry input `shouldBe` correct + + let input = "actions: { [not(inventoryFull())] retrieveItem(key), [] leave()}" + correct = Right (Entry (Tag "actions") $ Block [ + Entry (ConditionList [Not InventoryFull]) $ Regular $ Action $ RetrieveItem "key", + Entry (ConditionList []) $ Regular $ Action Leave + ], "") + parseWithRest structureElement input `shouldBe` correct + + it "can parse regulars" $ do + let input = "this is a string" + correct = Right $ Regular $ String input + parseWith regular ("\"" ++ input ++ "\"") `shouldBe` correct + + let correct = Right $ Regular $ Integer 1 + parseWith regular "1" `shouldBe` correct + + let correct = Right $ Regular Infinite + parseWith regular "infinite" `shouldBe` correct + + let wrong = Right $ Regular Infinite + parseWith regular "infinitee" `shouldNotBe` wrong + + let input = "leave()" + correct = Right $ Regular $ Action Leave + parseWith regular input `shouldBe` correct + + let input = "retrieveItem(firstId)" + correct = Right $ Regular $ Action $ RetrieveItem "firstId" + parseWith regular input `shouldBe` correct + + let input = "useItem(secondId)" + correct = Right $ Regular $ Action $ UseItem "secondId" + parseWith regular input `shouldBe` correct + + let input = "decreaseHp(entityId,objectId)" + correct = Right $ Regular $ Action $ DecreaseHp "entityId" "objectId" + parseWith regular input `shouldBe` correct + + let input = "increasePlayerHp(objectId)" + correct = Right $ Regular $ Action $ IncreasePlayerHp "objectId" + parseWith regular input `shouldBe` correct + + let input = "up" + correct = Right $ Regular $ Direction North + parseWith regular input `shouldBe` correct + + let input = "right" + correct = Right $ Regular $ Direction East + parseWith regular input `shouldBe` correct + + let input = "down" + correct = Right $ Regular $ Direction South + parseWith regular input `shouldBe` correct + + let input = "left" + correct = Right $ Regular $ Direction West + parseWith regular input `shouldBe` correct + + describe "Key" $ do + it "can parse tags" $ do + let input = "simpletag" + correct = Right $ Tag "simpletag" + parseWith tag input `shouldBe` correct + + it "can parse conditionlists" $ do + let input = "[not(inventoryFull())]" + correct = Right (ConditionList [Not InventoryFull], "") + parseWithRest conditionList input `shouldBe` correct + + let input = "[inventoryFull(), inventoryContains(itemId)]" + correct = Right (ConditionList [ + InventoryFull, + InventoryContains "itemId" + ], "") + parseWithRest conditionList input `shouldBe` correct + + let input = "[]" + correct = Right $ ConditionList [] + parseWith conditionList input `shouldBe` correct + + it "can parse conditions" $ do + let input = "inventoryFull()" + correct = Right (Condition InventoryFull, "") + parseWithRest condition input `shouldBe` correct + + let input = "inventoryContains(itemId)" + correct = Right (Condition $ InventoryContains "itemId", "") + parseWithRest condition input `shouldBe` correct + + let input = "not(inventoryFull())" + correct = Right (Condition $ Not InventoryFull, "") + parseWithRest condition input `shouldBe` correct + + let input = "not(inventoryContains(itemId))" + correct = Right (Condition $ Not $ InventoryContains "itemId", "") + parseWithRest condition input `shouldBe` correct + + describe "Value" $ do + it "can parse strings" $ do + let input = "dit is een string" + correct = Right $ String input + parseWith string ("\"" ++ input ++ "\"") `shouldBe` correct + + it "can parse integers" $ do + let correct = Right $ Integer 1 + parseWith integer "1" `shouldBe` correct + + it "can parse infinite" $ do + let correct = Right Infinite + parseWith infinite "infinite" `shouldBe` correct + + let wrong = Right Infinite + parseWith infinite "infinitee" `shouldNotBe` wrong + + it "can parse actions" $ do + let input = "leave()" + correct = Right $ Action Leave + parseWith action input `shouldBe` correct + + let input = "retrieveItem(firstId)" + correct = Right $ Action $ RetrieveItem "firstId" + parseWith action input `shouldBe` correct + + let input = "useItem(secondId)" + correct = Right $ Action $ UseItem "secondId" + parseWith action input `shouldBe` correct + + let input = "decreaseHp(entityId,objectId)" + correct = Right $ Action $ DecreaseHp "entityId" "objectId" + parseWith action input `shouldBe` correct + + let input = "increasePlayerHp(objectId)" + correct = Right $ Action $ IncreasePlayerHp "objectId" + parseWith action input `shouldBe` correct + + it "can parse directions" $ do + let input = "up" + correct = Right $ Direction North + parseWith RPGEngine.Parse.StructureElement.direction input `shouldBe` correct + + let input = "right" + correct = Right $ Direction East + parseWith RPGEngine.Parse.StructureElement.direction input `shouldBe` correct + + let input = "down" + correct = Right $ Direction South + parseWith RPGEngine.Parse.StructureElement.direction input `shouldBe` correct + + let input = "left" + correct = Right $ Direction West + parseWith RPGEngine.Parse.StructureElement.direction input `shouldBe` correct + + it "can parse layouts" $ do + let input = "| * * * * * * * *\n| * s . . . . e *\n| * * * * * * * *" + correct = Right $ Layout [ + [Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked], + [Blocked, Entrance, Walkable, Walkable, Walkable, Walkable, Exit, Blocked], + [Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked] + ] + parseWith RPGEngine.Parse.StructureElement.layout input `shouldBe` correct + + describe "Brackets" $ do + it "matches closing <" $ do + let input = '<' + correct = '>' + getMatchingClosingBracket input `shouldBe` correct + + it "matches closing (" $ do + let input = '(' + correct = ')' + getMatchingClosingBracket input `shouldBe` correct + + it "matches closing {" $ do + let input = '{' + correct = '}' + getMatchingClosingBracket input `shouldBe` correct + + it "matches closing [" $ do + let input = '[' + correct = ']' + getMatchingClosingBracket input `shouldBe` correct diff --git a/test/ParserSpec.hs b/test/ParserSpec.hs deleted file mode 100644 index 301b282..0000000 --- a/test/ParserSpec.hs +++ /dev/null @@ -1,132 +0,0 @@ -module ParserSpec where - -import Test.Hspec -import RPGEngine.Internals.Parse -import RPGEngine.Internals.Parse.StructureElement -import RPGEngine.Internals.Data.Internals -import Data.Either - -spec :: Spec -spec = do - describe "Basics of entries" $ do - it "can parse integers" $ do - let correct = Right $ Regular $ Integer 1 - parseWith regular "1" `shouldBe` correct - it "can parse string" $ do - let input = "dit is een string" - correct = Right $ Regular $ String input - parseWith regular ("\"" ++ input ++ "\"") `shouldBe` correct - it "can parse infinite" $ do - let correct = Right $ Regular Infinite - parseWith regular "infinite" `shouldBe` correct - - let wrong = Right $ Regular Infinite - parseWith regular "infinitee" `shouldNotBe` wrong - - it "can parse entries" $ do - let input = "id: \"dagger\"" - correct = Right $ Entry (Tag "id") $ Regular $ String "dagger" - parseWith entry input `shouldBe` correct - - let input = "x: 0" - correct = Right $ Entry (Tag "x") $ Regular $ Integer 0 - parseWith entry input `shouldBe` correct - - let input = "useTimes: infinite" - correct = Right $ Entry (Tag "useTimes") $ Regular Infinite - parseWith entry input `shouldBe` correct - - describe "block: {...}" $ do - it "can parse a block with a single entry" $ do - let input = "{ id: 1}" - correct = Right (Block [ - Entry (Tag "id") $ Regular $ Integer 1 - ], "") - parseWithRest structureElement input `shouldBe` correct - - it "can parse a block with entries" $ do - let input = "{ id: \"key\", x: 3, y: 1}" - correct = Right $ Block [ - Entry (Tag "id") $ Regular $ String "key", - Entry (Tag "x") $ Regular $ Integer 3, - Entry (Tag "y") $ Regular $ Integer 1 - ] - parseWith structureElement input `shouldBe` correct - - describe "Basics" $ do - it "can parse leave()" $ do - let input = "leave()" - correct = Right $ Action Leave - parseWith action input `shouldBe` correct - - it "can parse retrieveItem()" $ do - let input = "retrieveItem(firstId)" - correct = Right $ Action $ RetrieveItem "firstId" - parseWith action input `shouldBe` correct - - it "can parse useItem()" $ do - let input = "useItem(secondId)" - correct = Right $ Action $ UseItem "secondId" - parseWith action input `shouldBe` correct - - it "can parse decreaseHp()" $ do - let input = "decreaseHp(entityId,objectId)" - correct = Right $ Action $ DecreaseHp "entityId" "objectId" - parseWith action input `shouldBe` correct - - it "can parse increasePlayerHp()" $ do - let input = "increasePlayerHp(objectId)" - correct = Right $ Action $ IncreasePlayerHp "objectId" - parseWith action input `shouldBe` correct - - it "can parse inventoryFull()" $ do - let input = "inventoryFull()" - correct = Right (Condition InventoryFull, "") - parseWithRest condition input `shouldBe` correct - - it "can parse inventoryContains()" $ do - let input = "inventoryContains(itemId)" - correct = Right (Condition $ InventoryContains "itemId", "") - parseWithRest condition input `shouldBe` correct - - it "can parse not()" $ do - let input = "not(inventoryFull())" - correct = Right (Condition $ Not InventoryFull, "") - parseWithRest condition input `shouldBe` correct - - let input = "not(inventoryContains(itemId))" - correct = Right (Condition $ Not $ InventoryContains "itemId", "") - parseWithRest condition input `shouldBe` correct - - it "can parse conditionlists" $ do - let input = "[not(inventoryFull())]" - correct = Right (ConditionList [Not InventoryFull], "") - parseWithRest conditionList input `shouldBe` correct - - let input = "[inventoryFull(), inventoryContains(itemId)]" - correct = Right (ConditionList [ - InventoryFull, - InventoryContains "itemId" - ], "") - parseWithRest conditionList input `shouldBe` correct - - let input = "[]" - correct = Right $ ConditionList [] - parseWith conditionList input `shouldBe` correct - - it "can parse actions" $ do - let input = "actions: { [not(inventoryFull())] retrieveItem(key), [] leave()}" - correct = Right (Entry (Tag "actions") $ Block [ - Entry (ConditionList [Not InventoryFull]) $ Regular $ Action $ RetrieveItem "key", - Entry (ConditionList []) $ Regular $ Action Leave - ], "") - parseWithRest structureElement input `shouldBe` correct - - describe "Layouts" $ do - it "can parse layouts" $ do - pending - - describe "Lists and blocks" $ do - it "can parse entities" $ do - pending -