Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Beaver

A beaver in the game.

Hierarchy

Implements

  • IBaseGameObject

Index

Properties

actions

actions: number

The number of actions remaining for the Beaver this turn.

branches

branches: number

The amount of branches this Beaver is holding.

food

food: number

The amount of food this Beaver is holding.

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

How much health this Beaver has left.

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: Job

The Job this Beaver was recruited to do.

logs

logs: string[]

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

moves

moves: number

How many moves this Beaver has left this turn.

owner

owner: Player

The Player that owns and can control this Beaver.

recruited

recruited: boolean

True if the Beaver has finished being recruited and can do things, False otherwise.

tile

tile: Tile | undefined

The Tile this Beaver is on.

turnsDistracted

turnsDistracted: number

Number of turns this Beaver is distracted for (0 means not distracted).

Methods

attack

  • attack(beaver: Beaver): Promise<boolean>
  • Attacks another adjacent beaver.

    Parameters

    • beaver: Beaver

      The Beaver to attack. Must be on an adjacent Tile.

    Returns Promise<boolean>

    True if successfully attacked, false otherwise.

buildLodge

  • buildLodge(): Promise<boolean>
  • Builds a lodge on the Beavers current Tile.

    Returns Promise<boolean>

    True if successfully built a lodge, false otherwise.

drop

  • drop(tile: Tile, resource: "branches" | "food", amount?: number): Promise<boolean>
  • Drops some of the given resource on the beaver's Tile.

    Parameters

    • tile: Tile

      The Tile to drop branches/food on. Must be the same Tile that the Beaver is on, or an adjacent one.

    • resource: "branches" | "food"

      The type of resource to drop ('branches' or 'food').

    • Default value amount: number = 0

      The amount of the resource to drop, numbers <= 0 will drop all the resource type.

    Returns Promise<boolean>

    True if successfully dropped the resource, false otherwise.

harvest

  • harvest(spawner: Spawner): Promise<boolean>
  • Harvests the branches or food from a Spawner on an adjacent Tile.

    Parameters

    • spawner: Spawner

      The Spawner you want to harvest. Must be on an adjacent Tile.

    Returns Promise<boolean>

    True if successfully harvested, 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>

move

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

    Parameters

    • tile: Tile

      The Tile this Beaver should move to.

    Returns Promise<boolean>

    True if the move worked, false otherwise.

pickup

  • pickup(tile: Tile, resource: "branches" | "food", amount?: number): Promise<boolean>
  • Picks up some branches or food on the beaver's tile.

    Parameters

    • tile: Tile

      The Tile to pickup branches/food from. Must be the same Tile that the Beaver is on, or an adjacent one.

    • resource: "branches" | "food"

      The type of resource to pickup ('branches' or 'food').

    • Default value amount: number = 0

      The amount of the resource to drop, numbers <= 0 will pickup all of the resource type.

    Returns Promise<boolean>

    True if successfully picked up a resource, 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