-- This module keeps track of all the things that walk/crawl/fly/slither -- around on a level. The term "monster" is just a traditional catch-all -- term, it includes NPCs, pets, even the player's character. module Monsters ( Monster(..), Monsters, new_monsters, add_monster, move_monster ) where import Data.FiniteMap import Util.Grid import Body import Glyph import Language data Monster = Monster { monster_desc :: NounPhrase, monster_body :: Body, monster_glyph :: Glyph } type Monsters = FiniteMap Position Monster new_monsters :: Monsters new_monsters = emptyFM add_monster :: Monster -> Position -> Monsters -> Monsters add_monster m pos ms = addToFM ms pos m move_monster :: Monsters -> Position -> Position -> Monsters move_monster ms oldp newp = case lookupFM ms oldp of (Just m) -> addToFM (delFromFM ms oldp) newp m Nothing -> ms -- FIXME: warn somehow?