Unit

class games.necrowar.unit.Unit

Bases: games.necrowar.game_object.GameObject

The class representing the Unit in the Necrowar game.

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

property acted

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

Type

bool

attack(tile: games.necrowar.tile.Tile) → bool

Attacks an enemy tower on an adjacent tile.

Parameters

tile (games.necrowar.tile.Tile) – The Tile to attack.

Returns

True if successfully attacked, False otherwise.

Return type

bool

build(title: str) → bool

Unit, if it is a worker, builds a tower on the tile it is on, only workers can do this.

Parameters

title (str) – The tower type to build, as a string.

Returns

True if successfully built, False otherwise.

Return type

bool

fish(tile: games.necrowar.tile.Tile) → bool

Stops adjacent to a river tile and begins fishing for mana.

Parameters

tile (games.necrowar.tile.Tile) – The tile the unit will stand on as it fishes.

Returns

True if successfully began fishing for mana, False otherwise.

Return type

bool

property game_object_name

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.

Type

str

property health

The remaining health of a unit.

Type

int

property 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.

Type

str

property job

The type of unit this is.

Type

games.necrowar.unit_job.UnitJob

log(message: str) → None

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 (str) – A string to add to this GameObject’s log. Intended for debugging.

property logs

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

Type

list[str]

mine(tile: games.necrowar.tile.Tile) → bool

Enters a mine and is put to work gathering resources.

Parameters

tile (games.necrowar.tile.Tile) – The tile the mine is located on.

Returns

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

Return type

bool

move(tile: games.necrowar.tile.Tile) → bool

Moves this Unit from its current Tile to an adjacent Tile.

Parameters

tile (games.necrowar.tile.Tile) – The Tile this Unit should move to.

Returns

True if it moved, False otherwise.

Return type

bool

property moves

The number of moves this unit has left this turn.

Type

int

property owner

The Player that owns and can control this Unit.

Type

games.necrowar.player.Player or None

property tile

The Tile this Unit is on.

Type

games.necrowar.tile.Tile or None