{-# LANGUAGE DeriveGeneric #-}
module Game.LambdaHack.Content.ModeKind
( ModeKind(..), makeData
, Caves, Roster(..), Outcome(..)
, HiCondPoly, HiSummand, HiPolynomial, HiIndeterminant(..)
, Player(..), LeaderMode(..), AutoLeader(..)
, horrorGroup, genericEndMessages
#ifdef EXPOSE_INTERNAL
, validateSingle, validateAll
, validateSingleRoster, validateSinglePlayer, hardwiredModeGroups
#endif
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Data.Binary
import qualified Data.Text as T
import GHC.Generics (Generic)
import Game.LambdaHack.Content.CaveKind (CaveKind)
import Game.LambdaHack.Content.ItemKind (ItemKind)
import qualified Game.LambdaHack.Core.Dice as Dice
import qualified Game.LambdaHack.Definition.Ability as Ability
import Game.LambdaHack.Definition.ContentData
import Game.LambdaHack.Definition.Defs
data ModeKind = ModeKind
{ ModeKind -> Char
msymbol :: Char
, ModeKind -> Text
mname :: Text
, ModeKind -> Freqs ModeKind
mfreq :: Freqs ModeKind
, ModeKind -> Roster
mroster :: Roster
, ModeKind -> Caves
mcaves :: Caves
, ModeKind -> [(Outcome, Text)]
mendMsg :: [(Outcome, Text)]
, ModeKind -> Text
mdesc :: Text
}
deriving Int -> ModeKind -> ShowS
[ModeKind] -> ShowS
ModeKind -> String
(Int -> ModeKind -> ShowS)
-> (ModeKind -> String) -> ([ModeKind] -> ShowS) -> Show ModeKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModeKind] -> ShowS
$cshowList :: [ModeKind] -> ShowS
show :: ModeKind -> String
$cshow :: ModeKind -> String
showsPrec :: Int -> ModeKind -> ShowS
$cshowsPrec :: Int -> ModeKind -> ShowS
Show
type Caves = [([Int], [GroupName CaveKind])]
data Roster = Roster
{ Roster -> [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList :: [(Player, [(Int, Dice.Dice, GroupName ItemKind)])]
, Roster -> [(Text, Text)]
rosterEnemy :: [(Text, Text)]
, Roster -> [(Text, Text)]
rosterAlly :: [(Text, Text)]
}
deriving Int -> Roster -> ShowS
[Roster] -> ShowS
Roster -> String
(Int -> Roster -> ShowS)
-> (Roster -> String) -> ([Roster] -> ShowS) -> Show Roster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Roster] -> ShowS
$cshowList :: [Roster] -> ShowS
show :: Roster -> String
$cshow :: Roster -> String
showsPrec :: Int -> Roster -> ShowS
$cshowsPrec :: Int -> Roster -> ShowS
Show
data Outcome =
Killed
| Defeated
| Camping
| Conquer
| Escape
| Restart
deriving (Int -> Outcome -> ShowS
[Outcome] -> ShowS
Outcome -> String
(Int -> Outcome -> ShowS)
-> (Outcome -> String) -> ([Outcome] -> ShowS) -> Show Outcome
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Outcome] -> ShowS
$cshowList :: [Outcome] -> ShowS
show :: Outcome -> String
$cshow :: Outcome -> String
showsPrec :: Int -> Outcome -> ShowS
$cshowsPrec :: Int -> Outcome -> ShowS
Show, Outcome -> Outcome -> Bool
(Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Bool) -> Eq Outcome
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Outcome -> Outcome -> Bool
$c/= :: Outcome -> Outcome -> Bool
== :: Outcome -> Outcome -> Bool
$c== :: Outcome -> Outcome -> Bool
Eq, Eq Outcome
Eq Outcome =>
(Outcome -> Outcome -> Ordering)
-> (Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Outcome)
-> (Outcome -> Outcome -> Outcome)
-> Ord Outcome
Outcome -> Outcome -> Bool
Outcome -> Outcome -> Ordering
Outcome -> Outcome -> Outcome
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
min :: Outcome -> Outcome -> Outcome
$cmin :: Outcome -> Outcome -> Outcome
max :: Outcome -> Outcome -> Outcome
$cmax :: Outcome -> Outcome -> Outcome
>= :: Outcome -> Outcome -> Bool
$c>= :: Outcome -> Outcome -> Bool
> :: Outcome -> Outcome -> Bool
$c> :: Outcome -> Outcome -> Bool
<= :: Outcome -> Outcome -> Bool
$c<= :: Outcome -> Outcome -> Bool
< :: Outcome -> Outcome -> Bool
$c< :: Outcome -> Outcome -> Bool
compare :: Outcome -> Outcome -> Ordering
$ccompare :: Outcome -> Outcome -> Ordering
$cp1Ord :: Eq Outcome
Ord, Int -> Outcome
Outcome -> Int
Outcome -> [Outcome]
Outcome -> Outcome
Outcome -> Outcome -> [Outcome]
Outcome -> Outcome -> Outcome -> [Outcome]
(Outcome -> Outcome)
-> (Outcome -> Outcome)
-> (Int -> Outcome)
-> (Outcome -> Int)
-> (Outcome -> [Outcome])
-> (Outcome -> Outcome -> [Outcome])
-> (Outcome -> Outcome -> [Outcome])
-> (Outcome -> Outcome -> Outcome -> [Outcome])
-> Enum Outcome
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Outcome -> Outcome -> Outcome -> [Outcome]
$cenumFromThenTo :: Outcome -> Outcome -> Outcome -> [Outcome]
enumFromTo :: Outcome -> Outcome -> [Outcome]
$cenumFromTo :: Outcome -> Outcome -> [Outcome]
enumFromThen :: Outcome -> Outcome -> [Outcome]
$cenumFromThen :: Outcome -> Outcome -> [Outcome]
enumFrom :: Outcome -> [Outcome]
$cenumFrom :: Outcome -> [Outcome]
fromEnum :: Outcome -> Int
$cfromEnum :: Outcome -> Int
toEnum :: Int -> Outcome
$ctoEnum :: Int -> Outcome
pred :: Outcome -> Outcome
$cpred :: Outcome -> Outcome
succ :: Outcome -> Outcome
$csucc :: Outcome -> Outcome
Enum, Outcome
Outcome -> Outcome -> Bounded Outcome
forall a. a -> a -> Bounded a
maxBound :: Outcome
$cmaxBound :: Outcome
minBound :: Outcome
$cminBound :: Outcome
Bounded, (forall x. Outcome -> Rep Outcome x)
-> (forall x. Rep Outcome x -> Outcome) -> Generic Outcome
forall x. Rep Outcome x -> Outcome
forall x. Outcome -> Rep Outcome x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Outcome x -> Outcome
$cfrom :: forall x. Outcome -> Rep Outcome x
Generic)
instance Binary Outcome
type HiCondPoly = [HiSummand]
type HiSummand = (HiPolynomial, [Outcome])
type HiPolynomial = [(HiIndeterminant, Double)]
data HiIndeterminant =
HiConst
| HiLoot
| HiSprint
| HiBlitz
| HiSurvival
| HiKill
| HiLoss
deriving (Int -> HiIndeterminant -> ShowS
[HiIndeterminant] -> ShowS
HiIndeterminant -> String
(Int -> HiIndeterminant -> ShowS)
-> (HiIndeterminant -> String)
-> ([HiIndeterminant] -> ShowS)
-> Show HiIndeterminant
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HiIndeterminant] -> ShowS
$cshowList :: [HiIndeterminant] -> ShowS
show :: HiIndeterminant -> String
$cshow :: HiIndeterminant -> String
showsPrec :: Int -> HiIndeterminant -> ShowS
$cshowsPrec :: Int -> HiIndeterminant -> ShowS
Show, HiIndeterminant -> HiIndeterminant -> Bool
(HiIndeterminant -> HiIndeterminant -> Bool)
-> (HiIndeterminant -> HiIndeterminant -> Bool)
-> Eq HiIndeterminant
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HiIndeterminant -> HiIndeterminant -> Bool
$c/= :: HiIndeterminant -> HiIndeterminant -> Bool
== :: HiIndeterminant -> HiIndeterminant -> Bool
$c== :: HiIndeterminant -> HiIndeterminant -> Bool
Eq, Eq HiIndeterminant
Eq HiIndeterminant =>
(HiIndeterminant -> HiIndeterminant -> Ordering)
-> (HiIndeterminant -> HiIndeterminant -> Bool)
-> (HiIndeterminant -> HiIndeterminant -> Bool)
-> (HiIndeterminant -> HiIndeterminant -> Bool)
-> (HiIndeterminant -> HiIndeterminant -> Bool)
-> (HiIndeterminant -> HiIndeterminant -> HiIndeterminant)
-> (HiIndeterminant -> HiIndeterminant -> HiIndeterminant)
-> Ord HiIndeterminant
HiIndeterminant -> HiIndeterminant -> Bool
HiIndeterminant -> HiIndeterminant -> Ordering
HiIndeterminant -> HiIndeterminant -> HiIndeterminant
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
min :: HiIndeterminant -> HiIndeterminant -> HiIndeterminant
$cmin :: HiIndeterminant -> HiIndeterminant -> HiIndeterminant
max :: HiIndeterminant -> HiIndeterminant -> HiIndeterminant
$cmax :: HiIndeterminant -> HiIndeterminant -> HiIndeterminant
>= :: HiIndeterminant -> HiIndeterminant -> Bool
$c>= :: HiIndeterminant -> HiIndeterminant -> Bool
> :: HiIndeterminant -> HiIndeterminant -> Bool
$c> :: HiIndeterminant -> HiIndeterminant -> Bool
<= :: HiIndeterminant -> HiIndeterminant -> Bool
$c<= :: HiIndeterminant -> HiIndeterminant -> Bool
< :: HiIndeterminant -> HiIndeterminant -> Bool
$c< :: HiIndeterminant -> HiIndeterminant -> Bool
compare :: HiIndeterminant -> HiIndeterminant -> Ordering
$ccompare :: HiIndeterminant -> HiIndeterminant -> Ordering
$cp1Ord :: Eq HiIndeterminant
Ord, (forall x. HiIndeterminant -> Rep HiIndeterminant x)
-> (forall x. Rep HiIndeterminant x -> HiIndeterminant)
-> Generic HiIndeterminant
forall x. Rep HiIndeterminant x -> HiIndeterminant
forall x. HiIndeterminant -> Rep HiIndeterminant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HiIndeterminant x -> HiIndeterminant
$cfrom :: forall x. HiIndeterminant -> Rep HiIndeterminant x
Generic)
instance Binary HiIndeterminant
data Player = Player
{ Player -> Text
fname :: Text
, Player -> [GroupName ItemKind]
fgroups :: [GroupName ItemKind]
, Player -> Skills
fskillsOther :: Ability.Skills
, Player -> Bool
fcanEscape :: Bool
, Player -> Bool
fneverEmpty :: Bool
, Player -> HiCondPoly
fhiCondPoly :: HiCondPoly
, Player -> Bool
fhasGender :: Bool
, Player -> Tactic
ftactic :: Ability.Tactic
, Player -> LeaderMode
fleaderMode :: LeaderMode
, Player -> Bool
fhasUI :: Bool
}
deriving (Int -> Player -> ShowS
[Player] -> ShowS
Player -> String
(Int -> Player -> ShowS)
-> (Player -> String) -> ([Player] -> ShowS) -> Show Player
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Player] -> ShowS
$cshowList :: [Player] -> ShowS
show :: Player -> String
$cshow :: Player -> String
showsPrec :: Int -> Player -> ShowS
$cshowsPrec :: Int -> Player -> ShowS
Show, Player -> Player -> Bool
(Player -> Player -> Bool)
-> (Player -> Player -> Bool) -> Eq Player
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Player -> Player -> Bool
$c/= :: Player -> Player -> Bool
== :: Player -> Player -> Bool
$c== :: Player -> Player -> Bool
Eq, (forall x. Player -> Rep Player x)
-> (forall x. Rep Player x -> Player) -> Generic Player
forall x. Rep Player x -> Player
forall x. Player -> Rep Player x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Player x -> Player
$cfrom :: forall x. Player -> Rep Player x
Generic)
instance Binary Player
data LeaderMode =
LeaderNull
| LeaderAI AutoLeader
| LeaderUI AutoLeader
deriving (Int -> LeaderMode -> ShowS
[LeaderMode] -> ShowS
LeaderMode -> String
(Int -> LeaderMode -> ShowS)
-> (LeaderMode -> String)
-> ([LeaderMode] -> ShowS)
-> Show LeaderMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LeaderMode] -> ShowS
$cshowList :: [LeaderMode] -> ShowS
show :: LeaderMode -> String
$cshow :: LeaderMode -> String
showsPrec :: Int -> LeaderMode -> ShowS
$cshowsPrec :: Int -> LeaderMode -> ShowS
Show, LeaderMode -> LeaderMode -> Bool
(LeaderMode -> LeaderMode -> Bool)
-> (LeaderMode -> LeaderMode -> Bool) -> Eq LeaderMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LeaderMode -> LeaderMode -> Bool
$c/= :: LeaderMode -> LeaderMode -> Bool
== :: LeaderMode -> LeaderMode -> Bool
$c== :: LeaderMode -> LeaderMode -> Bool
Eq, Eq LeaderMode
Eq LeaderMode =>
(LeaderMode -> LeaderMode -> Ordering)
-> (LeaderMode -> LeaderMode -> Bool)
-> (LeaderMode -> LeaderMode -> Bool)
-> (LeaderMode -> LeaderMode -> Bool)
-> (LeaderMode -> LeaderMode -> Bool)
-> (LeaderMode -> LeaderMode -> LeaderMode)
-> (LeaderMode -> LeaderMode -> LeaderMode)
-> Ord LeaderMode
LeaderMode -> LeaderMode -> Bool
LeaderMode -> LeaderMode -> Ordering
LeaderMode -> LeaderMode -> LeaderMode
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
min :: LeaderMode -> LeaderMode -> LeaderMode
$cmin :: LeaderMode -> LeaderMode -> LeaderMode
max :: LeaderMode -> LeaderMode -> LeaderMode
$cmax :: LeaderMode -> LeaderMode -> LeaderMode
>= :: LeaderMode -> LeaderMode -> Bool
$c>= :: LeaderMode -> LeaderMode -> Bool
> :: LeaderMode -> LeaderMode -> Bool
$c> :: LeaderMode -> LeaderMode -> Bool
<= :: LeaderMode -> LeaderMode -> Bool
$c<= :: LeaderMode -> LeaderMode -> Bool
< :: LeaderMode -> LeaderMode -> Bool
$c< :: LeaderMode -> LeaderMode -> Bool
compare :: LeaderMode -> LeaderMode -> Ordering
$ccompare :: LeaderMode -> LeaderMode -> Ordering
$cp1Ord :: Eq LeaderMode
Ord, (forall x. LeaderMode -> Rep LeaderMode x)
-> (forall x. Rep LeaderMode x -> LeaderMode) -> Generic LeaderMode
forall x. Rep LeaderMode x -> LeaderMode
forall x. LeaderMode -> Rep LeaderMode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LeaderMode x -> LeaderMode
$cfrom :: forall x. LeaderMode -> Rep LeaderMode x
Generic)
instance Binary LeaderMode
data AutoLeader = AutoLeader
{ AutoLeader -> Bool
autoDungeon :: Bool
, AutoLeader -> Bool
autoLevel :: Bool
}
deriving (Int -> AutoLeader -> ShowS
[AutoLeader] -> ShowS
AutoLeader -> String
(Int -> AutoLeader -> ShowS)
-> (AutoLeader -> String)
-> ([AutoLeader] -> ShowS)
-> Show AutoLeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoLeader] -> ShowS
$cshowList :: [AutoLeader] -> ShowS
show :: AutoLeader -> String
$cshow :: AutoLeader -> String
showsPrec :: Int -> AutoLeader -> ShowS
$cshowsPrec :: Int -> AutoLeader -> ShowS
Show, AutoLeader -> AutoLeader -> Bool
(AutoLeader -> AutoLeader -> Bool)
-> (AutoLeader -> AutoLeader -> Bool) -> Eq AutoLeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoLeader -> AutoLeader -> Bool
$c/= :: AutoLeader -> AutoLeader -> Bool
== :: AutoLeader -> AutoLeader -> Bool
$c== :: AutoLeader -> AutoLeader -> Bool
Eq, Eq AutoLeader
Eq AutoLeader =>
(AutoLeader -> AutoLeader -> Ordering)
-> (AutoLeader -> AutoLeader -> Bool)
-> (AutoLeader -> AutoLeader -> Bool)
-> (AutoLeader -> AutoLeader -> Bool)
-> (AutoLeader -> AutoLeader -> Bool)
-> (AutoLeader -> AutoLeader -> AutoLeader)
-> (AutoLeader -> AutoLeader -> AutoLeader)
-> Ord AutoLeader
AutoLeader -> AutoLeader -> Bool
AutoLeader -> AutoLeader -> Ordering
AutoLeader -> AutoLeader -> AutoLeader
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
min :: AutoLeader -> AutoLeader -> AutoLeader
$cmin :: AutoLeader -> AutoLeader -> AutoLeader
max :: AutoLeader -> AutoLeader -> AutoLeader
$cmax :: AutoLeader -> AutoLeader -> AutoLeader
>= :: AutoLeader -> AutoLeader -> Bool
$c>= :: AutoLeader -> AutoLeader -> Bool
> :: AutoLeader -> AutoLeader -> Bool
$c> :: AutoLeader -> AutoLeader -> Bool
<= :: AutoLeader -> AutoLeader -> Bool
$c<= :: AutoLeader -> AutoLeader -> Bool
< :: AutoLeader -> AutoLeader -> Bool
$c< :: AutoLeader -> AutoLeader -> Bool
compare :: AutoLeader -> AutoLeader -> Ordering
$ccompare :: AutoLeader -> AutoLeader -> Ordering
$cp1Ord :: Eq AutoLeader
Ord, (forall x. AutoLeader -> Rep AutoLeader x)
-> (forall x. Rep AutoLeader x -> AutoLeader) -> Generic AutoLeader
forall x. Rep AutoLeader x -> AutoLeader
forall x. AutoLeader -> Rep AutoLeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoLeader x -> AutoLeader
$cfrom :: forall x. AutoLeader -> Rep AutoLeader x
Generic)
instance Binary AutoLeader
horrorGroup :: GroupName ItemKind
horrorGroup :: GroupName ItemKind
horrorGroup = "horror"
genericEndMessages :: [(Outcome, Text)]
genericEndMessages :: [(Outcome, Text)]
genericEndMessages =
[ (Outcome
Killed, "Let's hope a rescue party arrives in time!" )
, (Outcome
Defeated, "Let's hope your new overlords let you live." )
, (Outcome
Camping, "See you soon, stronger and braver!" )
, (Outcome
Conquer, "Can it be done in a better style, though?" )
, (Outcome
Escape, "Can it be done more efficiently, though?" )
, (Outcome
Restart, "This time for real." ) ]
validateSingle :: ModeKind -> [Text]
validateSingle :: ModeKind -> [Text]
validateSingle ModeKind{..} =
[ "mname longer than 20" | Text -> Int
T.length Text
mname Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 20 ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ let f :: ([a], [a]) -> [Text]
f cave :: ([a], [a])
cave@(ns :: [a]
ns, l :: [a]
l) =
[ "not enough or too many levels for required cave groups:"
Text -> Text -> Text
<+> ([a], [a]) -> Text
forall a. Show a => a -> Text
tshow ([a], [a])
cave
| [a] -> Int
forall a. [a] -> Int
length [a]
ns Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= [a] -> Int
forall a. [a] -> Int
length [a]
l ]
in (([Int], [GroupName CaveKind]) -> [Text]) -> Caves -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ([Int], [GroupName CaveKind]) -> [Text]
forall a a. (Show a, Show a) => ([a], [a]) -> [Text]
f Caves
mcaves
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Caves -> Roster -> [Text]
validateSingleRoster Caves
mcaves Roster
mroster
validateSingleRoster :: Caves -> Roster -> [Text]
validateSingleRoster :: Caves -> Roster -> [Text]
validateSingleRoster caves :: Caves
caves Roster{..} =
[ "no player keeps the dungeon alive"
| ((Player, [(Int, Dice, GroupName ItemKind)]) -> Bool)
-> [(Player, [(Int, Dice, GroupName ItemKind)])] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool
not (Bool -> Bool)
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Bool)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Player -> Bool
fneverEmpty (Player -> Bool)
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Player)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Player, [(Int, Dice, GroupName ItemKind)]) -> Player
forall a b. (a, b) -> a
fst) [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ "not exactly one UI client"
| [(Player, [(Int, Dice, GroupName ItemKind)])] -> Int
forall a. [a] -> Int
length (((Player, [(Int, Dice, GroupName ItemKind)]) -> Bool)
-> [(Player, [(Int, Dice, GroupName ItemKind)])]
-> [(Player, [(Int, Dice, GroupName ItemKind)])]
forall a. (a -> Bool) -> [a] -> [a]
filter (Player -> Bool
fhasUI (Player -> Bool)
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Player)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Player, [(Int, Dice, GroupName ItemKind)]) -> Player
forall a b. (a, b) -> a
fst) [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= 1 ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ ((Player, [(Int, Dice, GroupName ItemKind)]) -> [Text])
-> [(Player, [(Int, Dice, GroupName ItemKind)])] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Player -> [Text]
validateSinglePlayer (Player -> [Text])
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Player)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Player, [(Int, Dice, GroupName ItemKind)]) -> Player
forall a b. (a, b) -> a
fst) [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ let checkPl :: Text -> Text -> [Text]
checkPl field :: Text
field pl :: Text
pl =
[ Text
pl Text -> Text -> Text
<+> "is not a player name in" Text -> Text -> Text
<+> Text
field
| ((Player, [(Int, Dice, GroupName ItemKind)]) -> Bool)
-> [(Player, [(Int, Dice, GroupName ItemKind)])] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
pl) (Text -> Bool)
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Text)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Player -> Text
fname (Player -> Text)
-> ((Player, [(Int, Dice, GroupName ItemKind)]) -> Player)
-> (Player, [(Int, Dice, GroupName ItemKind)])
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Player, [(Int, Dice, GroupName ItemKind)]) -> Player
forall a b. (a, b) -> a
fst) [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList ]
checkDipl :: Text -> (Text, Text) -> [Text]
checkDipl field :: Text
field (pl1 :: Text
pl1, pl2 :: Text
pl2) =
[ "self-diplomacy in" Text -> Text -> Text
<+> Text
field | Text
pl1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
pl2 ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Text -> Text -> [Text]
checkPl Text
field Text
pl1
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Text -> Text -> [Text]
checkPl Text
field Text
pl2
in ((Text, Text) -> [Text]) -> [(Text, Text)] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Text -> (Text, Text) -> [Text]
checkDipl "rosterEnemy") [(Text, Text)]
rosterEnemy
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ ((Text, Text) -> [Text]) -> [(Text, Text)] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Text -> (Text, Text) -> [Text]
checkDipl "rosterAlly") [(Text, Text)]
rosterAlly
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ let keys :: [Int]
keys = (([Int], [GroupName CaveKind]) -> [Int]) -> Caves -> [Int]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ([Int], [GroupName CaveKind]) -> [Int]
forall a b. (a, b) -> a
fst Caves
caves
f :: (Player, [(Int, Dice, GroupName ItemKind)]) -> [Text]
f (_, l :: [(Int, Dice, GroupName ItemKind)]
l) = ((Int, Dice, GroupName ItemKind) -> [Text])
-> [(Int, Dice, GroupName ItemKind)] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Int, Dice, GroupName ItemKind) -> [Text]
g [(Int, Dice, GroupName ItemKind)]
l
g :: (Int, Dice, GroupName ItemKind) -> [Text]
g i3 :: (Int, Dice, GroupName ItemKind)
i3@(ln :: Int
ln, _, _) =
[ "initial actor levels not among caves:" Text -> Text -> Text
<+> (Int, Dice, GroupName ItemKind) -> Text
forall a. Show a => a -> Text
tshow (Int, Dice, GroupName ItemKind)
i3
| Int
ln Int -> [Int] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Int]
keys ]
in ((Player, [(Int, Dice, GroupName ItemKind)]) -> [Text])
-> [(Player, [(Int, Dice, GroupName ItemKind)])] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Player, [(Int, Dice, GroupName ItemKind)]) -> [Text]
f [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList
validateSinglePlayer :: Player -> [Text]
validateSinglePlayer :: Player -> [Text]
validateSinglePlayer Player{..} =
[ "fname empty:" Text -> Text -> Text
<+> Text
fname | Text -> Bool
T.null Text
fname ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ "no UI client, but UI leader:" Text -> Text -> Text
<+> Text
fname
| Bool -> Bool
not Bool
fhasUI Bool -> Bool -> Bool
&& case LeaderMode
fleaderMode of
LeaderUI _ -> Bool
True
_ -> Bool
False ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ "fskillsOther not negative:" Text -> Text -> Text
<+> Text
fname
| ((Skill, Int) -> Bool) -> [(Skill, Int)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 0) (Int -> Bool) -> ((Skill, Int) -> Int) -> (Skill, Int) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Skill, Int) -> Int
forall a b. (a, b) -> b
snd) ([(Skill, Int)] -> Bool) -> [(Skill, Int)] -> Bool
forall a b. (a -> b) -> a -> b
$ Skills -> [(Skill, Int)]
Ability.skillsToList Skills
fskillsOther ]
validateAll :: ContentData CaveKind
-> ContentData ItemKind
-> [ModeKind]
-> ContentData ModeKind
-> [Text]
validateAll :: ContentData CaveKind
-> ContentData ItemKind
-> [ModeKind]
-> ContentData ModeKind
-> [Text]
validateAll cocave :: ContentData CaveKind
cocave coitem :: ContentData ItemKind
coitem content :: [ModeKind]
content comode :: ContentData ModeKind
comode =
let caveGroups :: ModeKind -> [GroupName CaveKind]
caveGroups = (([Int], [GroupName CaveKind]) -> [GroupName CaveKind])
-> Caves -> [GroupName CaveKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ([Int], [GroupName CaveKind]) -> [GroupName CaveKind]
forall a b. (a, b) -> b
snd (Caves -> [GroupName CaveKind])
-> (ModeKind -> Caves) -> ModeKind -> [GroupName CaveKind]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModeKind -> Caves
mcaves
missingCave :: [GroupName CaveKind]
missingCave = (GroupName CaveKind -> Bool)
-> [GroupName CaveKind] -> [GroupName CaveKind]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (GroupName CaveKind -> Bool) -> GroupName CaveKind -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContentData CaveKind -> GroupName CaveKind -> Bool
forall a. ContentData a -> GroupName a -> Bool
omemberGroup ContentData CaveKind
cocave)
([GroupName CaveKind] -> [GroupName CaveKind])
-> [GroupName CaveKind] -> [GroupName CaveKind]
forall a b. (a -> b) -> a -> b
$ (ModeKind -> [GroupName CaveKind])
-> [ModeKind] -> [GroupName CaveKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ModeKind -> [GroupName CaveKind]
caveGroups [ModeKind]
content
f :: Roster -> [GroupName ItemKind]
f Roster{[(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList :: [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList :: Roster -> [(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList} =
((Player, [(Int, Dice, GroupName ItemKind)])
-> [GroupName ItemKind])
-> [(Player, [(Int, Dice, GroupName ItemKind)])]
-> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(p :: Player
p, l :: [(Int, Dice, GroupName ItemKind)]
l) -> GroupName ItemKind -> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. Eq a => a -> [a] -> [a]
delete GroupName ItemKind
horrorGroup (Player -> [GroupName ItemKind]
fgroups Player
p)
[GroupName ItemKind]
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. [a] -> [a] -> [a]
++ ((Int, Dice, GroupName ItemKind) -> GroupName ItemKind)
-> [(Int, Dice, GroupName ItemKind)] -> [GroupName ItemKind]
forall a b. (a -> b) -> [a] -> [b]
map (\(_, _, grp :: GroupName ItemKind
grp) -> GroupName ItemKind
grp) [(Int, Dice, GroupName ItemKind)]
l)
[(Player, [(Int, Dice, GroupName ItemKind)])]
rosterList
missingRosterItems :: [GroupName ItemKind]
missingRosterItems = (GroupName ItemKind -> Bool)
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (GroupName ItemKind -> Bool) -> GroupName ItemKind -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContentData ItemKind -> GroupName ItemKind -> Bool
forall a. ContentData a -> GroupName a -> Bool
omemberGroup ContentData ItemKind
coitem)
([GroupName ItemKind] -> [GroupName ItemKind])
-> [GroupName ItemKind] -> [GroupName ItemKind]
forall a b. (a -> b) -> a -> b
$ (ModeKind -> [GroupName ItemKind])
-> [ModeKind] -> [GroupName ItemKind]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Roster -> [GroupName ItemKind]
f (Roster -> [GroupName ItemKind])
-> (ModeKind -> Roster) -> ModeKind -> [GroupName ItemKind]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModeKind -> Roster
mroster) [ModeKind]
content
hardwiredAbsent :: [GroupName ModeKind]
hardwiredAbsent = (GroupName ModeKind -> Bool)
-> [GroupName ModeKind] -> [GroupName ModeKind]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (GroupName ModeKind -> Bool) -> GroupName ModeKind -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContentData ModeKind -> GroupName ModeKind -> Bool
forall a. ContentData a -> GroupName a -> Bool
omemberGroup ContentData ModeKind
comode) [GroupName ModeKind]
hardwiredModeGroups
in [ "cave groups not in content:" Text -> Text -> Text
<+> [GroupName CaveKind] -> Text
forall a. Show a => a -> Text
tshow [GroupName CaveKind]
missingCave
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [GroupName CaveKind] -> Bool
forall a. [a] -> Bool
null [GroupName CaveKind]
missingCave ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ "roster item groups not in content:" Text -> Text -> Text
<+> [GroupName ItemKind] -> Text
forall a. Show a => a -> Text
tshow [GroupName ItemKind]
missingRosterItems
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [GroupName ItemKind] -> Bool
forall a. [a] -> Bool
null [GroupName ItemKind]
missingRosterItems ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [ "Hardwired groups not in content:" Text -> Text -> Text
<+> [GroupName ModeKind] -> Text
forall a. Show a => a -> Text
tshow [GroupName ModeKind]
hardwiredAbsent
| Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [GroupName ModeKind] -> Bool
forall a. [a] -> Bool
null [GroupName ModeKind]
hardwiredAbsent ]
hardwiredModeGroups :: [GroupName ModeKind]
hardwiredModeGroups :: [GroupName ModeKind]
hardwiredModeGroups = ["campaign scenario", "insert coin"]
makeData :: ContentData CaveKind
-> ContentData ItemKind
-> [ModeKind]
-> ContentData ModeKind
makeData :: ContentData CaveKind
-> ContentData ItemKind -> [ModeKind] -> ContentData ModeKind
makeData cocave :: ContentData CaveKind
cocave coitem :: ContentData ItemKind
coitem =
String
-> (ModeKind -> Text)
-> (ModeKind -> Freqs ModeKind)
-> (ModeKind -> [Text])
-> ([ModeKind] -> ContentData ModeKind -> [Text])
-> [ModeKind]
-> ContentData ModeKind
forall c.
Show c =>
String
-> (c -> Text)
-> (c -> Freqs c)
-> (c -> [Text])
-> ([c] -> ContentData c -> [Text])
-> [c]
-> ContentData c
makeContentData "ModeKind" ModeKind -> Text
mname ModeKind -> Freqs ModeKind
mfreq ModeKind -> [Text]
validateSingle
(ContentData CaveKind
-> ContentData ItemKind
-> [ModeKind]
-> ContentData ModeKind
-> [Text]
validateAll ContentData CaveKind
cocave ContentData ItemKind
coitem)