Home Reference Source Repository
public class | source

Ability

Represents a non-attack action that a creature can perform

Method Summary

Public Methods
public

For targetted abilities, tells whether or not the target can be the tile the creature is standing on.

public abstract

A short description of the ability

public abstract

Gets the amount of mana deducted from the user upon use.

public

Gets a formatted name for the ability

public

For targetted abilities, tells how far away the ability can target.

public

getReasonIllegal(dungeon: Dungeon, creature: Creature, optionalTargetTile: Tile, isFree: boolean): String

Gives a reason the ability cannot be performed by the given creature, if any exists.

public

Tells whether the ability can cause the creature to move.

public abstract

For a targetted ability, tells whether the ability requires the target tile to contain a creature.

public abstract

Tells whether the ability targets a tile.

public

For targetted abilities, tells whether or not the target must be visible to the creature.

public

Generic toString method

public

use(dungeon: Dungeon, creature: Creature, optionalTargetTile: Tile, isFree: boolean)

Causes the given creature to perform the ability, modifying the game state

Public Methods

public canTargetSelf(): boolean source

For targetted abilities, tells whether or not the target can be the tile the creature is standing on.

Return:

boolean

true if the ability may target the user; false otherwise.

public abstract getDescription(): String source

A short description of the ability

Return:

String

A human-readable description of the ability's effects

public abstract getManaCost(): number source

Gets the amount of mana deducted from the user upon use. If this amount exceeds the creature's available mana, the ability cannot be used normally.

Return:

number

The mana required to use the ability

public getName(): String source

Gets a formatted name for the ability

Return:

String

A human-readable name

public getRange(): number source

For targetted abilities, tells how far away the ability can target. 0 means that the ability can only self-target.

Return:

number

A number indicating how far the ability can target

public getReasonIllegal(dungeon: Dungeon, creature: Creature, optionalTargetTile: Tile, isFree: boolean): String source

Gives a reason the ability cannot be performed by the given creature, if any exists.

Params:

NameTypeAttributeDescription
dungeon Dungeon

The dungeon the creature is in

creature Creature

The creature performing the ability

optionalTargetTile Tile
  • optional

The tile targetted by the ability, if required

isFree boolean
  • optional

If true, will not check whether mana cost is met

Return:

String

The reason the ability cannot be performed, or null if none exists.

public isMovementAbility(): boolean source

Tells whether the ability can cause the creature to move. creatures will not be able to use a movement ability if their movement is impaired.

Return:

boolean

true if the ability can cause the user to move; false otherwise.

public abstract isTargetCreature(): boolean source

For a targetted ability, tells whether the ability requires the target tile to contain a creature. This is not called if the ability doesn't target.

Return:

boolean

true if the ability must target a creature; false otherwise.

public abstract isTargetted(): boolean source

Tells whether the ability targets a tile.

Return:

boolean

true if the ability must target a tile; false otherwise.

public mustTargetBeVisible(): boolean source

For targetted abilities, tells whether or not the target must be visible to the creature.

Return:

boolean

true if the ability must target a visible tile; false otherwise.

public toString(): String source

Generic toString method

Return:

String

A string for debug purposes

public use(dungeon: Dungeon, creature: Creature, optionalTargetTile: Tile, isFree: boolean) source

Causes the given creature to perform the ability, modifying the game state

Params:

NameTypeAttributeDescription
dungeon Dungeon

The dungeon the creature is in

creature Creature

The creature performing the ability

optionalTargetTile Tile
  • optional

The tile targetted by the ability, if required

isFree boolean
  • optional

If true, will not check whether mana cost is met