Class: Unit

Newtonian. Unit

A unit in the game. May be a manager, intern, or physicist.

new Newtonian.Unit()

Initializes a Unit with basic logic as provided by the Creer code generator. Never use this directly. It is for internal Joueur use.

Extends

Members

boolean acted

Whether or not this Unit has performed its action this turn.

number blueium

The amount of blueium carried by this unit. (0 to job carry capacity - other carried items).

number blueiumOre

The amount of blueium ore carried by this unit. (0 to job carry capacity - other carried items).

string gameObjectName

Inherited From:
Newtonian.GameObject#gameObjectName
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.

number health

The remaining health of a unit.

string id

Inherited From:
Newtonian.GameObject#id
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.
The Job this Unit has.

Array.<string> logs

Inherited From:
Newtonian.GameObject#logs
Any strings logged will be stored here. Intended for debugging.

number moves

The number of moves this unit has left this turn.
The Player that owns and can control this Unit.

number redium

The amount of redium carried by this unit. (0 to job carry capacity - other carried items).

number rediumOre

The amount of redium ore carried by this unit. (0 to job carry capacity - other carried items).

number stunImmune

Duration of stun immunity. (0 to timeImmune).

number stunTime

Duration the unit is stunned. (0 to the game constant stunTime).
The Tile this Unit is on.

Methods

boolean act(tile)

Makes the unit do something to a machine or unit adjacent to its tile. Interns sabotage, physicists work. Interns stun physicist, physicist stuns manager, manager stuns intern.
Name Type Description
tile Newtonian.Tile The tile the unit acts on.
Returns: boolean
True if successfully acted, false otherwise.

boolean attack(tile)

Attacks a unit on an adjacent tile.
Name Type Description
tile Newtonian.Tile The Tile to attack.
Returns: boolean
True if successfully attacked, false otherwise.

boolean drop(tile, amount, material)

Drops materials at the units feet or adjacent tile.
Name Type Description
tile Newtonian.Tile The tile the materials will be dropped on.
amount number The number of materials to dropped. Amounts <= 0 will drop all the materials.
material string The material the unit will drop. 'redium', 'blueium', 'redium ore', or 'blueium ore'.
Returns: boolean
True if successfully deposited, false otherwise.

log(message)

Inherited From:
Newtonian.GameObject#log
Adds a message to this GameObject's logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.
Name Type Description
message string A string to add to this GameObject's log. Intended for debugging.

boolean move(tile)

Moves this Unit from its current Tile to an adjacent Tile.
Name Type Description
tile Newtonian.Tile The Tile this Unit should move to.
Returns: boolean
True if it moved, false otherwise.

boolean pickup(tile, amount, material)

Picks up material at the units feet or adjacent tile.
Name Type Description
tile Newtonian.Tile The tile the materials will be picked up from.
amount number The amount of materials to pick up. Amounts <= 0 will pick up all the materials that the unit can.
material string The material the unit will pick up. 'redium', 'blueium', 'redium ore', or 'blueium ore'.
Returns: boolean
True if successfully deposited, false otherwise.

string toString()

Inherited From:
BaseGameObject#toString
toString override for easier debugging
Returns: string
readable string in the format `GameObjectName #id`