Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

switch config file behaviour to case sensitive and rename options

  • Loading branch information...
commit 7f861f6803a76a608aa559e5b78edb989b9afc19 1 parent adc3f4f
@Mikolaj Mikolaj authored
View
25 LambdaHack.config.example
@@ -9,22 +9,23 @@
# paths to various game files; relative to ~/.LambdaHack/
# (or analogous prefixes for other OSes, see getAppUserDataDirectory)
[files]
-savegame: LambdaHack.save
-highscores: LambdaHack.scores
+saveGame: LambdaHack.save
+highScores: LambdaHack.scores
+# configuration of gameplay, more or less unbalancing
[engine]
-fov_mode: shadow
-#fov_mode: digital
-#fov_mode: permissive
-fov_radius: 40
+fovMode: shadow
+#fovMode: digital
+#fovMode: permissive
+fovRadius: 40
[heroes]
-base_hp: 50
-#extra_heroes: 4
+baseHp: 50
+#extraHeroes: 4
[dungeon]
depth: 10
-level3: bigroom
-level10: noiseroom
-level2: rogueroom # the default for most levels
-#level1: noiseroom
+level3: bigRoom
+level10: noiseRoom
+level2: rogueRoom # the default for most levels
+#level1: noiseRoom
View
11 src/Config.hs
@@ -21,9 +21,10 @@ instance B.Binary CP where
instance Show CP where
show (CP config) = show $ to_string config
--- | Underscore in the name to avoid name clash.
-empty_CP :: CP
-empty_CP = CP emptyCP
+-- | Our version of basic parser. Underscore in the name to avoid a name clash.
+-- All names turned case sensitive (insensitive is the default in ConfigFile).
+empty_CP :: ConfigParser
+empty_CP = emptyCP {optionxform = id}
-- | Path to the main configuration file.
file :: IO String
@@ -40,9 +41,9 @@ config =
f <- file
b <- doesFileExist f
if not b
- then return $ empty_CP
+ then return $ CP empty_CP
else do
- c <- readfile emptyCP f
+ c <- readfile empty_CP f
return $ CP (forceEither c)
-- | A simplified access to an option in a given section,
View
18 src/Dungeon.hs
@@ -86,9 +86,9 @@ newTile :: Terrain -> (Tile, Tile)
newTile t = (Tile t [], Tile Unknown [])
-- | Create a level consisting of only one room. Optionally, insert some walls.
-emptyroom :: (Level -> Rnd (LMap -> LMap)) -> LevelConfig ->
+emptyRoom :: (Level -> Rnd (LMap -> LMap)) -> LevelConfig ->
LevelName -> Rnd (Maybe (Maybe DungeonLoc) -> Maybe (Maybe DungeonLoc) -> Level, Loc, Loc)
-emptyroom addWallsRnd cfg@(LevelConfig { levelSize = (sy,sx) }) nm =
+emptyRoom addWallsRnd cfg@(LevelConfig { levelSize = (sy,sx) }) nm =
do
let lmap = digRoom Light ((1,1),(sy-1,sx-1)) (emptyLMap (sy,sx))
let smap = M.fromList [ ((y,x),-100) | y <- [0..sy], x <- [0..sx] ]
@@ -111,15 +111,15 @@ emptyroom addWallsRnd cfg@(LevelConfig { levelSize = (sy,sx) }) nm =
return (level, su, sd)
-- | For a bigroom level: Create a level consisting of only one, empty room.
-bigroom :: LevelConfig ->
+bigRoom :: LevelConfig ->
LevelName -> Rnd (Maybe (Maybe DungeonLoc) -> Maybe (Maybe DungeonLoc) -> Level, Loc, Loc)
-bigroom = emptyroom (\ lvl -> return id)
+bigRoom = emptyRoom (\ lvl -> return id)
-- | For a noiseroom level: Create a level consisting of only one room
-- with randomly distributed pillars.
-noiseroom :: LevelConfig ->
+noiseRoom :: LevelConfig ->
LevelName -> Rnd (Maybe (Maybe DungeonLoc) -> Maybe (Maybe DungeonLoc) -> Level, Loc, Loc)
-noiseroom cfg =
+noiseRoom cfg =
let addWalls lvl = do
rs <- rollPillars cfg lvl
let insertWall lmap l =
@@ -127,7 +127,7 @@ noiseroom cfg =
Tile (Floor _) [] -> M.insert l (newTile (Wall O)) lmap
_ -> lmap
return $ \ lmap -> foldl' insertWall lmap rs
- in emptyroom addWalls cfg
+ in emptyRoom addWalls cfg
data LevelConfig =
LevelConfig {
@@ -185,11 +185,11 @@ largeLevelConfig d =
-- | Create a "normal" dungeon level. Takes a configuration in order
-- to tweak all sorts of data.
-rogueroom :: LevelConfig ->
+rogueRoom :: LevelConfig ->
LevelName ->
Rnd (Maybe (Maybe DungeonLoc) -> Maybe (Maybe DungeonLoc) ->
Level, Loc, Loc)
-rogueroom cfg nm =
+rogueRoom cfg nm =
do
lgrid <- levelGrid cfg
lminroom <- minRoomSize cfg
View
2  src/HighScores.hs
@@ -83,7 +83,7 @@ empty = []
-- | Name of the high scores file.
file :: Config.CP -> IO String
-file config = Config.getFile config "LambdaHack.scores" "files" "highscores"
+file config = Config.getFile config "LambdaHack.scores" "files" "highScores"
-- | We save a simple serialized version of the high scores table.
-- The 'False' is used only as an EOF marker.
View
14 src/LambdaHack.hs
@@ -42,12 +42,12 @@ start session =
generate :: Config.CP -> Session -> String -> IO ()
generate config session msg =
let matchGenerator n Nothing =
- if n == 3 then bigroom else
- if n == 10 then noiseroom else -- access to stairs may be blocked
- rogueroom
- matchGenerator n (Just "bigroom") = bigroom
- matchGenerator n (Just "noiseroom") = noiseroom
- matchGenerator n (Just "rogueroom") = rogueroom
+ if n == 3 then bigRoom else
+ if n == 10 then noiseRoom else -- access to stairs may be blocked
+ rogueRoom
+ matchGenerator n (Just "bigRoom") = bigRoom
+ matchGenerator n (Just "noiseRoom") = noiseRoom
+ matchGenerator n (Just "rogueRoom") = rogueRoom
matchGenerator n (Just s) =
error $ "findGenerator: unknown: " ++ show n ++ ", " ++ s
@@ -80,6 +80,6 @@ generate config session msg =
player = defaultPlayer 0 ploc hp
defState = defaultState player dng lvl
state = defState { sassocs = assocs, sconfig = config }
- k = Config.getDefault 1 config "heroes" "extra_heroes"
+ k = Config.getDefault 1 config "heroes" "extraHeroes"
hstate <- rndToIO $ foldM (addHero hp) state [1..k]
handlerToIO session hstate msg handle
View
4 src/Monster.hs
@@ -17,8 +17,8 @@ defaultBaseHP = 50
-- | Hit points of the player. Experimentally balanced for multiple heroes.
playerHP :: Config.CP -> Int
playerHP config =
- let b = Config.getDefault defaultBaseHP config "heroes" "base_hp"
- k = Config.getDefault 0 config "heroes" "extra_heroes"
+ let b = Config.getDefault defaultBaseHP config "heroes" "baseHp"
+ k = Config.getDefault 0 config "heroes" "extraHeroes"
in b `div` (k + 1)
-- | Time the player can be traced by monsters. TODO: Make configurable.
View
4 src/Perception.hs
@@ -17,8 +17,8 @@ perception_ :: State -> Perception
perception_ state@(State { slevel = Level { lmap = lmap },
sconfig = config,
ssensory = sensory }) =
- let mode = Config.getDefault "shadow" config "engine" "fov_mode"
- radius = Config.getDefault 40 config "engine" "fov_radius"
+ let mode = Config.getDefault "shadow" config "engine" "fovMode"
+ radius = Config.getDefault 40 config "engine" "fovRadius"
fovMode =
-- terrible, temporary hack
case sensory of
View
2  src/Save.hs
@@ -10,7 +10,7 @@ import qualified Config
-- | Name of the save game.
file :: Config.CP -> IO String
-file config = Config.getFile config "LambdaHack.save" "files" "savegame"
+file config = Config.getFile config "LambdaHack.save" "files" "saveGame"
-- | We save a simple serialized version of the current level and
-- the current state. The 'False' is used only as an EOF marker.
View
2  src/State.hs
@@ -45,7 +45,7 @@ defaultState player dng lvl =
S.empty
dng
lvl
- Config.empty_CP
+ (Config.CP Config.empty_CP)
updatePlayer :: (Monster -> Monster) -> State -> State
updatePlayer f s = s { splayer = f (splayer s) }
Please sign in to comment.
Something went wrong with that request. Please try again.