Home Reference Source Repository
public class | source

Creature

Extends:

Entity → Creature

Indirect Subclass:

Fighter, Miner, Rogue, Wizard

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

addAbility(ability: Ability)

Adds an Ability to the Creature's list of Abilities.

public

addItem(item: Item, backpackOnly: boolean)

Adds an item to the creature's inventory, optionally equipping it if there's room

public

applyBuff(dungeon: Dungeon, buff: Buff)

Puts a Buff onto the creature.

public

Tells whether the Creature may act on the current timestep.

public

canAddItem(item: Item, backpackOnly: boolean): boolean

Checks to see if the creature's backpack can hold another item

public

canOccupy(tile: *): Boolean

public

canOccupyNow(tile: *): *

public

canSee(dungeon: *, tile: *): Boolean

Determines if the Creature can see the given tile and what's on it.

public

Tells whether the creature can pickup and use items.

public

die(-: Dungeon)

Kills this creature, removing it from the Dungeon

public

executeMove(dungeon: *, move: *)

public

Gets a list of the Creature's abilities

public

Gets the creature's Ability at the given index

public

Gets the index of a creature's Ability

public

getArmor(): *

public

Get's the Creature's maximum allowed hitpoints

public

Get's the Creature's maximum allowed mana

public

Gets a list of the Creature's Buffs.

public

getClosestEnemy(dungeon: *): *

public

Get's the Creature's current hitpoints

public

Get's the Creature's current mana

public

Get's the amount that damage of the given type is reduced by the creature's defenses.

public
public

Gets the creature's inventory

public
public

getNextMove(dungeon: *): Move | Promise

public
public
public
public

Gets the number of timesteps until this Creature's next move.

public

getVisibleCreatures(dungeon: *): *

public

getVisibleEnemies(dungeon: *): *

public

getVisibleTiles(dungeon: *): *

public
public

hasSeen(tile: *): *

public

heal(dungeon: Dungeon, amount: number)

Restores the Creature's hitpoints by a given amount. The Creature cannot go above it's hitpoint maximum in this way

public

Tells whether the Creature is dead.

public

isEnemy(other: *): *

public
public

Modifies the Creature's current mana by the given amount. Mana cannot go below zero or above the Creature's base mana value

public

observeMove(dungeon: *, actor: *, move: *)

public

An optional death handler for this Creature.

public

receiveDamage(dungeon: Dungeon, amount: number, type: string): number

Applies a given amount of typed damage to the creature, minus the creature's damage reduction

public

setArmor(armor: *)

public

setMeleeWeapon(weapon: *)

public

setRangedWeapon(weapon: *)

public

setStrategy(strategy: *)

public

takeItems(dungeon: Dungeon)

Takes items from the Creature's current tile and attempts to add each one to it's Inventory in sequence

public

timestep(dungeon: *)

public

visionObsuredBy(tile: *): *

Inherited Summary

From class Entity
public
public

getId(): *

public

getName(): *

public
public

toString(): *

Public Constructors

public constructor() source

Override:

Entity#constructor

Public Methods

public addAbility(ability: Ability) source

Adds an Ability to the Creature's list of Abilities.

Params:

NameTypeAttributeDescription
ability Ability

The new ability

public addItem(item: Item, backpackOnly: boolean) source

Adds an item to the creature's inventory, optionally equipping it if there's room

Params:

NameTypeAttributeDescription
item Item

The Item to add

backpackOnly boolean
  • optional
  • default: false

Prohibits automatically equipping the item

public applyBuff(dungeon: Dungeon, buff: Buff) source

Puts a Buff onto the creature. The Buff will have a chance to apply it's effects each timestep (including the current one) until it ends or is removed

Params:

NameTypeAttributeDescription
dungeon Dungeon

The Dungeon the creature is in

buff Buff

The Buff to apply

public canActThisTimestep(): boolean source

Tells whether the Creature may act on the current timestep.

Return:

boolean

true if the Creature's wait time til it's next move is 0; false otherwise

public canAddItem(item: Item, backpackOnly: boolean): boolean source

Checks to see if the creature's backpack can hold another item

Params:

NameTypeAttributeDescription
item Item

The Item to add

backpackOnly boolean
  • optional
  • default: false

If true, only checks for an empty backpack slot

Return:

boolean

public canOccupy(tile: *): Boolean source

Params:

NameTypeAttributeDescription
tile *

Return:

Boolean

true if the Creature could occupy the tile; false otherwise

public canOccupyNow(tile: *): * source

Params:

NameTypeAttributeDescription
tile *

Return:

*

public canSee(dungeon: *, tile: *): Boolean source

Determines if the Creature can see the given tile and what's on it.

Params:

NameTypeAttributeDescription
dungeon *
tile *

Return:

Boolean

true if the Creature can see the tile; false otherwise

public canUseItems(): boolean source

Tells whether the creature can pickup and use items. By default, players can use items and enemies cannot.

Return:

boolean

public die(-: Dungeon) source

Kills this creature, removing it from the Dungeon

Params:

NameTypeAttributeDescription
- Dungeon

The Dungeon this Creature is in

public executeMove(dungeon: *, move: *) source

Params:

NameTypeAttributeDescription
dungeon *
move *

public getAbilities(): Array<Ability> source

Gets a list of the Creature's abilities

Return:

Array<Ability>

public getAbility(index: number): Ability source

Gets the creature's Ability at the given index

Params:

NameTypeAttributeDescription
index number

Return:

Ability

public getAbilityIndex(param: function(): Ability): number source

Gets the index of a creature's Ability

Params:

NameTypeAttributeDescription
param function(): Ability

An ability constructor

Return:

number

An integer index if an instance of the given class is found; -1 otherwise

public getArmor(): * source

Return:

*

public getBaseHP(): number source

Get's the Creature's maximum allowed hitpoints

Return:

number

A positive integer

public getBaseMana(): number source

Get's the Creature's maximum allowed mana

Return:

number

A positive integer

public getBuffs(): Array<Buff> source

Gets a list of the Creature's Buffs.

Return:

Array<Buff>

The Creature's Buffs

public getClosestEnemy(dungeon: *): * source

Params:

NameTypeAttributeDescription
dungeon *

Return:

*

public getCurrentHP(): number source

Get's the Creature's current hitpoints

Return:

number

A non-negative integer

public getCurrentMana(): number source

Get's the Creature's current mana

Return:

number

A non-negative integer

public getDamageReduction(type: string): number source

Get's the amount that damage of the given type is reduced by the creature's defenses. Damage reduction is subtracted from incoming damage. Damage reduction typically comes from Armor

Params:

NameTypeAttributeDescription
type string

A member of DamageTypes

Return:

number

A non-negative integer

public getFaction(): string source

Return:

string

public getInventory(): * source

Gets the creature's inventory

Return:

*

Inventory

public getMeleeWeapon(): * source

Return:

*

public getNextMove(dungeon: *): Move | Promise source

Params:

NameTypeAttributeDescription
dungeon *

Return:

Move | Promise

A Move or a Promise for a Move

public getRangedWeapon(): * source

Return:

*

public getSpeed(): number source

Return:

number

public getStrategy(): * source

Return:

*

public getTimeToNextMove(): number source

Gets the number of timesteps until this Creature's next move.

Return:

number

public getVisibleCreatures(dungeon: *): * source

Params:

NameTypeAttributeDescription
dungeon *

Return:

*

public getVisibleEnemies(dungeon: *): * source

Params:

NameTypeAttributeDescription
dungeon *

Return:

*

public getVisibleTiles(dungeon: *): * source

Params:

NameTypeAttributeDescription
dungeon *

Return:

*

public getVisionRadius(): number source

Return:

number

public hasSeen(tile: *): * source

Params:

NameTypeAttributeDescription
tile *

Return:

*

public heal(dungeon: Dungeon, amount: number) source

Restores the Creature's hitpoints by a given amount. The Creature cannot go above it's hitpoint maximum in this way

Params:

NameTypeAttributeDescription
dungeon Dungeon

The creature's current Dungeon

amount number

The amount of damage to restore

public isDead(): boolean source

Tells whether the Creature is dead. If the Creature is dead it will no longer be in a Dungeon.

Return:

boolean

true if the Creature has died; false otherwise

public isEnemy(other: *): * source

Params:

NameTypeAttributeDescription
other *

Return:

*

public isFlying(): boolean source

Return:

boolean

public modifyMana(-: number) source

Modifies the Creature's current mana by the given amount. Mana cannot go below zero or above the Creature's base mana value

Params:

NameTypeAttributeDescription
- number

An integer to add to the Creature's current mana. Negative numbers are allowed

public observeMove(dungeon: *, actor: *, move: *) source

Params:

NameTypeAttributeDescription
dungeon *
actor *
move *

public onDeath() source

An optional death handler for this Creature. Called when the Creature dies

public receiveDamage(dungeon: Dungeon, amount: number, type: string): number source

Applies a given amount of typed damage to the creature, minus the creature's damage reduction

Params:

NameTypeAttributeDescription
dungeon Dungeon

The creature's current Dungeon

amount number

The amount of damage

type string

A member of DamageTypes

Return:

number

The amount of damage received. If the creature has no reduction for the given type, then this will be the same as the input amount

public setArmor(armor: *) source

Params:

NameTypeAttributeDescription
armor *

public setMeleeWeapon(weapon: *) source

Params:

NameTypeAttributeDescription
weapon *

public setRangedWeapon(weapon: *) source

Params:

NameTypeAttributeDescription
weapon *

public setStrategy(strategy: *) source

Params:

NameTypeAttributeDescription
strategy *

public takeItems(dungeon: Dungeon) source

Takes items from the Creature's current tile and attempts to add each one to it's Inventory in sequence

Params:

NameTypeAttributeDescription
dungeon Dungeon

The Dungeon the creature is in

public timestep(dungeon: *) source

Params:

NameTypeAttributeDescription
dungeon *

public visionObsuredBy(tile: *): * source

Params:

NameTypeAttributeDescription
tile *

Return:

*