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

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Client.State

Description

Client-specific game state components.

Synopsis

- data StateClient = StateClient {
  - seps :: Int
  - stargetD :: EnumMap ActorId TgtAndPath
  - sfleeD :: EnumMap ActorId (Point, Time)
  - sexplored :: EnumSet LevelId
  - sbfsD :: EnumMap ActorId BfsAndPath
  - sundo :: ()
  - sdiscoBenefit :: DiscoveryBenefit
  - sfper :: PerLid
  - salter :: AlterLid
  - srandom :: SMGen
  - _sleader :: Maybe ActorId
  - _sside :: FactionId
  - squit :: Bool
  - scondInMelee :: EnumSet LevelId
  - soptions :: ClientOptions
  - stabs :: (PrimArray PointI, PrimArray PointI)
  - scurChal :: Challenge
  - snxtChal :: Challenge
  - smarkSuspect :: Int
  }
- type AlterLid = EnumMap LevelId (Array Word8)
- data BfsAndPath
  - = BfsInvalid
  - | BfsAndPath (Array BfsDistance) (EnumMap Point AndPath)
- data TgtAndPath = TgtAndPath {
  - tapTgt :: Target
  - tapPath :: Maybe AndPath
  }
- data Target
  - = TEnemy ActorId
  - | TNonEnemy ActorId
  - | TPoint TGoal LevelId Point
  - | TVector Vector
- data TGoal
  - = TStash FactionId
  - | TEnemyPos ActorId
  - | TEmbed ItemBag Point
  - | TItem ItemBag
  - | TSmell
  - | TBlock
  - | TUnknown
  - | TKnown
  - | THideout
- emptyStateClient :: FactionId -> StateClient
- cycleMarkSuspect :: Int -> StateClient -> StateClient
- updateTarget :: ActorId -> (Maybe Target -> Maybe Target) -> StateClient -> StateClient
- getTarget :: ActorId -> StateClient -> Maybe Target
- updateLeader :: ActorId -> State -> StateClient -> StateClient
- sside :: StateClient -> FactionId
- sleader :: StateClient -> Maybe ActorId

# Documentation

data StateClient Source #

Client state, belonging to a single faction.

Constructors

StateClient |

Fields

- seps :: Int

  a parameter of the aiming digital line

- stargetD :: EnumMap ActorId TgtAndPath

  targets of our actors in the dungeon; this is only useful for AI and for directing non-pointmen, in particular with following doctrines, where non-pointmen go to the pointman's target

- sfleeD :: EnumMap ActorId (Point, Time)

  the position and time of last fleeing attempt (regardless if succeeded)

- sexplored :: EnumSet LevelId

  the set of fully explored levels

- sbfsD :: EnumMap ActorId BfsAndPath

  pathfinding data for our actors

- sundo :: ()
- sdiscoBenefit :: DiscoveryBenefit

  remembered AI benefits of items; could be recomputed at resume, but they are costly to generate and not too large

- sfper :: PerLid

  faction perception indexed by level

- salter :: AlterLid

  cached alter skill data for positions (actually, `Tile.alterMinWalk` instead)

- srandom :: SMGen

  current random generator

- _sleader :: Maybe ActorId

  candidate new leader of the faction; Faction.gleader is the old leader

- _sside :: FactionId

  faction controlled by the client

- squit :: Bool

  exit the game loop

- scondInMelee :: EnumSet LevelId

  whether we are in melee, per level

- soptions :: ClientOptions

  client options

- stabs :: (PrimArray PointI, PrimArray PointI)

  Instead of a BFS queue (list) we use these two arrays, for (JS) speed. They need to be per-client distinct, because sometimes multiple clients interleave BFS computation.

- scurChal :: Challenge

  current game challenge setup

- snxtChal :: Challenge

  next game challenge setup

- smarkSuspect :: Int

  whether to mark suspect features

#### Instances

Instances details

Binary StateClient Source # |
Instance details Defined in Game.LambdaHack.Client.State Methods put :: StateClient -> Put Source # get :: Get StateClient Source # putList :: [StateClient] -> Put Source #

type AlterLid = EnumMap LevelId (Array Word8) Source #

data BfsAndPath Source #

Pathfinding distances to all reachable positions of an actor and a shortest paths to some of the positions.

Constructors

BfsInvalid |
BfsAndPath (Array BfsDistance) (EnumMap Point AndPath) |

#### Instances

Instances details

Show BfsAndPath Source # |
Instance details Defined in Game.LambdaHack.Client.State Methods showsPrec :: Int -> BfsAndPath -> ShowS Source # show :: BfsAndPath -> String Source # showList :: [BfsAndPath] -> ShowS Source #

data TgtAndPath Source #

Actor's target and a path to it, if any.

Constructors

TgtAndPath |

Fields

- tapTgt :: Target
- tapPath :: Maybe AndPath

#### Instances

Instances details

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

Instance details

Defined in Game.LambdaHack.Client.State

Associated Types

type Rep TgtAndPath |

Instance details

Defined in Game.LambdaHack.Client.State

type Rep TgtAndPath = D1 ('MetaData "TgtAndPath" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "TgtAndPath" 'PrefixI 'True) (S1 ('MetaSel ('Just "tapTgt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Target) :*: S1 ('MetaSel ('Just "tapPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe AndPath))))

Methods

from :: TgtAndPath -> Rep TgtAndPath x Source #

to :: Rep TgtAndPath x -> TgtAndPath Source #

Show TgtAndPath Source # |
Instance details Defined in Game.LambdaHack.Client.State Methods showsPrec :: Int -> TgtAndPath -> ShowS Source # show :: TgtAndPath -> String Source # showList :: [TgtAndPath] -> ShowS Source #
type Rep TgtAndPath Source # |

Instance details

Defined in Game.LambdaHack.Client.State

type Rep TgtAndPath = D1 ('MetaData "TgtAndPath" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "TgtAndPath" 'PrefixI 'True) (S1 ('MetaSel ('Just "tapTgt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Target) :*: S1 ('MetaSel ('Just "tapPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe AndPath))))

data Target Source #

The type of na actor target.

Constructors

TEnemy ActorId | target an enemy
TNonEnemy ActorId | target a friend or neutral
TPoint TGoal LevelId Point | target a concrete spot
TVector Vector | target position relative to actor

#### Instances

Instances details

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

Instance details

Defined in Game.LambdaHack.Client.State

Associated Types

type Rep Target |

Instance details

Defined in Game.LambdaHack.Client.State

type Rep Target = D1 ('MetaData "Target" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "TEnemy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId)) :+: C1 ('MetaCons "TNonEnemy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId))) :+: (C1 ('MetaCons "TPoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 TGoal) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LevelId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point))) :+: C1 ('MetaCons "TVector" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Vector))))

Methods

from :: Target -> Rep Target x Source #

to :: Rep Target x -> Target Source #

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

Instance details

Defined in Game.LambdaHack.Client.State

type Rep Target = D1 ('MetaData "Target" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "TEnemy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId)) :+: C1 ('MetaCons "TNonEnemy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId))) :+: (C1 ('MetaCons "TPoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 TGoal) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LevelId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point))) :+: C1 ('MetaCons "TVector" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Vector))))

data TGoal Source #

The goal of an actor.

Constructors

TStash FactionId | shared inventory stash of our or an enemy faction
TEnemyPos ActorId | last seen position of the targeted actor
TEmbed ItemBag Point | embedded item that can be triggered; in `TPoint (TEmbed bag p) _ q` usually `bag` is embbedded in `p` and `q` is an adjacent open tile
TItem ItemBag | item lying on the ground
TSmell | smell potentially left by enemies
TBlock | a blocking tile to be approached (and, e.g., revealed to be walkable or altered or searched)
TUnknown | an unknown tile to be explored
TKnown | a known tile to be patrolled
THideout | a hideout to either flee to or find a hidden enemy sniper in

#### Instances

Instances details

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

Instance details

Defined in Game.LambdaHack.Client.State

Associated Types

type Rep TGoal |

Instance details

Defined in Game.LambdaHack.Client.State

type Rep TGoal = D1 ('MetaData "TGoal" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (((C1 ('MetaCons "TStash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionId)) :+: C1 ('MetaCons "TEnemyPos" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId))) :+: (C1 ('MetaCons "TEmbed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point)) :+: C1 ('MetaCons "TItem" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag)))) :+: ((C1 ('MetaCons "TSmell" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TBlock" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TUnknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TKnown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THideout" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: TGoal -> Rep TGoal x Source #

to :: Rep TGoal x -> TGoal Source #

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

Instance details

Defined in Game.LambdaHack.Client.State

type Rep TGoal = D1 ('MetaData "TGoal" "Game.LambdaHack.Client.State" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (((C1 ('MetaCons "TStash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionId)) :+: C1 ('MetaCons "TEnemyPos" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ActorId))) :+: (C1 ('MetaCons "TEmbed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point)) :+: C1 ('MetaCons "TItem" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag)))) :+: ((C1 ('MetaCons "TSmell" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TBlock" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TUnknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TKnown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THideout" 'PrefixI 'False) (U1 :: Type -> Type)))))

emptyStateClient :: FactionId -> StateClient Source #

Initial empty game client state.

cycleMarkSuspect :: Int -> StateClient -> StateClient Source #

Cycle the `smarkSuspect` setting.

updateTarget :: ActorId -> (Maybe Target -> Maybe Target) -> StateClient -> StateClient Source #

Update target parameters within client state.

getTarget :: ActorId -> StateClient -> Maybe Target Source #

Get target parameters from client state.

updateLeader :: ActorId -> State -> StateClient -> StateClient Source #

Update picked leader within state. Verify actor's faction.

sside :: StateClient -> FactionId Source #

sleader :: StateClient -> Maybe ActorId Source #