{-# LANGUAGE DeriveGeneric #-}
module Game.LambdaHack.Content.ItemKind
( pattern CONDITION, pattern COMMON_ITEM, pattern S_BONUS_HP, pattern S_BRACED, pattern S_ASLEEP, pattern S_IMPRESSED, pattern S_CURRENCY, pattern MOBILE
, pattern CRAWL_ITEM, pattern TREASURE, pattern ANY_SCROLL, pattern ANY_GLASS, pattern ANY_POTION, pattern ANY_FLASK, pattern EXPLOSIVE, pattern ANY_JEWELRY, pattern S_SINGLE_SPARK, pattern S_SPARK, pattern S_FRAGRANCE
, pattern HORROR, pattern VALUABLE, pattern UNREPORTED_INVENTORY, pattern AQUATIC
, ItemKind(..), makeData
, Aspect(..), Effect(..), Condition(..), DetectKind(..)
, TimerDice, ThrowMod(..)
, ItemSymbolsUsedInEngine(..), emptyItemSymbolsUsedInEngine
, boostItemKindList, forApplyEffect, forDamageEffect, isDamagingKind
, strengthOnCombine, strengthOnSmash, getDropOrgans
, getMandatoryPresentAsFromKind, isEffEscape, isEffEscapeOrAscend
, timeoutAspect, orEffect, onSmashEffect, onCombineEffect, alwaysDudEffect
, damageUsefulness, verbMsgNoLonger, verbMsgLess, toVelocity, toLinger
, timerNone, isTimerNone, foldTimer, toOrganBad, toOrganGood, toOrganNoTimer
, validateSingle
, mandatoryGroups, mandatoryGroupsSingleton
#ifdef EXPOSE_INTERNAL
, boostItemKind, onSmashOrCombineEffect
, validateAll, validateDups, validateDamage
#endif
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Data.Binary
import Data.Hashable (Hashable)
import qualified Data.Text as T
import GHC.Generics (Generic)
import qualified System.Random.SplitMix32 as SM
import qualified Game.LambdaHack.Core.Dice as Dice
import Game.LambdaHack.Core.Random (nextRandom)
import qualified Game.LambdaHack.Definition.Ability as Ability
import Game.LambdaHack.Definition.ContentData
import Game.LambdaHack.Definition.Defs
import Game.LambdaHack.Definition.DefsInternal
import Game.LambdaHack.Definition.Flavour
mandatoryGroupsSingleton :: [GroupName ItemKind]
mandatoryGroupsSingleton :: [GroupName ItemKind]
mandatoryGroupsSingleton =
[GroupName ItemKind
S_BONUS_HP, GroupName ItemKind
S_BRACED, GroupName ItemKind
S_ASLEEP, GroupName ItemKind
S_IMPRESSED, GroupName ItemKind
S_CURRENCY]
pattern S_BONUS_HP, S_BRACED, S_ASLEEP, S_IMPRESSED, S_CURRENCY :: GroupName ItemKind
mandatoryGroups :: [GroupName ItemKind]
mandatoryGroups :: [GroupName ItemKind]
mandatoryGroups =
[GroupName ItemKind
CONDITION, GroupName ItemKind
COMMON_ITEM, GroupName ItemKind
MOBILE]
pattern CONDITION, COMMON_ITEM, MOBILE :: GroupName ItemKind
pattern $mCONDITION :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bCONDITION :: GroupName ItemKind
CONDITION = GroupName "condition"
pattern $mCOMMON_ITEM :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bCOMMON_ITEM :: GroupName ItemKind
COMMON_ITEM = GroupName "common item"
pattern $mS_BONUS_HP :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_BONUS_HP :: GroupName ItemKind
S_BONUS_HP = GroupName "bonus HP"
pattern $mS_BRACED :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_BRACED :: GroupName ItemKind
S_BRACED = GroupName "braced"
pattern $mS_ASLEEP :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_ASLEEP :: GroupName ItemKind
S_ASLEEP = GroupName "asleep"
pattern $mS_IMPRESSED :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_IMPRESSED :: GroupName ItemKind
S_IMPRESSED = GroupName "impressed"
pattern $mS_CURRENCY :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_CURRENCY :: GroupName ItemKind
S_CURRENCY = GroupName "currency"
pattern $mMOBILE :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bMOBILE :: GroupName ItemKind
MOBILE = GroupName "mobile"
pattern S_SINGLE_SPARK, S_SPARK, S_FRAGRANCE, CRAWL_ITEM, TREASURE, ANY_SCROLL, ANY_GLASS, ANY_POTION, ANY_FLASK, EXPLOSIVE, ANY_JEWELRY, VALUABLE, UNREPORTED_INVENTORY, AQUATIC, HORROR :: GroupName ItemKind
pattern $mS_SINGLE_SPARK :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_SINGLE_SPARK :: GroupName ItemKind
S_SINGLE_SPARK = GroupName "single spark"
pattern $mS_SPARK :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_SPARK :: GroupName ItemKind
S_SPARK = GroupName "spark"
pattern $mS_FRAGRANCE :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bS_FRAGRANCE :: GroupName ItemKind
S_FRAGRANCE = GroupName "fragrance"
pattern $mCRAWL_ITEM :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bCRAWL_ITEM :: GroupName ItemKind
CRAWL_ITEM = GroupName "curious item"
pattern $mTREASURE :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bTREASURE :: GroupName ItemKind
TREASURE = GroupName "treasure"
pattern $mANY_SCROLL :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bANY_SCROLL :: GroupName ItemKind
ANY_SCROLL = GroupName "scroll"
pattern $mANY_GLASS :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bANY_GLASS :: GroupName ItemKind
ANY_GLASS = GroupName "glass"
pattern $mANY_POTION :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bANY_POTION :: GroupName ItemKind
ANY_POTION = GroupName "potion"
pattern $mANY_FLASK :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bANY_FLASK :: GroupName ItemKind
ANY_FLASK = GroupName "flask"
pattern $mEXPLOSIVE :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bEXPLOSIVE :: GroupName ItemKind
EXPLOSIVE = GroupName "explosive"
pattern $mANY_JEWELRY :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bANY_JEWELRY :: GroupName ItemKind
ANY_JEWELRY = GroupName "jewelry"
pattern $mVALUABLE :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bVALUABLE :: GroupName ItemKind
VALUABLE = GroupName "valuable"
pattern $mUNREPORTED_INVENTORY :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bUNREPORTED_INVENTORY :: GroupName ItemKind
UNREPORTED_INVENTORY = GroupName "unreported inventory"
pattern $mAQUATIC :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bAQUATIC :: GroupName ItemKind
AQUATIC = GroupName "aquatic"
pattern $mHORROR :: forall {r}. GroupName ItemKind -> ((# #) -> r) -> ((# #) -> r) -> r
$bHORROR :: GroupName ItemKind
HORROR = GroupName "horror"
data ItemKind = ItemKind
{ ItemKind -> Char
isymbol :: ContentSymbol ItemKind
, ItemKind -> Text
iname :: Text
, ItemKind -> Freqs ItemKind
ifreq :: Freqs ItemKind
, ItemKind -> [Flavour]
iflavour :: [Flavour]
, ItemKind -> Dice
icount :: Dice.Dice
, ItemKind -> Rarity
irarity :: Rarity
, ItemKind -> Text
iverbHit :: Text
, ItemKind -> Int
iweight :: Int
, ItemKind -> Dice
idamage :: Dice.Dice
, ItemKind -> [Aspect]
iaspects :: [Aspect]
, ItemKind -> [Effect]
ieffects :: [Effect]
, ItemKind -> [(GroupName ItemKind, CStore)]
ikit :: [(GroupName ItemKind, CStore)]
, ItemKind -> Text
idesc :: Text
}
deriving Int -> ItemKind -> ShowS
[ItemKind] -> ShowS
ItemKind -> String
(Int -> ItemKind -> ShowS)
-> (ItemKind -> String) -> ([ItemKind] -> ShowS) -> Show ItemKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ItemKind -> ShowS
showsPrec :: Int -> ItemKind -> ShowS
$cshow :: ItemKind -> String
show :: ItemKind -> String
$cshowList :: [ItemKind] -> ShowS
showList :: [ItemKind] -> ShowS
Show
data Aspect =
Timeout Dice.Dice
| AddSkill Ability.Skill Dice.Dice
| SetFlag Ability.Flag
| ELabel Text
| ToThrow ThrowMod
| PresentAs (GroupName ItemKind)
| EqpSlot Ability.EqpSlot
| Odds Dice.Dice [Aspect] [Aspect]
deriving (Int -> Aspect -> ShowS
[Aspect] -> ShowS
Aspect -> String
(Int -> Aspect -> ShowS)
-> (Aspect -> String) -> ([Aspect] -> ShowS) -> Show Aspect
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Aspect -> ShowS
showsPrec :: Int -> Aspect -> ShowS
$cshow :: Aspect -> String
show :: Aspect -> String
$cshowList :: [Aspect] -> ShowS
showList :: [Aspect] -> ShowS
Show, Aspect -> Aspect -> Bool
(Aspect -> Aspect -> Bool)
-> (Aspect -> Aspect -> Bool) -> Eq Aspect
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Aspect -> Aspect -> Bool
== :: Aspect -> Aspect -> Bool
$c/= :: Aspect -> Aspect -> Bool
/= :: Aspect -> Aspect -> Bool
Eq)
data Effect =
Burn Dice.Dice
| Explode (GroupName ItemKind)
| RefillHP Int
| RefillCalm Int
| Dominate
| Impress
| PutToSleep
| Yell
| Summon (GroupName ItemKind) Dice.Dice
| Ascend Bool
| Escape
| Paralyze Dice.Dice
| ParalyzeInWater Dice.Dice
| InsertMove Dice.Dice
| Teleport Dice.Dice
| CreateItem (Maybe Int) CStore (GroupName ItemKind) TimerDice
| DestroyItem Int Int CStore (GroupName ItemKind)
| ConsumeItems [(Int, GroupName ItemKind)] [(Int, GroupName ItemKind)]
| DropItem Int Int CStore (GroupName ItemKind)
| Recharge Int Dice.Dice
| Discharge Int Dice.Dice
| PolyItem
| RerollItem
| DupItem
| Identify
| Detect DetectKind Int
| SendFlying ThrowMod
| PushActor ThrowMod
| PullActor ThrowMod
| ApplyPerfume
| AtMostOneOf [Effect]
| OneOf [Effect]
| OnSmash Effect
| OnCombine Effect
| OnUser Effect
| NopEffect
| AndEffect Effect Effect
| OrEffect Effect Effect
| SeqEffect [Effect]
| When Condition Effect
| Unless Condition Effect
| IfThenElse Condition Effect Effect
| VerbNoLonger Text Text
| VerbMsg Text Text
| VerbMsgFail Text Text
deriving (Int -> Effect -> ShowS
[Effect] -> ShowS
Effect -> String
(Int -> Effect -> ShowS)
-> (Effect -> String) -> ([Effect] -> ShowS) -> Show Effect
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Effect -> ShowS
showsPrec :: Int -> Effect -> ShowS
$cshow :: Effect -> String
show :: Effect -> String
$cshowList :: [Effect] -> ShowS
showList :: [Effect] -> ShowS
Show, Effect -> Effect -> Bool
(Effect -> Effect -> Bool)
-> (Effect -> Effect -> Bool) -> Eq Effect
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Effect -> Effect -> Bool
== :: Effect -> Effect -> Bool
$c/= :: Effect -> Effect -> Bool
/= :: Effect -> Effect -> Bool
Eq)
data Condition =
HpLeq Int
| HpGeq Int
| CalmLeq Int
| CalmGeq Int
| TriggeredBy Ability.ActivationFlag
deriving (Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> String
(Int -> Condition -> ShowS)
-> (Condition -> String)
-> ([Condition] -> ShowS)
-> Show Condition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Condition -> ShowS
showsPrec :: Int -> Condition -> ShowS
$cshow :: Condition -> String
show :: Condition -> String
$cshowList :: [Condition] -> ShowS
showList :: [Condition] -> ShowS
Show, Condition -> Condition -> Bool
(Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool) -> Eq Condition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Condition -> Condition -> Bool
== :: Condition -> Condition -> Bool
$c/= :: Condition -> Condition -> Bool
/= :: Condition -> Condition -> Bool
Eq)
data DetectKind =
DetectAll
| DetectActor
| DetectLoot
| DetectExit
| DetectHidden
| DetectEmbed
| DetectStash
deriving (Int -> DetectKind -> ShowS
[DetectKind] -> ShowS
DetectKind -> String
(Int -> DetectKind -> ShowS)
-> (DetectKind -> String)
-> ([DetectKind] -> ShowS)
-> Show DetectKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DetectKind -> ShowS
showsPrec :: Int -> DetectKind -> ShowS
$cshow :: DetectKind -> String
show :: DetectKind -> String
$cshowList :: [DetectKind] -> ShowS
showList :: [DetectKind] -> ShowS
Show, DetectKind -> DetectKind -> Bool
(DetectKind -> DetectKind -> Bool)
-> (DetectKind -> DetectKind -> Bool) -> Eq DetectKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DetectKind -> DetectKind -> Bool
== :: DetectKind -> DetectKind -> Bool
$c/= :: DetectKind -> DetectKind -> Bool
/= :: DetectKind -> DetectKind -> Bool
Eq)
data TimerDice =
TimerNone
| TimerGameTurn Dice.Dice
| TimerActorTurn Dice.Dice
deriving TimerDice -> TimerDice -> Bool
(TimerDice -> TimerDice -> Bool)
-> (TimerDice -> TimerDice -> Bool) -> Eq TimerDice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimerDice -> TimerDice -> Bool
== :: TimerDice -> TimerDice -> Bool
$c/= :: TimerDice -> TimerDice -> Bool
/= :: TimerDice -> TimerDice -> Bool
Eq
instance Show TimerDice where
show :: TimerDice -> String
show TimerDice
TimerNone = String
"0"
show (TimerGameTurn Dice
nDm) =
Dice -> String
forall a. Show a => a -> String
show Dice
nDm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ if Dice
nDm Dice -> Dice -> Bool
forall a. Eq a => a -> a -> Bool
== Dice
1 then String
"turn" else String
"turns"
show (TimerActorTurn Dice
nDm) =
Dice -> String
forall a. Show a => a -> String
show Dice
nDm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ if Dice
nDm Dice -> Dice -> Bool
forall a. Eq a => a -> a -> Bool
== Dice
1 then String
"move" else String
"moves"
data ThrowMod = ThrowMod
{ ThrowMod -> Int
throwVelocity :: Int
, ThrowMod -> Int
throwLinger :: Int
, ThrowMod -> Int
throwHP :: Int
}
deriving (Int -> ThrowMod -> ShowS
[ThrowMod] -> ShowS
ThrowMod -> String
(Int -> ThrowMod -> ShowS)
-> (ThrowMod -> String) -> ([ThrowMod] -> ShowS) -> Show ThrowMod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ThrowMod -> ShowS
showsPrec :: Int -> ThrowMod -> ShowS
$cshow :: ThrowMod -> String
show :: ThrowMod -> String
$cshowList :: [ThrowMod] -> ShowS
showList :: [ThrowMod] -> ShowS
Show, ThrowMod -> ThrowMod -> Bool
(ThrowMod -> ThrowMod -> Bool)
-> (ThrowMod -> ThrowMod -> Bool) -> Eq ThrowMod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ThrowMod -> ThrowMod -> Bool
== :: ThrowMod -> ThrowMod -> Bool
$c/= :: ThrowMod -> ThrowMod -> Bool
/= :: ThrowMod -> ThrowMod -> Bool
Eq, Eq ThrowMod
Eq ThrowMod =>
(ThrowMod -> ThrowMod -> Ordering)
-> (ThrowMod -> ThrowMod -> Bool)
-> (ThrowMod -> ThrowMod -> Bool)
-> (ThrowMod -> ThrowMod -> Bool)
-> (ThrowMod -> ThrowMod -> Bool)
-> (ThrowMod -> ThrowMod -> ThrowMod)
-> (ThrowMod -> ThrowMod -> ThrowMod)
-> Ord ThrowMod
ThrowMod -> ThrowMod -> Bool
ThrowMod -> ThrowMod -> Ordering
ThrowMod -> ThrowMod -> ThrowMod
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ThrowMod -> ThrowMod -> Ordering
compare :: ThrowMod -> ThrowMod -> Ordering
$c< :: ThrowMod -> ThrowMod -> Bool
< :: ThrowMod -> ThrowMod -> Bool
$c<= :: ThrowMod -> ThrowMod -> Bool
<= :: ThrowMod -> ThrowMod -> Bool
$c> :: ThrowMod -> ThrowMod -> Bool
> :: ThrowMod -> ThrowMod -> Bool
$c>= :: ThrowMod -> ThrowMod -> Bool
>= :: ThrowMod -> ThrowMod -> Bool
$cmax :: ThrowMod -> ThrowMod -> ThrowMod
max :: ThrowMod -> ThrowMod -> ThrowMod
$cmin :: ThrowMod -> ThrowMod -> ThrowMod
min :: ThrowMod -> ThrowMod -> ThrowMod
Ord, (forall x. ThrowMod -> Rep ThrowMod x)
-> (forall x. Rep ThrowMod x -> ThrowMod) -> Generic ThrowMod
forall x. Rep ThrowMod x -> ThrowMod
forall x. ThrowMod -> Rep ThrowMod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ThrowMod -> Rep ThrowMod x
from :: forall x. ThrowMod -> Rep ThrowMod x
$cto :: forall x. Rep ThrowMod x -> ThrowMod
to :: forall x. Rep ThrowMod x -> ThrowMod
Generic)
instance Binary ThrowMod
instance Hashable ThrowMod
data ItemSymbolsUsedInEngine = ItemSymbolsUsedInEngine
{ ItemSymbolsUsedInEngine -> Char
rsymbolProjectile :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolLight :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolTool :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolSpecial :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolGold :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolNecklace :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolRing :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolPotion :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolFlask :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolScroll :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolTorsoArmor :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolMiscArmor :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolClothes :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolShield :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolPolearm :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolEdged :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolHafted :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolWand :: ContentSymbol ItemKind
, ItemSymbolsUsedInEngine -> Char
rsymbolFood :: ContentSymbol ItemKind
}
emptyItemSymbolsUsedInEngine :: ItemSymbolsUsedInEngine
emptyItemSymbolsUsedInEngine :: ItemSymbolsUsedInEngine
emptyItemSymbolsUsedInEngine = ItemSymbolsUsedInEngine
{ rsymbolProjectile :: Char
rsymbolProjectile = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolLight :: Char
rsymbolLight = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolTool :: Char
rsymbolTool = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolSpecial :: Char
rsymbolSpecial = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolGold :: Char
rsymbolGold = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolNecklace :: Char
rsymbolNecklace = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolRing :: Char
rsymbolRing = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolPotion :: Char
rsymbolPotion = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolFlask :: Char
rsymbolFlask = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolScroll :: Char
rsymbolScroll = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolTorsoArmor :: Char
rsymbolTorsoArmor = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolMiscArmor :: Char
rsymbolMiscArmor = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolClothes :: Char
rsymbolClothes = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolShield :: Char
rsymbolShield = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolPolearm :: Char
rsymbolPolearm = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolEdged :: Char
rsymbolEdged = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolHafted :: Char
rsymbolHafted = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolWand :: Char
rsymbolWand = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
, rsymbolFood :: Char
rsymbolFood = Char -> Char
forall c. Char -> Char
toContentSymbol Char
'0'
}
boostItemKindList :: SM.SMGen -> [ItemKind] -> [ItemKind]
boostItemKindList :: SMGen -> [ItemKind] -> [ItemKind]
boostItemKindList SMGen
_ [] = []
boostItemKindList SMGen
initialGen [ItemKind]
l =
let (Int
r, SMGen
_) = Int -> SMGen -> (Int, SMGen)
forall a. Integral a => a -> SMGen -> (a, SMGen)
nextRandom ([ItemKind] -> Int
forall a. [a] -> Int
length [ItemKind]
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) SMGen
initialGen
in case Int -> [ItemKind] -> ([ItemKind], [ItemKind])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
r [ItemKind]
l of
([ItemKind]
pre, ItemKind
i : [ItemKind]
post) -> [ItemKind]
pre [ItemKind] -> [ItemKind] -> [ItemKind]
forall a. [a] -> [a] -> [a]
++ ItemKind -> ItemKind
boostItemKind ItemKind
i ItemKind -> [ItemKind] -> [ItemKind]
forall a. a -> [a] -> [a]
: [ItemKind]
post
([ItemKind], [ItemKind])
_ -> String -> [ItemKind]
forall a. HasCallStack => String -> a
error (String -> [ItemKind]) -> String -> [ItemKind]
forall a b. (a -> b) -> a -> b
$ String
"" String -> [ItemKind] -> String
forall v. Show v => String -> v -> String
`showFailure` [ItemKind]
l
boostItemKind :: ItemKind -> ItemKind
boostItemKind :: ItemKind -> ItemKind
boostItemKind ItemKind
i =
let mainlineLabel :: (GroupName ItemKind, b) -> Bool
mainlineLabel (GroupName ItemKind
label, b
_) =
GroupName ItemKind
label GroupName ItemKind -> [GroupName ItemKind] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [GroupName ItemKind
COMMON_ITEM, GroupName ItemKind
CRAWL_ITEM, GroupName ItemKind
TREASURE]
in if ((GroupName ItemKind, Int) -> Bool) -> Freqs ItemKind -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (GroupName ItemKind, Int) -> Bool
forall {b}. (GroupName ItemKind, b) -> Bool
mainlineLabel (ItemKind -> Freqs ItemKind
ifreq ItemKind
i)
then ItemKind
i { ifreq = (COMMON_ITEM, 10000) : filter (not . mainlineLabel)
(ifreq i)
, iaspects = delete (SetFlag Ability.Unique) $ iaspects i
}
else ItemKind
i
forApplyEffect :: Effect -> Bool
forApplyEffect :: Effect -> Bool
forApplyEffect Effect
eff = case Effect
eff of
OnSmash{} -> Bool
False
OnCombine{} -> Bool
False
OnUser Effect
eff1 -> Effect -> Bool
forApplyEffect Effect
eff1
Effect
NopEffect -> Bool
False
AndEffect Effect
eff1 Effect
eff2 -> Effect -> Bool
forApplyEffect Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
forApplyEffect Effect
eff2
OrEffect Effect
eff1 Effect
eff2 -> Effect -> Bool
forApplyEffect Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
forApplyEffect Effect
eff2
SeqEffect [Effect]
effs -> (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
forApplyEffect [Effect]
effs
When Condition
_ Effect
eff1 -> Effect -> Bool
forApplyEffect Effect
eff1
Unless Condition
_ Effect
eff1 -> Effect -> Bool
forApplyEffect Effect
eff1
IfThenElse Condition
_ Effect
eff1 Effect
eff2 -> Effect -> Bool
forApplyEffect Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
forApplyEffect Effect
eff2
VerbNoLonger{} -> Bool
False
VerbMsg{} -> Bool
False
VerbMsgFail{} -> Bool
False
ParalyzeInWater{} -> Bool
False
Effect
_ -> Bool
True
forDamageEffect :: Effect -> Bool
forDamageEffect :: Effect -> Bool
forDamageEffect Effect
eff = case Effect
eff of
Burn{} -> Bool
True
RefillHP Int
n | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 -> Bool
True
Effect
_ -> Bool
False
isDamagingKind :: ItemKind -> Bool
isDamagingKind :: ItemKind -> Bool
isDamagingKind ItemKind
itemKind = Dice -> Int
Dice.infDice (ItemKind -> Dice
idamage ItemKind
itemKind) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0
Bool -> Bool -> Bool
|| (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
forDamageEffect (ItemKind -> [Effect]
ieffects ItemKind
itemKind)
isEffEscape :: Effect -> Bool
isEffEscape :: Effect -> Bool
isEffEscape Escape{} = Bool
True
isEffEscape (AtMostOneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscape [Effect]
l
isEffEscape (OneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscape [Effect]
l
isEffEscape (OnCombine Effect
eff) = Effect -> Bool
isEffEscape Effect
eff
isEffEscape (OnUser Effect
eff) = Effect -> Bool
isEffEscape Effect
eff
isEffEscape (AndEffect Effect
eff1 Effect
eff2) = Effect -> Bool
isEffEscape Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscape Effect
eff2
isEffEscape (OrEffect Effect
eff1 Effect
eff2) = Effect -> Bool
isEffEscape Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscape Effect
eff2
isEffEscape (SeqEffect [Effect]
effs) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscape [Effect]
effs
isEffEscape (When Condition
_ Effect
eff) = Effect -> Bool
isEffEscape Effect
eff
isEffEscape (Unless Condition
_ Effect
eff) = Effect -> Bool
isEffEscape Effect
eff
isEffEscape (IfThenElse Condition
_ Effect
eff1 Effect
eff2) = Effect -> Bool
isEffEscape Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscape Effect
eff2
isEffEscape Effect
_ = Bool
False
isEffEscapeOrAscend :: Effect -> Bool
isEffEscapeOrAscend :: Effect -> Bool
isEffEscapeOrAscend Ascend{} = Bool
True
isEffEscapeOrAscend Escape{} = Bool
True
isEffEscapeOrAscend (AtMostOneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscapeOrAscend [Effect]
l
isEffEscapeOrAscend (OneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscapeOrAscend [Effect]
l
isEffEscapeOrAscend (OnCombine Effect
eff) = Effect -> Bool
isEffEscapeOrAscend Effect
eff
isEffEscapeOrAscend (OnUser Effect
eff) = Effect -> Bool
isEffEscapeOrAscend Effect
eff
isEffEscapeOrAscend (AndEffect Effect
eff1 Effect
eff2) =
Effect -> Bool
isEffEscapeOrAscend Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscapeOrAscend Effect
eff2
isEffEscapeOrAscend (OrEffect Effect
eff1 Effect
eff2) =
Effect -> Bool
isEffEscapeOrAscend Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscapeOrAscend Effect
eff2
isEffEscapeOrAscend (SeqEffect [Effect]
effs) =
(Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
isEffEscapeOrAscend [Effect]
effs
isEffEscapeOrAscend (When Condition
_ Effect
eff) = Effect -> Bool
isEffEscapeOrAscend Effect
eff
isEffEscapeOrAscend (Unless Condition
_ Effect
eff) = Effect -> Bool
isEffEscapeOrAscend Effect
eff
isEffEscapeOrAscend (IfThenElse Condition
_ Effect
eff1 Effect
eff2) =
Effect -> Bool
isEffEscapeOrAscend Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
isEffEscapeOrAscend Effect
eff2
isEffEscapeOrAscend Effect
_ = Bool
False
timeoutAspect :: Aspect -> Bool
timeoutAspect :: Aspect -> Bool
timeoutAspect Timeout{} = Bool
True
timeoutAspect Aspect
_ = Bool
False
orEffect :: Effect -> Bool
orEffect :: Effect -> Bool
orEffect OrEffect{} = Bool
True
orEffect Effect
_ = Bool
False
onSmashEffect :: Effect -> Bool
onSmashEffect :: Effect -> Bool
onSmashEffect OnSmash{} = Bool
True
onSmashEffect Effect
_ = Bool
False
onCombineEffect :: Effect -> Bool
onCombineEffect :: Effect -> Bool
onCombineEffect OnCombine{} = Bool
True
onCombineEffect Effect
_ = Bool
False
onSmashOrCombineEffect :: Effect -> Bool
onSmashOrCombineEffect :: Effect -> Bool
onSmashOrCombineEffect OnSmash{} = Bool
True
onSmashOrCombineEffect OnCombine{} = Bool
True
onSmashOrCombineEffect Effect
_ = Bool
False
alwaysDudEffect :: Effect -> Bool
alwaysDudEffect :: Effect -> Bool
alwaysDudEffect OnSmash{} = Bool
True
alwaysDudEffect OnCombine{} = Bool
True
alwaysDudEffect Effect
NopEffect = Bool
True
alwaysDudEffect Effect
_ = Bool
False
strengthOnSmash :: ItemKind -> [Effect]
strengthOnSmash :: ItemKind -> [Effect]
strengthOnSmash =
let f :: Effect -> [Effect]
f (OnSmash Effect
eff) = [Effect
eff]
f Effect
_ = []
in (Effect -> [Effect]) -> [Effect] -> [Effect]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [Effect]
f ([Effect] -> [Effect])
-> (ItemKind -> [Effect]) -> ItemKind -> [Effect]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ItemKind -> [Effect]
ieffects
strengthOnCombine :: ItemKind -> [Effect]
strengthOnCombine :: ItemKind -> [Effect]
strengthOnCombine =
let f :: Effect -> [Effect]
f (OnCombine Effect
eff) = [Effect
eff]
f Effect
_ = []
in (Effect -> [Effect]) -> [Effect] -> [Effect]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [Effect]
f ([Effect] -> [Effect])
-> (ItemKind -> [Effect]) -> ItemKind -> [Effect]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ItemKind -> [Effect]
ieffects
getDropOrgans :: ItemKind -> [GroupName ItemKind]
getDropOrgans :: ItemKind -> [GroupName ItemKind]
getDropOrgans =
let f :: Effect -> [GroupName ItemKind]
f (DestroyItem Int
_ Int
_ CStore
COrgan GroupName ItemKind
grp) = [GroupName ItemKind
grp]
f (DropItem Int
_ Int
_ CStore
COrgan GroupName ItemKind
grp) = [GroupName ItemKind
grp]
f Effect
Impress = [GroupName ItemKind
S_IMPRESSED]
f (AtMostOneOf [Effect]
l) = (Effect -> [GroupName ItemKind])
-> [Effect] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [GroupName ItemKind]
f [Effect]
l
f (OneOf [Effect]
l) = (Effect -> [GroupName ItemKind])
-> [Effect] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [GroupName ItemKind]
f [Effect]
l
f (OnUser Effect
eff) = Effect -> [GroupName ItemKind]
f Effect
eff
f (AndEffect Effect
eff1 Effect
eff2) = Effect -> [GroupName ItemKind]
f Effect
eff1 [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ Effect -> [GroupName ItemKind]
f Effect
eff2
f (OrEffect Effect
eff1 Effect
eff2) = Effect -> [GroupName ItemKind]
f Effect
eff1 [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ Effect -> [GroupName ItemKind]
f Effect
eff2
f (SeqEffect [Effect]
effs) = (Effect -> [GroupName ItemKind])
-> [Effect] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [GroupName ItemKind]
f [Effect]
effs
f (When Condition
_ Effect
eff) = Effect -> [GroupName ItemKind]
f Effect
eff
f (Unless Condition
_ Effect
eff) = Effect -> [GroupName ItemKind]
f Effect
eff
f (IfThenElse Condition
_ Effect
eff1 Effect
eff2) = Effect -> [GroupName ItemKind]
f Effect
eff1 [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ Effect -> [GroupName ItemKind]
f Effect
eff2
f Effect
_ = []
in (Effect -> [GroupName ItemKind])
-> [Effect] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Effect -> [GroupName ItemKind]
f ([Effect] -> [GroupName ItemKind])
-> (ItemKind -> [Effect]) -> ItemKind -> [GroupName ItemKind]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ItemKind -> [Effect]
ieffects
getMandatoryPresentAsFromKind :: ItemKind -> Maybe (GroupName ItemKind)
getMandatoryPresentAsFromKind :: ItemKind -> Maybe (GroupName ItemKind)
getMandatoryPresentAsFromKind ItemKind
itemKind =
let f :: Aspect -> [GroupName ItemKind]
f (PresentAs GroupName ItemKind
grp) = [GroupName ItemKind
grp]
f Aspect
_ = []
in [GroupName ItemKind] -> Maybe (GroupName ItemKind)
forall a. [a] -> Maybe a
listToMaybe ([GroupName ItemKind] -> Maybe (GroupName ItemKind))
-> [GroupName ItemKind] -> Maybe (GroupName ItemKind)
forall a b. (a -> b) -> a -> b
$ (Aspect -> [GroupName ItemKind])
-> [Aspect] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Aspect -> [GroupName ItemKind]
f (ItemKind -> [Aspect]
iaspects ItemKind
itemKind)
damageUsefulness :: ItemKind -> Double
damageUsefulness :: ItemKind -> Double
damageUsefulness ItemKind
itemKind =
let v :: Double
v = Double -> Double -> Double
forall a. Ord a => a -> a -> a
min Double
1000 (Double
10 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Dice -> Double
Dice.meanDice (ItemKind -> Dice
idamage ItemKind
itemKind))
in Bool -> Double -> Double
forall a. HasCallStack => Bool -> a -> a
assert (Double
v Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0) Double
v
verbMsgNoLonger :: Text -> Effect
verbMsgNoLonger :: Text -> Effect
verbMsgNoLonger Text
name = Text -> Text -> Effect
VerbNoLonger (Text
"be no longer" Text -> Text -> Text
<+> Text
name) Text
"."
verbMsgLess :: Text -> Effect
verbMsgLess :: Text -> Effect
verbMsgLess Text
name = Text -> Text -> Effect
VerbMsg (Text
"appear less" Text -> Text -> Text
<+> Text
name) Text
"."
toVelocity :: Int -> Aspect
toVelocity :: Int -> Aspect
toVelocity Int
n = ThrowMod -> Aspect
ToThrow (ThrowMod -> Aspect) -> ThrowMod -> Aspect
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> ThrowMod
ThrowMod Int
n Int
100 Int
1
toLinger :: Int -> Aspect
toLinger :: Int -> Aspect
toLinger Int
n = ThrowMod -> Aspect
ToThrow (ThrowMod -> Aspect) -> ThrowMod -> Aspect
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> ThrowMod
ThrowMod Int
100 Int
n Int
1
timerNone :: TimerDice
timerNone :: TimerDice
timerNone = TimerDice
TimerNone
isTimerNone :: TimerDice -> Bool
isTimerNone :: TimerDice -> Bool
isTimerNone TimerDice
tim = TimerDice
tim TimerDice -> TimerDice -> Bool
forall a. Eq a => a -> a -> Bool
== TimerDice
TimerNone
foldTimer :: a -> (Dice.Dice -> a) -> (Dice.Dice -> a) -> TimerDice -> a
foldTimer :: forall a. a -> (Dice -> a) -> (Dice -> a) -> TimerDice -> a
foldTimer a
a Dice -> a
fgame Dice -> a
factor TimerDice
tim = case TimerDice
tim of
TimerDice
TimerNone -> a
a
TimerGameTurn Dice
nDm -> Dice -> a
fgame Dice
nDm
TimerActorTurn Dice
nDm -> Dice -> a
factor Dice
nDm
toOrganBad :: GroupName ItemKind -> Dice.Dice -> Effect
toOrganBad :: GroupName ItemKind -> Dice -> Effect
toOrganBad GroupName ItemKind
grp Dice
nDm = Maybe Int -> CStore -> GroupName ItemKind -> TimerDice -> Effect
CreateItem Maybe Int
forall a. Maybe a
Nothing CStore
COrgan GroupName ItemKind
grp (Dice -> TimerDice
TimerGameTurn Dice
nDm)
toOrganGood :: GroupName ItemKind -> Dice.Dice -> Effect
toOrganGood :: GroupName ItemKind -> Dice -> Effect
toOrganGood GroupName ItemKind
grp Dice
nDm = Maybe Int -> CStore -> GroupName ItemKind -> TimerDice -> Effect
CreateItem Maybe Int
forall a. Maybe a
Nothing CStore
COrgan GroupName ItemKind
grp (Dice -> TimerDice
TimerActorTurn Dice
nDm)
toOrganNoTimer :: GroupName ItemKind -> Effect
toOrganNoTimer :: GroupName ItemKind -> Effect
toOrganNoTimer GroupName ItemKind
grp = Maybe Int -> CStore -> GroupName ItemKind -> TimerDice -> Effect
CreateItem Maybe Int
forall a. Maybe a
Nothing CStore
COrgan GroupName ItemKind
grp TimerDice
TimerNone
validateSingle :: ItemSymbolsUsedInEngine -> ItemKind -> [Text]
validateSingle :: ItemSymbolsUsedInEngine -> ItemKind -> [Text]
validateSingle ItemSymbolsUsedInEngine
itemSymbols ik :: ItemKind
ik@ItemKind{Char
Int
Rarity
Freqs ItemKind
[(GroupName ItemKind, CStore)]
[Flavour]
[Effect]
[Aspect]
Text
Dice
isymbol :: ItemKind -> Char
iname :: ItemKind -> Text
ifreq :: ItemKind -> Freqs ItemKind
iflavour :: ItemKind -> [Flavour]
icount :: ItemKind -> Dice
irarity :: ItemKind -> Rarity
iverbHit :: ItemKind -> Text
iweight :: ItemKind -> Int
idamage :: ItemKind -> Dice
iaspects :: ItemKind -> [Aspect]
ieffects :: ItemKind -> [Effect]
ikit :: ItemKind -> [(GroupName ItemKind, CStore)]
idesc :: ItemKind -> Text
isymbol :: Char
iname :: Text
ifreq :: Freqs ItemKind
iflavour :: [Flavour]
icount :: Dice
irarity :: Rarity
iverbHit :: Text
iweight :: Int
idamage :: Dice
iaspects :: [Aspect]
ieffects :: [Effect]
ikit :: [(GroupName ItemKind, CStore)]
idesc :: Text
..} =
[Text
"iname longer than 23" | Text -> Int
T.length Text
iname Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
23]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
"icount < 0" | Dice -> Int
Dice.infDice Dice
icount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Rarity -> [Text]
validateRarity Rarity
irarity
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Dice -> [Text]
validateDamage Dice
idamage
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter Aspect -> Bool
timeoutAspect [Aspect]
iaspects
in [Text
"more than one Timeout specification" | [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1])
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"Conflicting Fragile and Durable"
| Flag -> Aspect
SetFlag Flag
Ability.Fragile Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
Bool -> Bool -> Bool
&& Flag -> Aspect
SetFlag Flag
Ability.Durable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Aspect -> Bool
f :: Aspect -> Bool
f EqpSlot{} = Bool
True
f Aspect
_ = Bool
False
ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter Aspect -> Bool
f [Aspect]
iaspects
equipable :: Bool
equipable = Flag -> Aspect
SetFlag Flag
Ability.Equipable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
meleeable :: Bool
meleeable = Flag -> Aspect
SetFlag Flag
Ability.Meleeable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
likelyTemplate :: Bool
likelyTemplate = case Freqs ItemKind
ifreq of
[(GroupName ItemKind
grp, Int
1)] -> Text
"unknown" Text -> Text -> Bool
`T.isSuffixOf` GroupName ItemKind -> Text
forall c. GroupName c -> Text
fromGroupName GroupName ItemKind
grp
Freqs ItemKind
_ -> Bool
False
likelyException :: Bool
likelyException = Char
isymbol Char -> String -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ ItemSymbolsUsedInEngine -> Char
rsymbolFood ItemSymbolsUsedInEngine
itemSymbols
, ItemSymbolsUsedInEngine -> Char
rsymbolNecklace ItemSymbolsUsedInEngine
itemSymbols
, ItemSymbolsUsedInEngine -> Char
rsymbolWand ItemSymbolsUsedInEngine
itemSymbols ]
Bool -> Bool -> Bool
|| Bool
likelyTemplate
in [ Text
"EqpSlot specified but not Equipable nor Meleeable"
| [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
equipable Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
meleeable ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"EqpSlot not specified but Equipable or Meleeable and not a likely organ or necklace or template"
| Bool -> Bool
not Bool
likelyException
Bool -> Bool -> Bool
&& [Aspect] -> Bool
forall a. [a] -> Bool
null [Aspect]
ts Bool -> Bool -> Bool
&& (Bool
equipable Bool -> Bool -> Bool
|| Bool
meleeable) ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"More than one EqpSlot specified"
| [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1 ] )
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"Redundant Equipable or Meleeable"
| Flag -> Aspect
SetFlag Flag
Ability.Equipable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
Bool -> Bool -> Bool
&& Flag -> Aspect
SetFlag Flag
Ability.Meleeable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"Conflicting Durable and Blast"
| Flag -> Aspect
SetFlag Flag
Ability.Durable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
Bool -> Bool -> Bool
&& Flag -> Aspect
SetFlag Flag
Ability.Blast Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"Conflicting Durable and Condition"
| Flag -> Aspect
SetFlag Flag
Ability.Durable Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
Bool -> Bool -> Bool
&& Flag -> Aspect
SetFlag Flag
Ability.Condition Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ Text
"Conflicting Blast and Condition"
| Flag -> Aspect
SetFlag Flag
Ability.Blast Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects
Bool -> Bool -> Bool
&& Flag -> Aspect
SetFlag Flag
Ability.Condition Aspect -> [Aspect] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Aspect]
iaspects ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Aspect -> Bool
f :: Aspect -> Bool
f ELabel{} = Bool
True
f Aspect
_ = Bool
False
ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter Aspect -> Bool
f [Aspect]
iaspects
in [Text
"more than one ELabel specification" | [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1])
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Aspect -> Bool
f :: Aspect -> Bool
f ToThrow{} = Bool
True
f Aspect
_ = Bool
False
ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter Aspect -> Bool
f [Aspect]
iaspects
in [Text
"more than one ToThrow specification" | [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1])
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Aspect -> Bool
f :: Aspect -> Bool
f PresentAs{} = Bool
True
f Aspect
_ = Bool
False
ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter Aspect -> Bool
f [Aspect]
iaspects
in [Text
"more than one PresentAs specification" | [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1])
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (Flag -> [Text]) -> [Flag] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ItemKind -> Aspect -> [Text]
validateDups ItemKind
ik (Aspect -> [Text]) -> (Flag -> Aspect) -> Flag -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flag -> Aspect
SetFlag) [Flag
forall a. Bounded a => a
minBound .. Flag
forall a. Bounded a => a
maxBound]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Effect -> Bool
f :: Effect -> Bool
f VerbNoLonger{} = Bool
True
f Effect
_ = Bool
False
in [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateOnlyOne [Effect]
ieffects Text
"VerbNoLonger" Effect -> Bool
f)
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Effect -> Bool
f :: Effect -> Bool
f VerbMsg{} = Bool
True
f Effect
_ = Bool
False
in [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateOnlyOne [Effect]
ieffects Text
"VerbMsg" Effect -> Bool
f)
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let f :: Effect -> Bool
f :: Effect -> Bool
f VerbMsgFail{} = Bool
True
f Effect
_ = Bool
False
in [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateOnlyOne [Effect]
ieffects Text
"VerbMsgFail" Effect -> Bool
f)
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateNotNested [Effect]
ieffects Text
"OnSmash or OnCombine" Effect -> Bool
onSmashOrCombineEffect
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ let nonPositiveBurn :: Effect -> Bool
nonPositiveBurn :: Effect -> Bool
nonPositiveBurn (Burn Dice
d) = Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0
nonPositiveBurn Effect
_ = Bool
False
containingNonPositiveBurn :: [Effect]
containingNonPositiveBurn =
(Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Effect -> Bool) -> Effect -> Bool
checkSubEffectProp Effect -> Bool
nonPositiveBurn) [Effect]
ieffects
in [ Text
"effects with non-positive Burn:" Text -> Text -> Text
<+> [Effect] -> Text
forall a. Show a => a -> Text
tshow [Effect]
containingNonPositiveBurn
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [Effect] -> Bool
forall a. [a] -> Bool
null [Effect]
containingNonPositiveBurn ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ let emptyOneOf :: Effect -> Bool
emptyOneOf :: Effect -> Bool
emptyOneOf (AtMostOneOf []) = Bool
True
emptyOneOf (OneOf []) = Bool
True
emptyOneOf Effect
_ = Bool
False
containingEmptyOneOf :: [Effect]
containingEmptyOneOf = (Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Effect -> Bool) -> Effect -> Bool
checkSubEffectProp Effect -> Bool
emptyOneOf) [Effect]
ieffects
in [ Text
"effects with empty AtMostOneOf or OneOf:"
Text -> Text -> Text
<+> [Effect] -> Text
forall a. Show a => a -> Text
tshow [Effect]
containingEmptyOneOf
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [Effect] -> Bool
forall a. [a] -> Bool
null [Effect]
containingEmptyOneOf ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let nonPositiveEffect :: Effect -> Bool
nonPositiveEffect :: Effect -> Bool
nonPositiveEffect (CreateItem (Just Int
n) CStore
_ GroupName ItemKind
_ TimerDice
_) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (DestroyItem Int
n Int
k CStore
_ GroupName ItemKind
_) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 Bool -> Bool -> Bool
|| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (ConsumeItems [(Int, GroupName ItemKind)]
tools [(Int, GroupName ItemKind)]
raw)
| ((Int, GroupName ItemKind) -> Bool)
-> [(Int, GroupName ItemKind)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0) (Int -> Bool)
-> ((Int, GroupName ItemKind) -> Int)
-> (Int, GroupName ItemKind)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, GroupName ItemKind) -> Int
forall a b. (a, b) -> a
fst) ([(Int, GroupName ItemKind)]
tools [(Int, GroupName ItemKind)]
-> [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)]
forall a. [a] -> [a] -> [a]
++ [(Int, GroupName ItemKind)]
raw) = Bool
True
nonPositiveEffect (DropItem Int
n Int
k CStore
_ GroupName ItemKind
_) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 Bool -> Bool -> Bool
|| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (Detect DetectKind
_ Int
n) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect Effect
_ = Bool
False
containingNonPositiveEffect :: [Effect]
containingNonPositiveEffect =
(Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Effect -> Bool) -> Effect -> Bool
checkSubEffectProp Effect -> Bool
nonPositiveEffect) [Effect]
ieffects
in [ Text
"effects with forbidden non-positive parameters:"
Text -> Text -> Text
<+> [Effect] -> Text
forall a. Show a => a -> Text
tshow [Effect]
containingNonPositiveEffect
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [Effect] -> Bool
forall a. [a] -> Bool
null [Effect]
containingNonPositiveEffect ])
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ (let nonPositiveEffect :: Effect -> Bool
nonPositiveEffect :: Effect -> Bool
nonPositiveEffect (Summon GroupName ItemKind
_ Dice
d) | Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (Paralyze Dice
d) | Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (ParalyzeInWater Dice
d) | Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (InsertMove Dice
d) | Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (Teleport Dice
d) | Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (CreateItem Maybe Int
_ CStore
_ GroupName ItemKind
_ (TimerGameTurn Dice
d))
| Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (CreateItem Maybe Int
_ CStore
_ GroupName ItemKind
_ (TimerActorTurn Dice
d))
| Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (Recharge Int
n Dice
d)
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 Bool -> Bool -> Bool
|| Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect (Discharge Int
n Dice
d)
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 Bool -> Bool -> Bool
|| Dice -> Int
Dice.infDice Dice
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Bool
True
nonPositiveEffect Effect
_ = Bool
False
containingNonPositiveEffect :: [Effect]
containingNonPositiveEffect =
(Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Effect -> Bool) -> Effect -> Bool
checkSubEffectProp Effect -> Bool
nonPositiveEffect) [Effect]
ieffects
in [ Text
"effects with forbidden potentially non-positive or negative number or dice:"
Text -> Text -> Text
<+> [Effect] -> Text
forall a. Show a => a -> Text
tshow [Effect]
containingNonPositiveEffect
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [Effect] -> Bool
forall a. [a] -> Bool
null [Effect]
containingNonPositiveEffect ])
validateOnlyOne :: [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateOnlyOne :: [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateOnlyOne [Effect]
effs Text
t Effect -> Bool
f =
let ts :: [Effect]
ts = (Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter Effect -> Bool
f [Effect]
effs
in [Text
"more than one" Text -> Text -> Text
<+> Text
t Text -> Text -> Text
<+> Text
"specification" | [Effect] -> Int
forall a. [a] -> Int
length [Effect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1]
validateNotNested :: [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateNotNested :: [Effect] -> Text -> (Effect -> Bool) -> [Text]
validateNotNested [Effect]
effs Text
t Effect -> Bool
f =
let g :: Effect -> Bool
g (AtMostOneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
l
g (OneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
l
g (OnSmash Effect
effect) = Effect -> Bool
h Effect
effect
g (OnCombine Effect
effect) = Effect -> Bool
h Effect
effect
g (OnUser Effect
effect) = Effect -> Bool
h Effect
effect
g (AndEffect Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g (OrEffect Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g (SeqEffect [Effect]
effs2) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
effs2
g (When Condition
_ Effect
effect) = Effect -> Bool
h Effect
effect
g (Unless Condition
_ Effect
effect) = Effect -> Bool
h Effect
effect
g (IfThenElse Condition
_ Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g Effect
_ = Bool
False
h :: Effect -> Bool
h Effect
effect = Effect -> Bool
f Effect
effect Bool -> Bool -> Bool
|| Effect -> Bool
g Effect
effect
ts :: [Effect]
ts = (Effect -> Bool) -> [Effect] -> [Effect]
forall a. (a -> Bool) -> [a] -> [a]
filter Effect -> Bool
g [Effect]
effs
in [ Text
"effect" Text -> Text -> Text
<+> Text
t Text -> Text -> Text
<+> Text
"should be specified at top level, not nested"
| Bool -> Bool
not ([Effect] -> Bool
forall a. [a] -> Bool
null [Effect]
ts) ]
checkSubEffectProp :: (Effect -> Bool) -> Effect -> Bool
checkSubEffectProp :: (Effect -> Bool) -> Effect -> Bool
checkSubEffectProp Effect -> Bool
f Effect
eff =
let g :: Effect -> Bool
g (AtMostOneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
l
g (OneOf [Effect]
l) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
l
g (OnSmash Effect
effect) = Effect -> Bool
h Effect
effect
g (OnCombine Effect
effect) = Effect -> Bool
h Effect
effect
g (OnUser Effect
effect) = Effect -> Bool
h Effect
effect
g (AndEffect Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g (OrEffect Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g (SeqEffect [Effect]
effs) = (Effect -> Bool) -> [Effect] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Effect -> Bool
h [Effect]
effs
g (When Condition
_ Effect
effect) = Effect -> Bool
h Effect
effect
g (Unless Condition
_ Effect
effect) = Effect -> Bool
h Effect
effect
g (IfThenElse Condition
_ Effect
eff1 Effect
eff2) = Effect -> Bool
h Effect
eff1 Bool -> Bool -> Bool
|| Effect -> Bool
h Effect
eff2
g Effect
_ = Bool
False
h :: Effect -> Bool
h Effect
effect = Effect -> Bool
f Effect
effect Bool -> Bool -> Bool
|| Effect -> Bool
g Effect
effect
in Effect -> Bool
h Effect
eff
validateDups :: ItemKind -> Aspect -> [Text]
validateDups :: ItemKind -> Aspect -> [Text]
validateDups ItemKind{Char
Int
Rarity
Freqs ItemKind
[(GroupName ItemKind, CStore)]
[Flavour]
[Effect]
[Aspect]
Text
Dice
isymbol :: ItemKind -> Char
iname :: ItemKind -> Text
ifreq :: ItemKind -> Freqs ItemKind
iflavour :: ItemKind -> [Flavour]
icount :: ItemKind -> Dice
irarity :: ItemKind -> Rarity
iverbHit :: ItemKind -> Text
iweight :: ItemKind -> Int
idamage :: ItemKind -> Dice
iaspects :: ItemKind -> [Aspect]
ieffects :: ItemKind -> [Effect]
ikit :: ItemKind -> [(GroupName ItemKind, CStore)]
idesc :: ItemKind -> Text
isymbol :: Char
iname :: Text
ifreq :: Freqs ItemKind
iflavour :: [Flavour]
icount :: Dice
irarity :: Rarity
iverbHit :: Text
iweight :: Int
idamage :: Dice
iaspects :: [Aspect]
ieffects :: [Effect]
ikit :: [(GroupName ItemKind, CStore)]
idesc :: Text
..} Aspect
feat =
let ts :: [Aspect]
ts = (Aspect -> Bool) -> [Aspect] -> [Aspect]
forall a. (a -> Bool) -> [a] -> [a]
filter (Aspect -> Aspect -> Bool
forall a. Eq a => a -> a -> Bool
== Aspect
feat) [Aspect]
iaspects
in [Text
"more than one" Text -> Text -> Text
<+> Aspect -> Text
forall a. Show a => a -> Text
tshow Aspect
feat Text -> Text -> Text
<+> Text
"specification" | [Aspect] -> Int
forall a. [a] -> Int
length [Aspect]
ts Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1]
validateDamage :: Dice.Dice -> [Text]
validateDamage :: Dice -> [Text]
validateDamage Dice
dice = [ Text
"potentially negative dice:" Text -> Text -> Text
<+> Dice -> Text
forall a. Show a => a -> Text
tshow Dice
dice
| Dice -> Int
Dice.infDice Dice
dice Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0]
validateAll :: [ItemKind] -> ContentData ItemKind -> [Text]
validateAll :: [ItemKind] -> ContentData ItemKind -> [Text]
validateAll [ItemKind]
content ContentData ItemKind
coitem =
let f :: Aspect -> Bool
f :: Aspect -> Bool
f PresentAs{} = Bool
True
f Aspect
_ = Bool
False
wrongPresentAsGroups :: [GroupName ItemKind]
wrongPresentAsGroups =
[ GroupName ItemKind
cgroup
| ItemKind
k <- [ItemKind]
content
, let (GroupName ItemKind
cgroup, Bool
notSingleton) = case (Aspect -> Bool) -> [Aspect] -> Maybe Aspect
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find Aspect -> Bool
f (ItemKind -> [Aspect]
iaspects ItemKind
k) of
Just (PresentAs GroupName ItemKind
grp) | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ContentData ItemKind -> GroupName ItemKind -> Bool
forall a. ContentData a -> GroupName a -> Bool
oisSingletonGroup ContentData ItemKind
coitem GroupName ItemKind
grp ->
(GroupName ItemKind
grp, Bool
True)
Maybe Aspect
_ -> (GroupName ItemKind
forall a. HasCallStack => a
undefined, Bool
False)
, Bool
notSingleton
]
in [ Text
"PresentAs groups not singletons:" Text -> Text -> Text
<+> [GroupName ItemKind] -> Text
forall a. Show a => a -> Text
tshow [GroupName ItemKind]
wrongPresentAsGroups
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [GroupName ItemKind] -> Bool
forall a. [a] -> Bool
null [GroupName ItemKind]
wrongPresentAsGroups ]
makeData :: ItemSymbolsUsedInEngine
-> [ItemKind] -> [GroupName ItemKind] -> [GroupName ItemKind]
-> ContentData ItemKind
makeData :: ItemSymbolsUsedInEngine
-> [ItemKind]
-> [GroupName ItemKind]
-> [GroupName ItemKind]
-> ContentData ItemKind
makeData ItemSymbolsUsedInEngine
itemSymbols [ItemKind]
content [GroupName ItemKind]
groupNamesSingleton [GroupName ItemKind]
groupNames =
let allGroupNamesTooLong :: [GroupName ItemKind]
allGroupNamesTooLong = (GroupName ItemKind -> Bool)
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
23) (Int -> Bool)
-> (GroupName ItemKind -> Int) -> GroupName ItemKind -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Int
T.length (Text -> Int)
-> (GroupName ItemKind -> Text) -> GroupName ItemKind -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupName ItemKind -> Text
forall c. GroupName c -> Text
fromGroupName)
([GroupName ItemKind] -> [GroupName ItemKind])
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a b. (a -> b) -> a -> b
$ [GroupName ItemKind]
groupNamesSingleton [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ [GroupName ItemKind]
groupNames
in Bool -> ContentData ItemKind -> ContentData ItemKind
forall a. HasCallStack => Bool -> a -> a
assert ([GroupName ItemKind] -> Bool
forall a. [a] -> Bool
null [GroupName ItemKind]
allGroupNamesTooLong
Bool -> (String, [GroupName ItemKind]) -> Bool
forall v. Show v => Bool -> v -> Bool
`blame` String
"ItemKind: some item group names too long"
String -> [GroupName ItemKind] -> (String, [GroupName ItemKind])
forall v. String -> v -> (String, v)
`swith` [GroupName ItemKind]
allGroupNamesTooLong) (ContentData ItemKind -> ContentData ItemKind)
-> ContentData ItemKind -> ContentData ItemKind
forall a b. (a -> b) -> a -> b
$
String
-> (ItemKind -> Text)
-> (ItemKind -> Freqs ItemKind)
-> (ItemKind -> [Text])
-> ([ItemKind] -> ContentData ItemKind -> [Text])
-> [ItemKind]
-> [GroupName ItemKind]
-> [GroupName ItemKind]
-> ContentData ItemKind
forall c.
Show c =>
String
-> (c -> Text)
-> (c -> Freqs c)
-> (c -> [Text])
-> ([c] -> ContentData c -> [Text])
-> [c]
-> [GroupName c]
-> [GroupName c]
-> ContentData c
makeContentData String
"ItemKind" ItemKind -> Text
iname ItemKind -> Freqs ItemKind
ifreq
(ItemSymbolsUsedInEngine -> ItemKind -> [Text]
validateSingle ItemSymbolsUsedInEngine
itemSymbols) [ItemKind] -> ContentData ItemKind -> [Text]
validateAll [ItemKind]
content
([GroupName ItemKind]
mandatoryGroupsSingleton [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ [GroupName ItemKind]
groupNamesSingleton)
([GroupName ItemKind]
mandatoryGroups [GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ [GroupName ItemKind]
groupNames)