Files
loop/src/Dodge/Room/Treasure.hs
T
2021-11-13 12:31:11 +00:00

56 lines
1.5 KiB
Haskell

{- |
Rooms that contain valuable items, typically protected in some manner.
Typically dead ends.
-}
module Dodge.Room.Treasure
where
import Dodge.Data
import Dodge.Room.Data
import Dodge.Placements
import Dodge.Default.Room
import Dodge.LevelGen.Data
import Geometry
--import Data.List
import Control.Monad.State
--import Control.Lens
--import System.Random
{- | A triangular room with loot at the top (with 'PutID' 2),
creatures in the bottom two corners (with 'PutID' 0),
and (single) entrance bottom middle. -}
triLootRoom
:: Float -- Width
-> Float -- Height
-> State g Room
triLootRoom w h = pure $ defaultRoom
{ _rmPolys = [ tri
, base
]
, _rmLinks = [(V2 0 (-80) , pi)]
, _rmPath = doublePair (V2 0 (-80) , V2 0 (h/2))
, _rmPmnts =
[sPS (V2 (15-w) 15 ) 0 $ PutID 0
,sPS (V2 (w-15) 15 ) pi $ PutID 0
,sPS (V2 0 (h-35)) 0 $ PutID 2
,mntLS vShape (V2 0 (h-20)) (V3 0 (h-80) 70)
,sPS (V2 0 ( -60)) 0 putLamp
]
, _rmBound = [tri , base]
}
where
tri = map toV2
[ ( -w,30)
, ( -w, 0)
, ( w, 0)
, ( w,30)
, ( 20, h)
, (-20, h)
]
base = rectNSWE 20 (-80) (-20) 20
{- | Create a random room with one entrance containing given creatures and items. -}
lootRoom :: [Creature] -> [Item] -> State g Room
lootRoom crs itms = do
let w = 300
h = 700
replacePutID 0 (map PutCrit crs) . replacePutID 2 (map PutFlIt itms) <$> triLootRoom w h