Unit

class games.newtonian.unit.Unit

Bases: games.newtonian.game_object.GameObject

The class representing the Unit in the Newtonian game.

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

act(tile: games.newtonian.tile.Tile) → bool

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.

Parameters

tile (games.newtonian.tile.Tile) – The tile the unit acts on.

Returns

True if successfully acted, False otherwise.

Return type

bool

property acted

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

Type

bool

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

Attacks a unit on an adjacent tile.

Parameters

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

Returns

True if successfully attacked, False otherwise.

Return type

bool

property blueium

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

Type

int

property blueium_ore

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

Type

int

drop(tile: games.newtonian.tile.Tile, amount: int, material: str) → bool

Drops materials at the units feet or adjacent tile.

Parameters
  • tile (games.newtonian.tile.Tile) – The tile the materials will be dropped on.

  • amount (int) – The number of materials to dropped. Amounts <= 0 will drop all the materials.

  • material ('redium ore', 'redium', 'blueium', or 'blueium ore') – The material the unit will drop. ‘redium’, ‘blueium’, ‘redium ore’, or ‘blueium ore’.

Returns

True if successfully deposited, 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 Job this Unit has.

Type

games.newtonian.job.Job

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]

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

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

Parameters

tile (games.newtonian.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.newtonian.player.Player or None

pickup(tile: games.newtonian.tile.Tile, amount: int, material: str) → bool

Picks up material at the units feet or adjacent tile.

Parameters
  • tile (games.newtonian.tile.Tile) – The tile the materials will be picked up from.

  • amount (int) – The amount of materials to pick up. Amounts <= 0 will pick up all the materials that the unit can.

  • material ('redium ore', 'redium', 'blueium', or 'blueium ore') – The material the unit will pick up. ‘redium’, ‘blueium’, ‘redium ore’, or ‘blueium ore’.

Returns

True if successfully deposited, False otherwise.

Return type

bool

property redium

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

Type

int

property redium_ore

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

Type

int

property stun_immune

Duration of stun immunity. (0 to timeImmune).

Type

int

property stun_time

Duration the unit is stunned. (0 to the game constant stunTime).

Type

int

property tile

The Tile this Unit is on.

Type

games.newtonian.tile.Tile or None