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

Safe HaskellNone

Game.LambdaHack.Common.ActorState

Description

Operations on the Actor type that need the State type, but not the Action type. TODO: Document an export list after it's rewritten according to #17.

Synopsis

Documentation

calculateTotal :: Actor -> State -> (ItemBag, Int)

Calculate loot's worth for heroes on the current level.

Warning: scores are shown during the game, so when the server calculates then, we should be careful not to leak secret information (e.g., the nature of the items through the total worth of inventory).

whereTo

Arguments

:: LevelId

level of the stairs

-> Point

position of the stairs

-> Int

jump up this many levels

-> State

game state

-> (LevelId, Point)

target level and the position of its receiving stairs

Compute the level identifier and starting position on the level, after a level change.

posToActor :: Point -> LevelId -> State -> Maybe ActorId

Finds an actor at a position on the current level. Perception irrelevant.

memActor :: ActorId -> LevelId -> State -> Bool

Checks if the actor is present on the current level. The order of argument here and in other functions is set to allow

 b <- getsState (memActor a)

getActorBody :: ActorId -> State -> Actor

Gets actor body from the current level. Error if not found.

getActorItem :: ActorId -> State -> [(ItemId, Item)]

Gets actor's items from the current level. Warning: this does not work for viewing items of actors from remote level.

foesAdjacent :: X -> Y -> Point -> [Actor] -> Bool