module Game.LambdaHack.Content.ActorKind
( ActorKind(..), avalidate
) where
import Control.Arrow ((&&&))
import qualified Data.List as L
import qualified Data.Ord as Ord
import Data.Text (Text)
import Game.LambdaHack.Common.Ability
import Game.LambdaHack.Common.Color
import Game.LambdaHack.Common.Misc
import qualified Game.LambdaHack.Common.Random as Random
import Game.LambdaHack.Common.Time
data ActorKind = ActorKind
{ asymbol :: !Char
, aname :: !Text
, afreq :: !Freqs
, acolor :: !Color
, aspeed :: !Speed
, ahp :: !Random.RollDice
, asight :: !Bool
, asmell :: !Bool
, aiq :: !Int
, aregen :: !Int
, acanDo :: ![Ability]
}
deriving Show
avalidate :: [ActorKind] -> [ActorKind]
avalidate l =
let cmp = Ord.comparing $ asymbol &&& acolor
eq ka1 ka2 = cmp ka1 ka2 == Ord.EQ
sorted = L.sortBy cmp l
nubbed = L.nubBy eq sorted
in L.deleteFirstsBy eq sorted nubbed