new Necrowar.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 (attack or build).
-
string gameObjectName
- Inherited From:
- Necrowar.GameObject#gameObjectName
-
number health
-
The remaining health of a unit.
-
string id
- Inherited From:
- Necrowar.GameObject#id
-
Necrowar.UnitJob job
-
The type of unit this is.
-
Array.<string> logs
- Inherited From:
- Necrowar.GameObject#logs
-
number moves
-
The number of moves this unit has left this turn.
-
Necrowar.Player owner
-
The Player that owns and can control this Unit.
-
Necrowar.Tile tile
-
The Tile this Unit is on.
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.
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.
Any strings logged will be stored here. Intended for debugging.
Methods
-
boolean attack(tile)
-
Attacks an enemy tower on an adjacent tile.
Name Type Description tile
Necrowar.Tile The Tile to attack. Returns: boolean
True if successfully attacked, false otherwise. -
boolean build(title)
-
Unit, if it is a worker, builds a tower on the tile it is on, only workers can do this.
Name Type Description title
string The tower type to build, as a string. Returns: boolean
True if successfully built, false otherwise. -
boolean fish(tile)
-
Stops adjacent to a river tile and begins fishing for mana.
Name Type Description tile
Necrowar.Tile The tile the unit will stand on as it fishes. Returns: boolean
True if successfully began fishing for mana, false otherwise. -
log(message)
- Inherited From:
- Necrowar.GameObject#log
-
boolean mine(tile)
-
Enters a mine and is put to work gathering resources.
Name Type Description tile
Necrowar.Tile The tile the mine is located on. Returns: boolean
True if successfully entered mine and began mining, false otherwise. -
boolean move(tile)
-
Moves this Unit from its current Tile to an adjacent Tile.
Name Type Description tile
Necrowar.Tile The Tile this Unit should move to. Returns: boolean
True if it moved, false otherwise. -
string toString()
- Inherited From:
- BaseGameObject#toString
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. |
toString override for easier debugging