Permalink
Browse files

move Dungeon type to Dungeon.hs

  • Loading branch information...
1 parent 11dea08 commit 83c6b312316fdde68dcd5007962150079c9ecf46 @Mikolaj Mikolaj committed Mar 24, 2011
Showing with 27 additions and 24 deletions.
  1. +25 −0 src/Dungeon.hs
  2. +0 −24 src/Level.hs
  3. +1 −0 src/MovableState.hs
  4. +1 −0 src/State.hs
View
@@ -3,6 +3,7 @@ module Dungeon where
import Prelude hiding (floor)
import Control.Monad
+import Data.Binary
import Data.Map as M
import Data.List as L
import Data.Ratio
@@ -13,6 +14,30 @@ import Level
import Item
import Random
+-- | The complete dungeon is a map from level names to levels.
+-- We usually store all but the current level in this data structure.
+data Dungeon = Dungeon (M.Map LevelName Level)
+ deriving Show
+
+-- | Create a dungeon from a list of levels.
+dungeon :: [Level] -> Dungeon
+dungeon = Dungeon . M.fromList . L.map (\ l -> (lname l, l))
+
+-- | Extract a level from a dungeon.
+getDungeonLevel :: LevelName -> Dungeon -> (Level, Dungeon)
+getDungeonLevel ln (Dungeon dng) = (dng ! ln, Dungeon (M.delete ln dng))
+
+-- | Put a level into a dungeon.
+putDungeonLevel :: Level -> Dungeon -> Dungeon
+putDungeonLevel lvl (Dungeon dng) = Dungeon (M.insert (lname lvl) lvl dng)
+
+sizeDungeon :: Dungeon -> Int
+sizeDungeon (Dungeon dng) = M.size dng
+
+instance Binary Dungeon where
+ put (Dungeon dng) = put (M.elems dng)
+ get = liftM dungeon get
+
type Corridor = [(Y,X)]
type Room = Area
View
@@ -46,30 +46,6 @@ levelName (LambdaCave n) = "The Lambda Cave " ++ show n
levelNumber :: LevelName -> Int
levelNumber (LambdaCave n) = n
--- | The complete dungeon is a map from level names to levels.
--- We usually store all but the current level in this data structure.
-data Dungeon = Dungeon (M.Map LevelName Level)
- deriving Show
-
--- | Create a dungeon from a list of levels.
-dungeon :: [Level] -> Dungeon
-dungeon = Dungeon . M.fromList . L.map (\ l -> (lname l, l))
-
--- | Extract a level from a dungeon.
-getDungeonLevel :: LevelName -> Dungeon -> (Level, Dungeon)
-getDungeonLevel ln (Dungeon dng) = (dng ! ln, Dungeon (M.delete ln dng))
-
--- | Put a level into a dungeon.
-putDungeonLevel :: Level -> Dungeon -> Dungeon
-putDungeonLevel lvl (Dungeon dng) = Dungeon (M.insert (lname lvl) lvl dng)
-
-sizeDungeon :: Dungeon -> Int
-sizeDungeon (Dungeon dng) = M.size dng
-
-instance Binary Dungeon where
- put (Dungeon dng) = put (M.elems dng)
- get = liftM dungeon get
-
-- | A dungeon location is a level together with a location on that level.
type DungeonLoc = (LevelName, Loc)
View
@@ -10,6 +10,7 @@ import Data.Maybe
import Geometry
import Movable
import Level
+import Dungeon
import State
-- The operations with "Any", and those that use them, consider all the dungeon.
View
@@ -9,6 +9,7 @@ import qualified Config
import Movable
import Geometry
import Level
+import Dungeon
import Item
import Message

0 comments on commit 83c6b31

Please sign in to comment.