Permalink
Browse files

remove the Hero and Monster types

They are almost never used and not enforced (not newtypes).
  • Loading branch information...
Mikolaj committed Mar 20, 2011
1 parent f436888 commit 54d27e332d12086c438adf8eb3b8bf2d28c0366c
Showing with 5 additions and 10 deletions.
  1. +1 −1 src/Level.hs
  2. +2 −7 src/Monster.hs
  3. +2 −2 src/State.hs
View
@@ -29,7 +29,7 @@ data LevelName = LambdaCave Int | Exit
-- the strength of the character and the strength of the monsters present
-- could further influence the chance, and the chance could also affect
-- which monster is generated.
-monsterGenChance :: LevelName -> [Monster] -> Rnd Bool
+monsterGenChance :: LevelName -> [Movable] -> Rnd Bool
monsterGenChance (LambdaCave n) ms =
chance $ 1%(fromIntegral (250 + 200 * (L.length ms - n)) `max` 50)
monsterGenChance _ _ = return False
View
@@ -19,15 +19,10 @@ heroHP config =
in k + b `div` (k + 1)
-- | Initial hero.
-defaultHero :: Char -> String -> Loc -> Int -> Hero
+defaultHero :: Char -> String -> Loc -> Int -> Movable
defaultHero symbol name ploc hp =
Movable (Hero symbol name) hp hp Nothing TCursor ploc [] 'a' 10 0
--- The types should be equal, becase monsters can be sometimes
--- player-controlled and heroes can be alien-controlled or panicked, etc.
-type Hero = Movable
-type Monster = Movable
-
data Movable = Movable
{ mtype :: !MovableType,
mhpmax :: !Int,
@@ -120,7 +115,7 @@ monsterFrequency =
]
-- | Generate monster.
-newMonster :: Loc -> Frequency MovableType -> Rnd Monster
+newMonster :: Loc -> Frequency MovableType -> Rnd Movable
newMonster loc ftp =
do
tp <- frequency ftp
View
@@ -121,10 +121,10 @@ insertActor a m =
AHero n -> updateLevel (updateHeroes (IM.insert n m))
AMonster n -> updateLevel (updateMonsters (IM.insert n m))
-levelHeroList :: State -> [Hero]
+levelHeroList :: State -> [Movable]
levelHeroList (State { slevel = Level { lheroes = hs } }) = IM.elems hs
-levelMonsterList :: State -> [Monster]
+levelMonsterList :: State -> [Movable]
levelMonsterList (State { slevel = Level { lmonsters = ms } }) = IM.elems ms
updateCursor :: (Cursor -> Cursor) -> State -> State

0 comments on commit 54d27e3

Please sign in to comment.