Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Miner

A Miner in the game.

Hierarchy

Implements

  • IBaseGameObject

Index

Properties

bombs

bombs: number

The number of bombs being carried by this Miner.

buildingMaterials

buildingMaterials: number

The number of building materials carried by this Miner.

currentUpgrade

currentUpgrade: Upgrade

The Upgrade this Miner is on.

dirt

dirt: number

The amount of dirt carried by this Miner.

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 this Miner.

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.

logs

logs: string[]

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

miningPower

miningPower: number

The remaining mining power this Miner has this turn.

moves

moves: number

The number of moves this Miner has left this turn.

ore

ore: number

The amount of ore carried by this Miner.

owner

owner: Player

The Player that owns and can control this Miner.

tile

tile: Tile | undefined

The Tile this Miner is on.

upgradeLevel

upgradeLevel: number

The upgrade level of this Miner. Starts at 0.

Methods

build

  • build(tile: Tile, type: "support" | "ladder" | "shield"): Promise<boolean>
  • Builds a support, shield, or ladder on Miner's Tile, or an adjacent Tile.

    Parameters

    • tile: Tile

      The Tile to build on.

    • type: "support" | "ladder" | "shield"

      The structure to build (support, ladder, or shield).

    Returns Promise<boolean>

    True if successfully built, False otherwise.

buy

  • buy(resource: "dirt" | "ore" | "bomb" | "buildingMaterials", amount: number): Promise<boolean>
  • Purchase a resource from the Player's base or hopper.

    Parameters

    • resource: "dirt" | "ore" | "bomb" | "buildingMaterials"

      The type of resource to buy.

    • amount: number

      The amount of resource to buy. Amounts <= 0 will buy all of that material Player can.

    Returns Promise<boolean>

    True if successfully purchased, false otherwise.

dump

  • dump(tile: Tile, material: "dirt" | "ore" | "bomb", amount: number): Promise<boolean>
  • Dumps materials from cargo to an adjacent Tile. If the Tile is a base or a hopper Tile, materials are sold instead of placed.

    Parameters

    • tile: Tile

      The Tile the materials will be dumped on.

    • material: "dirt" | "ore" | "bomb"

      The material the Miner will drop. 'dirt', 'ore', or 'bomb'.

    • amount: number

      The number of materials to drop. Amounts <= 0 will drop all of the material.

    Returns Promise<boolean>

    True if successfully dumped materials, 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, amount: number): Promise<boolean>
  • Mines the Tile the Miner is on or an adjacent Tile.

    Parameters

    • tile: Tile

      The Tile the materials will be mined from.

    • amount: number

      The amount of material to mine up. Amounts <= 0 will mine all the materials that the Miner can.

    Returns Promise<boolean>

    True if successfully mined, false otherwise.

move

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

    Parameters

    • tile: Tile

      The Tile this Miner 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.

transfer

  • transfer(miner: Miner, resource: "dirt" | "ore" | "bomb" | "buildingMaterials", amount: number): Promise<boolean>
  • Transfers a resource from the one Miner to another.

    Parameters

    • miner: Miner

      The Miner to transfer materials to.

    • resource: "dirt" | "ore" | "bomb" | "buildingMaterials"

      The type of resource to transfer.

    • amount: number

      The amount of resource to transfer. Amounts <= 0 will transfer all the of the material.

    Returns Promise<boolean>

    True if successfully transferred, false otherwise.

upgrade

  • upgrade(): Promise<boolean>
  • Upgrade this Miner by installing an upgrade module.

    Returns Promise<boolean>

    True if successfully upgraded, False otherwise.

Generated using TypeDoc