module Game.LambdaHack.Content.CaveKind
( CaveKind(..), validateSingleCaveKind, validateAllCaveKind
) where
import Data.Text (Text)
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
data CaveKind = CaveKind
{ csymbol :: !Char
, cname :: !Text
, cfreq :: !Freqs
, 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
, cdoorChance :: !Chance
, copenChance :: !Chance
, chidden :: !Int
, cactorCoeff :: !Int
, cactorFreq :: !Freqs
, citemNum :: !Dice.Dice
, citemFreq :: !Freqs
, cplaceFreq :: !Freqs
, cpassable :: !Bool
, cdefTile :: !GroupName
, cdarkCorTile :: !GroupName
, clitCorTile :: !GroupName
, cfillerTile :: !GroupName
, couterFenceTile :: !GroupName
, clegendDarkTile :: !GroupName
, clegendLitTile :: !GroupName
}
deriving Show
validateSingleCaveKind :: CaveKind -> [Text]
validateSingleCaveKind CaveKind{..} =
let (maxGridX, maxGridY) = Dice.maxDiceXY cgrid
(minMinSizeX, minMinSizeY) = Dice.minDiceXY cminPlaceSize
(maxMinSizeX, maxMinSizeY) = Dice.maxDiceXY cminPlaceSize
(minMaxSizeX, minMaxSizeY) = Dice.minDiceXY cmaxPlaceSize
xborder = if maxGridX == 1 || couterFenceTile /= "basic outer fence"
then 2
else 0
yborder = if maxGridY == 1 || 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 ]
++ [ "minMinSizeX < 1" | minMinSizeX < 1 ]
++ [ "minMinSizeY < 1" | minMinSizeY < 1 ]
++ [ "minMaxSizeX < maxMinSizeX" | minMaxSizeX < maxMinSizeX ]
++ [ "minMaxSizeY < maxMinSizeY" | minMaxSizeY < maxMinSizeY ]
++ [ "cxsize too small"
| maxGridX * (maxMinSizeX + 1) + xborder >= cxsize ]
++ [ "cysize too small"
| maxGridY * (maxMinSizeY + 1) + yborder >= cysize ]
validateAllCaveKind :: [CaveKind] -> [Text]
validateAllCaveKind lk =
if any (\k -> maybe False (> 0) $ lookup "campaign random" $ cfreq k) lk
then []
else ["no cave defined for \"campaign random\""]