LambdaHack-0.2.10: A roguelike game engine in early and active development

Safe HaskellNone

Game.LambdaHack.Common.Actor

Contents

Description

Actors in the game: heroes, monsters, etc. No operation in this module involves the State or Action type.

Synopsis

Actor identifiers and related operations

data ActorId

A unique identifier of an actor in the dungeon.

monsterGenChance :: Int -> Int -> Int -> Rnd Bool

Chance that a new monster is generated. Currently depends on the number of monsters already present, and on the level. In the future, the strength of the character and the strength of the monsters present could further influence the chance, and the chance could also affect which monster is generated. How many and which monsters are generated will also depend on the cave kind used to build the level.

partActor :: Actor -> Part

The part of speech describing the actor.

The Actor type

data Actor

Actor properties that are changing throughout the game. If they are dublets of properties from ActorKind, they are usually modified temporarily, but tend to return to the original value from ActorKind over time. E.g., HP.

Constructors

Actor 

Fields

bkind :: !(Id ActorKind)

the kind of the actor

bsymbol :: !Char

individual map symbol

bname :: !Text

individual name

bcolor :: !Color

individual map color

bspeed :: !Speed

individual speed

bhp :: !Int

current hit points

bpath :: !(Maybe [Vector])

path the actor is forced to travel

bpos :: !Point

current position

boldpos :: !Point

previous position

blid :: !LevelId

current level

bbag :: !ItemBag

items carried

binv :: !ItemInv

map from letters to items

bletter :: !InvChar

next inventory letter

btime :: !Time

absolute time of next action

bwait :: !Time

last bracing expires at this time

bfid :: !FactionId

to which faction the actor belongs

bproj :: !Bool

is a projectile? (shorthand only, this can be deduced from bkind)

Instances

actorTemplate :: Id ActorKind -> Char -> Text -> Color -> Speed -> Int -> Maybe [Vector] -> Point -> LevelId -> Time -> FactionId -> Bool -> Actor

A template for a new non-projectile actor.

timeAddFromSpeed :: Actor -> Time -> Time

Add time taken by a single step at the actor's current speed.

braced :: Actor -> Time -> Bool

Whether an actor is braced for combat this clip. If a foe moves just after this actor in the same time moment, the actor won't block, because bwait is reset to zero in ageActorA before the condition is checked.

waitedLastTurn :: Actor -> Time -> Bool

The actor most probably waited at most a turn ago (unless his speed was changed, etc.)

unoccupied :: [Actor] -> Point -> Bool

Checks for the presence of actors in a position. Does not check if the tile is walkable.

heroKindId :: Ops ActorKind -> Id ActorKind

The unique kind of heroes.

projectileKindId :: Ops ActorKind -> Id ActorKind

The unique kind of projectiles.

Inventory management

type ItemBag = EnumMap ItemId Int

type ItemInv = EnumMap InvChar ItemId

newtype InvChar

Constructors

InvChar 

Fields

invChar :: Char
 

type ItemDict = EnumMap ItemId Item

All items in the dungeon (including in actor inventories), indexed by item identifier.

type ItemRev = HashMap Item ItemId

Reverse item map, for item creation, to keep items and item identifiers in bijection.

assignLetter :: ItemId -> Maybe InvChar -> Actor -> Maybe InvChar

Assigns a letter to an item, for inclusion in the inventory of a hero. Tries to to use the requested letter, if any.

letterLabel :: InvChar -> Part

letterRange :: [InvChar] -> Text

Assorted

type ActorDict = EnumMap ActorId Actor

All actors on the level, indexed by actor identifier.

smellTimeout :: Time

How long until an actor's smell vanishes from a tile.

mapActorItems_ :: Monad m => (ItemId -> Int -> m a) -> Actor -> m ()