Skip to content

Commit

Permalink
Updates defaultGame syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
chendrix committed Jun 22, 2015
1 parent 10f185d commit 7d1feb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Rogue.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ main =

gameState : Signal Game
gameState =
Signal.foldp update newGame input
Signal.foldp update defaultGame input

input : Signal Input
input =
Expand Down
36 changes: 10 additions & 26 deletions src/Rogue/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,27 @@ defaultCell =
defaultGameMap : Int -> GameMap
defaultGameMap size = Matrix.initialize size (always defaultCell)

generateMap : GameMap -> List (GameMap -> GameMap) -> GameMap
generateMap startingMap mapTransformers =
foldr (<|) startingMap mapTransformers

generateGame : Game -> List (Game -> Game) -> Game
generateGame =
applyTransformations : a -> List (a -> a) -> a
applyTransformations =
foldr (<|)

defaultGame : Game
defaultGame =
let
p = newPlayer
startLoc = (0,0)
size = 10
g = generateMap (defaultGameMap size) []
in
{ gameMap = g
, player = p
, playerLocation = startLoc
}
newGame newPlayer (0,0) 10
[ setBarriers (randomizeLocationsWithin 10 11)
, addItems (randomizeLocationsWithin 10 30)
]

newGame : Game
newGame =
newGame : Player -> Location -> Int -> List (Game -> Game) -> Game
newGame p startLoc size transformations =
let
p = newPlayer
startLoc = (0,0)
size = 10
g = generateMap (defaultGameMap size) []
g = defaultGameMap size
startingGame = { gameMap = g
, player = p
, playerLocation = startLoc
}
in
generateGame startingGame
[ setBarriers (randomizeLocationsWithin size 11)
, addItems (randomizeLocationsWithin size 30)
]
applyTransformations startingGame transformations

updateContents : (Contents -> Contents) -> Cell -> Cell
updateContents f c =
Expand Down

0 comments on commit 7d1feb1

Please sign in to comment.