parent
5cc96cbdba
commit
f3bce99120
18 changed files with 289 additions and 103 deletions
|
@ -6,24 +6,50 @@ import RPGEngine.Data
|
|||
import RPGEngine.Parse.Core
|
||||
import RPGEngine.Parse.TextToStructure
|
||||
import RPGEngine.Parse.StructureToGame
|
||||
import RPGEngine.Parse.TextToStructure (gameFile)
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Game" $ do
|
||||
it "TODO: Simple game" $ do
|
||||
pending
|
||||
it "TODO: More complex game" $ do
|
||||
pending
|
||||
it "TODO: Game with multiple levels" $ do
|
||||
pending
|
||||
-- TODO There is a weird bug that caused this to go in an infinite loop. Fix later.
|
||||
xit "Simple game" $ do
|
||||
let input = "player: {\n hp: 50,\n inventory: []\n}\n\nlevels: [\n {\n layout: {\n | * * * * * *\n | * s . . e *\n | * * * * * *\n },\n \n items: [],\n\n entities: []\n\n\n }\n]"
|
||||
correct = Game {
|
||||
state = Playing {
|
||||
levels = [],
|
||||
count = 0,
|
||||
level = Level {
|
||||
RPGEngine.Data.layout = [],
|
||||
index = [],
|
||||
items = [],
|
||||
entities = []
|
||||
},
|
||||
player = Player {
|
||||
playerHp = Just 50,
|
||||
inventory = [],
|
||||
position = (0, 0),
|
||||
showHp = True,
|
||||
showInventory = False
|
||||
},
|
||||
restart = Menu
|
||||
}
|
||||
}
|
||||
(Right struct) = parseWith gameFile input
|
||||
structureToGame struct `shouldBe` correct
|
||||
it "More complex game" $ do
|
||||
pendingWith "fix parsing first"
|
||||
it "Game with multiple levels" $ do
|
||||
pendingWith "fix parsing first"
|
||||
|
||||
describe "Player" $ do
|
||||
it "cannot die" $ do
|
||||
let input = "player: { hp: infinite, inventory: [] }"
|
||||
correct = Player {
|
||||
playerHp = Prelude.Nothing,
|
||||
inventory = [],
|
||||
position = (0, 0)
|
||||
playerHp = Prelude.Nothing,
|
||||
inventory = [],
|
||||
position = (0, 0),
|
||||
showHp = True,
|
||||
showInventory = False
|
||||
}
|
||||
Right (Entry (Tag "player") struct) = parseWith structure input
|
||||
structureToPlayer struct `shouldBe` correct
|
||||
|
@ -31,9 +57,11 @@ spec = do
|
|||
it "without inventory" $ do
|
||||
let input = "player: { hp: 50, inventory: [] }"
|
||||
correct = Player {
|
||||
playerHp = Just 50,
|
||||
inventory = [],
|
||||
position = (0, 0)
|
||||
playerHp = Just 50,
|
||||
inventory = [],
|
||||
position = (0, 0),
|
||||
showHp = True,
|
||||
showInventory = False
|
||||
}
|
||||
Right (Entry (Tag "player") struct) = parseWith structure input
|
||||
structureToPlayer struct `shouldBe` correct
|
||||
|
@ -54,14 +82,12 @@ spec = do
|
|||
useTimes = Prelude.Nothing
|
||||
}
|
||||
],
|
||||
position = (0, 0)
|
||||
position = (0, 0),
|
||||
showHp = True,
|
||||
showInventory = False
|
||||
}
|
||||
Right (Entry (Tag "player") struct) = parseWith structure input
|
||||
structureToPlayer struct `shouldBe` correct
|
||||
|
||||
describe "Layout" $ do
|
||||
it "simple" $ do
|
||||
pending
|
||||
|
||||
describe "Items" $ do
|
||||
it "simple" $ do
|
||||
|
@ -117,23 +143,40 @@ spec = do
|
|||
structureToActions struct `shouldBe` correct
|
||||
|
||||
describe "Entities" $ do
|
||||
it "TODO: Simple entity" $ do
|
||||
pending
|
||||
it "Simple entity" $ do
|
||||
pendingWith "fix parsing first"
|
||||
|
||||
describe "Level" $ do
|
||||
it "Simple layout" $ do
|
||||
let input = "{ layout: { | * * * * * * \n| * s . . e *\n| * * * * * * }, items: [], entities: [] }"
|
||||
let input = "{ layout: { | * * * * * *\n| * s . . e *\n| * * * * * *\n }, items: [], entities: [] }"
|
||||
correct = Level {
|
||||
RPGEngine.Data.layout = [
|
||||
[Blocked, Blocked, Blocked, Blocked, Blocked, Blocked],
|
||||
[Blocked, Entrance, Walkable, Walkable, Exit, Blocked],
|
||||
[Blocked, Blocked, Blocked, Blocked, Blocked, Blocked]
|
||||
],
|
||||
index = [
|
||||
(0, 0, Blocked),
|
||||
(1, 0, Blocked),
|
||||
(2, 0, Blocked),
|
||||
(3, 0, Blocked),
|
||||
(4, 0, Blocked),
|
||||
(5, 0, Blocked),
|
||||
(0, 1, Blocked),
|
||||
(1, 1, Entrance),
|
||||
(2, 1, Walkable),
|
||||
(3, 1, Walkable),
|
||||
(4, 1, Exit),
|
||||
(5, 1, Blocked),
|
||||
(0, 2, Blocked),
|
||||
(1, 2, Blocked),
|
||||
(2, 2, Blocked),
|
||||
(3, 2, Blocked),
|
||||
(4, 2, Blocked),
|
||||
(5, 2, Blocked)
|
||||
],
|
||||
items = [],
|
||||
entities = []
|
||||
}
|
||||
Right struct = parseWith structure input
|
||||
structureToLevel struct `shouldBe` correct
|
||||
|
||||
it "TODO: Complex layout" $ do
|
||||
pending
|
||||
structureToLevel struct `shouldBe` correct
|
Reference in a new issue