module Game.LambdaHack.Content.CaveKind
( CaveKind(..), validateSingleCaveKind, validateAllCaveKind
) where
import Prelude ()
import Game.LambdaHack.Common.Prelude
import qualified Data.Text as T
import qualified Game.LambdaHack.Common.Dice as Dice
import Game.LambdaHack.Common.Misc
import Game.LambdaHack.Common.Point
import Game.LambdaHack.Common.Random
import Game.LambdaHack.Content.ItemKind (ItemKind)
import Game.LambdaHack.Content.PlaceKind
import Game.LambdaHack.Content.TileKind (TileKind)
data CaveKind = CaveKind
{ csymbol :: Char
, cname :: Text
, cfreq :: Freqs CaveKind
, cxsize :: X
, cysize :: Y
, cgrid :: Dice.DiceXY
, cminPlaceSize :: Dice.DiceXY
, cmaxPlaceSize :: Dice.DiceXY
, cdarkChance :: Dice.Dice
, cnightChance :: Dice.Dice
, cauxConnects :: Rational
, cmaxVoid :: Rational
, cminStairDist :: Int
, cextraStairs :: Dice.Dice
, cdoorChance :: Chance
, copenChance :: Chance
, chidden :: Int
, cactorCoeff :: Int
, cactorFreq :: Freqs ItemKind
, citemNum :: Dice.Dice
, citemFreq :: Freqs ItemKind
, cplaceFreq :: Freqs PlaceKind
, cpassable :: Bool
, cdefTile :: GroupName TileKind
, cdarkCorTile :: GroupName TileKind
, clitCorTile :: GroupName TileKind
, cfillerTile :: GroupName TileKind
, couterFenceTile :: GroupName TileKind
, clegendDarkTile :: GroupName TileKind
, clegendLitTile :: GroupName TileKind
, cescapeGroup :: Maybe (GroupName PlaceKind)
, cstairFreq :: Freqs PlaceKind
}
deriving Show
validateSingleCaveKind :: CaveKind -> [Text]
validateSingleCaveKind CaveKind{..} =
let (minGridX, minGridY) = Dice.minDiceXY cgrid
(maxGridX, maxGridY) = Dice.maxDiceXY cgrid
(minMinSizeX, minMinSizeY) = Dice.minDiceXY cminPlaceSize
(maxMinSizeX, maxMinSizeY) = Dice.maxDiceXY cminPlaceSize
(minMaxSizeX, minMaxSizeY) = Dice.minDiceXY cmaxPlaceSize
xborder = if couterFenceTile /= "basic outer fence" then 2 else 0
yborder = if couterFenceTile /= "basic outer fence" then 2 else 0
in [ "cname longer than 25" | T.length cname > 25 ]
++ [ "cxsize < 7" | cxsize < 7 ]
++ [ "cysize < 7" | cysize < 7 ]
++ [ "minGridX < 1" | minGridX < 1 ]
++ [ "minGridY < 1" | minGridY < 1 ]
++ [ "minMinSizeX < 1" | minMinSizeX < 1 ]
++ [ "minMinSizeY < 1" | minMinSizeY < 1 ]
++ [ "minMaxSizeX < maxMinSizeX" | minMaxSizeX < maxMinSizeX ]
++ [ "minMaxSizeY < maxMinSizeY" | minMaxSizeY < maxMinSizeY ]
++ [ "cxsize too small"
| maxGridX * (maxMinSizeX - 4) + xborder >= cxsize ]
++ [ "cysize too small"
| maxGridY * maxMinSizeY + yborder >= cysize ]
++ [ "cextraStairs < 0" | cextraStairs < 0 ]
++ [ "chidden < 0" | chidden < 0 ]
++ [ "cactorCoeff < 0" | cactorCoeff < 0 ]
++ [ "citemNum < 0" | citemNum < 0 ]
validateAllCaveKind :: [CaveKind] -> [Text]
validateAllCaveKind lk =
if any (maybe False (> 0) . lookup "default random" . cfreq) lk
then []
else ["no cave defined for \"default random\""]