module Game.LambdaHack.Content.CaveKind
( CaveKind(..), cvalidate
) where
import qualified Data.List as L
import Data.Text (Text)
import qualified Data.Text as T
import Game.LambdaHack.Common.Misc
import Game.LambdaHack.Common.PointXY
import Game.LambdaHack.Common.Random
data CaveKind = CaveKind
{ csymbol :: Char
, cname :: Text
, cfreq :: Freqs
, cxsize :: X
, cysize :: Y
, cgrid :: RollDiceXY
, cminPlaceSize :: RollDiceXY
, cdarkChance :: RollDeep
, cauxConnects :: Rational
, cvoidChance :: Chance
, cnonVoidMin :: Int
, cminStairDist :: Int
, cdoorChance :: Chance
, copenChance :: Chance
, chidden :: Int
, citemNum :: RollDice
, cdefTile :: Text
, ccorridorTile :: Text
, cfillerTile :: Text
, cdarkLegendTile :: Text
, clitLegendTile :: Text
}
deriving Show
cvalidate :: [CaveKind] -> [CaveKind]
cvalidate = L.filter (\ CaveKind{ cgrid = RollDiceXY (gx, gy)
, cminPlaceSize = RollDiceXY (mx, my)
, ..
} ->
let (maxGridX, maxGridY) = (maxDice gx, maxDice gy)
(maxPlaceSizeX, maxPlaceSizeY) = (maxDice mx, maxDice my)
xborder = if maxGridX == 1 then 5 else 3
yborder = if maxGridX == 1 then 5 else 3
in T.length cname <= 25
&& (maxGridX * (xborder + maxPlaceSizeX) + 1 > cxsize ||
maxGridY * (yborder + maxPlaceSizeY) + 1 > cysize))