LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Common.Faction

Contents

- Internal operations

Description

Factions taking part in the game, e.g., a hero faction, a monster faction and an animal faction.

Synopsis

- type FactionDict = EnumMap FactionId Faction
- data Faction = Faction {
  - gkind :: FactionKind
  - gname :: Text
  - gcolor :: Color
  - gdoctrine :: Doctrine
  - gunderAI :: Bool
  - ginitial :: [(Int, Int, GroupName ItemKind)]
  - gdipl :: Dipl
  - gquit :: Maybe Status
  - _gleader :: Maybe ActorId
  - gstash :: Maybe (LevelId, Point)
  - gvictims :: EnumMap (ContentId ItemKind) Int
  }
- data Diplomacy
  - = Unknown
  - | Neutral
  - | Alliance
  - | War
- data Status = Status {
  - stOutcome :: Outcome
  - stDepth :: Int
  - stNewGame :: Maybe (GroupName ModeKind)
  }
- data Challenge = Challenge {
  - cdiff :: Int
  - cfish :: Bool
  - cgoods :: Bool
  - cwolf :: Bool
  - ckeeper :: Bool
  }
- tshowDiplomacy :: Diplomacy -> Text
- tshowChallenge :: Challenge -> Text
- gleader :: Faction -> Maybe ActorId
- isHorrorFact :: Faction -> Bool
- noRunWithMulti :: Faction -> Bool
- bannedPointmanSwitchBetweenLevels :: Faction -> Bool
- isFoe :: FactionId -> Faction -> FactionId -> Bool
- isFriend :: FactionId -> Faction -> FactionId -> Bool
- difficultyBound :: Int
- difficultyDefault :: Int
- difficultyCoeff :: Int -> Int
- defaultChallenge :: Challenge
- possibleActorFactions :: [GroupName ItemKind] -> ItemKind -> FactionDict -> Frequency (FactionId, Faction)
- ppContainer :: FactionDict -> Container -> Text
- type Dipl = EnumMap FactionId Diplomacy

# Documentation

type FactionDict = EnumMap FactionId Faction Source #

All factions in the game, indexed by faction identifier.

data Faction Source #

The faction datatype.

Constructors

Faction |

Fields

- gkind :: FactionKind

  the player spec for this faction, do not update! it is morally read-only, but not represented as `ContentId FactionKind`, because it's very small and it's looked up often enough in the code and during runtime; a side-effect is that if content changes mid-game, this stays; if we ever have thousands of factions in a single game, e.g., one for each separately spawned herd of animals, change this

- gname :: Text

  individual name

- gcolor :: Color

  color of numbered actors

- gdoctrine :: Doctrine

  non-pointmen behave according to this

- gunderAI :: Bool

  whether the faction is under AI control

- ginitial :: [(Int, Int, GroupName ItemKind)]

  initial actors

- gdipl :: Dipl

  diplomatic standing

- gquit :: Maybe Status

  cause of game end/exit

- _gleader :: Maybe ActorId

  the leader of the faction; don't use in place of sleader on clients

- gstash :: Maybe (LevelId, Point)

  level and position of faction's shared inventory stash

- gvictims :: EnumMap (ContentId ItemKind) Int

  members killed

#### Instances

Instances details

Binary Faction Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods put :: Faction -> Put Source # get :: Get Faction Source # putList :: [Faction] -> Put Source #
Generic Faction Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Associated Types

type Rep Faction |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Faction = D1 ('MetaData "Faction" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Faction" 'PrefixI 'True) (((S1 ('MetaSel ('Just "gkind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionKind) :*: S1 ('MetaSel ('Just "gname") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "gcolor") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Color) :*: (S1 ('MetaSel ('Just "gdoctrine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Doctrine) :*: S1 ('MetaSel ('Just "gunderAI") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "ginitial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Int, Int, GroupName ItemKind)]) :*: (S1 ('MetaSel ('Just "gdipl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Dipl) :*: S1 ('MetaSel ('Just "gquit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Status)))) :*: (S1 ('MetaSel ('Just "_gleader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ActorId)) :*: (S1 ('MetaSel ('Just "gstash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (LevelId, Point))) :*: S1 ('MetaSel ('Just "gvictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int)))))))

Methods

from :: Faction -> Rep Faction x Source #

to :: Rep Faction x -> Faction Source #

Show Faction Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods showsPrec :: Int -> Faction -> ShowS Source # show :: Faction -> String Source # showList :: [Faction] -> ShowS Source #
Eq Faction Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods (==) :: Faction -> Faction -> Bool Source # (/=) :: Faction -> Faction -> Bool Source #
type Rep Faction Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Faction = D1 ('MetaData "Faction" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Faction" 'PrefixI 'True) (((S1 ('MetaSel ('Just "gkind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionKind) :*: S1 ('MetaSel ('Just "gname") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "gcolor") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Color) :*: (S1 ('MetaSel ('Just "gdoctrine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Doctrine) :*: S1 ('MetaSel ('Just "gunderAI") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "ginitial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Int, Int, GroupName ItemKind)]) :*: (S1 ('MetaSel ('Just "gdipl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Dipl) :*: S1 ('MetaSel ('Just "gquit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Status)))) :*: (S1 ('MetaSel ('Just "_gleader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ActorId)) :*: (S1 ('MetaSel ('Just "gstash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (LevelId, Point))) :*: S1 ('MetaSel ('Just "gvictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int)))))))

data Diplomacy Source #

Diplomacy states. Higher overwrite lower in case of asymmetric content.

Constructors

Unknown |
Neutral |
Alliance |
War |

#### Instances

Instances details

Binary Diplomacy Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods put :: Diplomacy -> Put Source # get :: Get Diplomacy Source # putList :: [Diplomacy] -> Put Source #
Enum Diplomacy Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Methods

succ :: Diplomacy -> Diplomacy Source #

pred :: Diplomacy -> Diplomacy Source #

toEnum :: Int -> Diplomacy Source #

fromEnum :: Diplomacy -> Int Source #

enumFrom :: Diplomacy -> [Diplomacy] Source #

enumFromThen :: Diplomacy -> Diplomacy -> [Diplomacy] Source #

enumFromTo :: Diplomacy -> Diplomacy -> [Diplomacy] Source #

enumFromThenTo :: Diplomacy -> Diplomacy -> Diplomacy -> [Diplomacy] Source #

Generic Diplomacy Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Associated Types

type Rep Diplomacy |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Diplomacy = D1 ('MetaData "Diplomacy" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "Unknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Neutral" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Alliance" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "War" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Diplomacy -> Rep Diplomacy x Source #

to :: Rep Diplomacy x -> Diplomacy Source #

Show Diplomacy Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods showsPrec :: Int -> Diplomacy -> ShowS Source # show :: Diplomacy -> String Source # showList :: [Diplomacy] -> ShowS Source #
Eq Diplomacy Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods (==) :: Diplomacy -> Diplomacy -> Bool Source # (/=) :: Diplomacy -> Diplomacy -> Bool Source #
Ord Diplomacy Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Methods

compare :: Diplomacy -> Diplomacy -> Ordering Source #

(<) :: Diplomacy -> Diplomacy -> Bool Source #

(<=) :: Diplomacy -> Diplomacy -> Bool Source #

(>) :: Diplomacy -> Diplomacy -> Bool Source #

(>=) :: Diplomacy -> Diplomacy -> Bool Source #

max :: Diplomacy -> Diplomacy -> Diplomacy Source #

min :: Diplomacy -> Diplomacy -> Diplomacy Source #

type Rep Diplomacy Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Diplomacy = D1 ('MetaData "Diplomacy" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "Unknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Neutral" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Alliance" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "War" 'PrefixI 'False) (U1 :: Type -> Type)))

data Status Source #

Current game status.

Constructors

Status |

Fields

- stOutcome :: Outcome

  current game outcome

- stDepth :: Int

  depth of the final encounter

- stNewGame :: Maybe (GroupName ModeKind)

  new game group to start, if any

#### Instances

Instances details

Binary Status Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods put :: Status -> Put Source # get :: Get Status Source # putList :: [Status] -> Put Source #
Generic Status Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Associated Types

type Rep Status |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Status = D1 ('MetaData "Status" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Status" 'PrefixI 'True) (S1 ('MetaSel ('Just "stOutcome") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Outcome) :*: (S1 ('MetaSel ('Just "stDepth") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "stNewGame") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (GroupName ModeKind))))))

Methods

from :: Status -> Rep Status x Source #

to :: Rep Status x -> Status Source #

Show Status Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods showsPrec :: Int -> Status -> ShowS Source # show :: Status -> String Source # showList :: [Status] -> ShowS Source #
Eq Status Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods (==) :: Status -> Status -> Bool Source # (/=) :: Status -> Status -> Bool Source #
Ord Status Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods compare :: Status -> Status -> Ordering Source # (<) :: Status -> Status -> Bool Source # (<=) :: Status -> Status -> Bool Source # (>) :: Status -> Status -> Bool Source # (>=) :: Status -> Status -> Bool Source # max :: Status -> Status -> Status Source # min :: Status -> Status -> Status Source #
type Rep Status Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Status = D1 ('MetaData "Status" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Status" 'PrefixI 'True) (S1 ('MetaSel ('Just "stOutcome") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Outcome) :*: (S1 ('MetaSel ('Just "stDepth") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "stNewGame") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (GroupName ModeKind))))))

data Challenge Source #

The difficulty level influencess HP of either the human player or the AI. The challenges restrict some abilities of the human player only.

Constructors

Challenge |

Fields

- cdiff :: Int

  game difficulty level (HP bonus or malus)

- cfish :: Bool

  cold fish challenge (no healing from enemies)

- cgoods :: Bool

  ready goods challenge (crafting disabled)

- cwolf :: Bool

  lone wolf challenge (only one starting character)

- ckeeper :: Bool

  finder keeper challenge (ranged attacks disabled)

#### Instances

Instances details

Binary Challenge Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods put :: Challenge -> Put Source # get :: Get Challenge Source # putList :: [Challenge] -> Put Source #
Generic Challenge Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Associated Types

type Rep Challenge |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Challenge = D1 ('MetaData "Challenge" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Challenge" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cdiff") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "cfish") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "cgoods") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cwolf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "ckeeper") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))))

Methods

from :: Challenge -> Rep Challenge x Source #

to :: Rep Challenge x -> Challenge Source #

Show Challenge Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods showsPrec :: Int -> Challenge -> ShowS Source # show :: Challenge -> String Source # showList :: [Challenge] -> ShowS Source #
Eq Challenge Source # |
Instance details Defined in Game.LambdaHack.Common.Faction Methods (==) :: Challenge -> Challenge -> Bool Source # (/=) :: Challenge -> Challenge -> Bool Source #
Ord Challenge Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

Methods

compare :: Challenge -> Challenge -> Ordering Source #

(<) :: Challenge -> Challenge -> Bool Source #

(<=) :: Challenge -> Challenge -> Bool Source #

(>) :: Challenge -> Challenge -> Bool Source #

(>=) :: Challenge -> Challenge -> Bool Source #

max :: Challenge -> Challenge -> Challenge Source #

min :: Challenge -> Challenge -> Challenge Source #

type Rep Challenge Source # |

Instance details

Defined in Game.LambdaHack.Common.Faction

type Rep Challenge = D1 ('MetaData "Challenge" "Game.LambdaHack.Common.Faction" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Challenge" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cdiff") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "cfish") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "cgoods") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cwolf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "ckeeper") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))))

tshowDiplomacy :: Diplomacy -> Text Source #

tshowChallenge :: Challenge -> Text Source #

gleader :: Faction -> Maybe ActorId Source #

isHorrorFact :: Faction -> Bool Source #

Tell whether the faction consists of summoned horrors only.

Horror player is special, for summoned actors that don't belong to any of the main players of a given game. E.g., animals summoned during a skirmish game between two hero factions land in the horror faction. In every game, either all factions for which summoning items exist should be present or a horror player should be added to host them.

noRunWithMulti :: Faction -> Bool Source #

bannedPointmanSwitchBetweenLevels :: Faction -> Bool Source #

isFoe :: FactionId -> Faction -> FactionId -> Bool Source #

Check if factions are at war. Assumes symmetry.

isFriend :: FactionId -> Faction -> FactionId -> Bool Source #

Check if factions are allied or are the same faction. Assumes symmetry.

difficultyBound :: Int Source #

difficultyDefault :: Int Source #

difficultyCoeff :: Int -> Int Source #

defaultChallenge :: Challenge Source #

possibleActorFactions :: [GroupName ItemKind] -> ItemKind -> FactionDict -> Frequency (FactionId, Faction) Source #

ppContainer :: FactionDict -> Container -> Text Source #

# Internal operations

type Dipl = EnumMap FactionId Diplomacy Source #