Skip to content

Commit

Permalink
remove the Hero and Monster types
Browse files Browse the repository at this point in the history
They are almost never used and not enforced (not newtypes).
  • Loading branch information
Mikolaj committed Mar 20, 2011
1 parent f436888 commit 54d27e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Level.hs
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/Monster.hs
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/State.hs
Expand Up @@ -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
Expand Down

0 comments on commit 54d27e3

Please sign in to comment.