Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Unit

A unit in the game. May be a worker, zombie, ghoul, hound, abomination, wraith or horseman.

Hierarchy

Implements

  • IBaseGameObject

Index

Properties

acted

acted: boolean

Whether or not this Unit has performed its action this turn (attack or build).

gameObjectName

gameObjectName: string

String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

health

health: number

The remaining health of a unit.

id

id: string

A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

job

job: UnitJob

The type of unit this is.

logs

logs: string[]

Any strings logged will be stored here. Intended for debugging.

moves

moves: number

The number of moves this unit has left this turn.

owner

owner: Player | undefined

The Player that owns and can control this Unit.

tile

tile: Tile | undefined

The Tile this Unit is on.

Methods

attack

  • attack(tile: Tile): Promise<boolean>
  • Attacks an enemy tower on an adjacent tile.

    Parameters

    • tile: Tile

      The Tile to attack.

    Returns Promise<boolean>

    True if successfully attacked, false otherwise.

build

  • build(title: string): Promise<boolean>
  • Unit, if it is a worker, builds a tower on the tile it is on, only workers can do this.

    Parameters

    • title: string

      The tower type to build, as a string.

    Returns Promise<boolean>

    True if successfully built, false otherwise.

fish

  • fish(tile: Tile): Promise<boolean>
  • Stops adjacent to a river tile and begins fishing for mana.

    Parameters

    • tile: Tile

      The tile the unit will stand on as it fishes.

    Returns Promise<boolean>

    True if successfully began fishing for mana, false otherwise.

log

  • log(message: string): Promise<void>
  • Adds a message to this GameObject's logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.

    Parameters

    • message: string

      A string to add to this GameObject's log. Intended for debugging.

    Returns Promise<void>

mine

  • mine(tile: Tile): Promise<boolean>
  • Enters a mine and is put to work gathering resources.

    Parameters

    • tile: Tile

      The tile the mine is located on.

    Returns Promise<boolean>

    True if successfully entered mine and began mining, false otherwise.

move

  • move(tile: Tile): Promise<boolean>
  • Moves this Unit from its current Tile to an adjacent Tile.

    Parameters

    • tile: Tile

      The Tile this Unit should move to.

    Returns Promise<boolean>

    True if it moved, false otherwise.

toString

  • toString(): string
  • A toString override for easier debugging.

    example

    String(gameObject); 🠞 "GameObjectName #1245"

    Returns string

    A human readable representation of the game object.

Generated using TypeDoc