Unit

class games.stardash.unit.Unit

Bases: games.stardash.game_object.GameObject

The class representing the Unit in the Stardash game.

A unit in the game. May be a corvette, missleboat, martyr, transport, miner.

property acted

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

Type

bool

attack(enemy: games.stardash.unit.Unit) → bool

Attacks the specified unit.

Parameters

enemy (games.stardash.unit.Unit) – The Unit being attacked.

Returns

True if successfully attacked, False otherwise.

Return type

bool

dash(x: float, y: float) → bool

Causes the unit to dash towards the designated destination.

Parameters
  • x (float) – The x value of the destination’s coordinates.

  • y (float) – The y value of the destination’s coordinates.

Returns

True if it moved, False otherwise.

Return type

bool

property dash_x

The x value this unit is dashing to.

Type

float

property dash_y

The y value this unit is dashing to.

Type

float

property energy

The remaining health of the unit.

Type

int

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 genarium

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

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 is_busy

Tracks whether or not the ship is dashing or Mining. If True, it cannot do anything else.

Type

bool

property job

The Job this Unit has.

Type

games.stardash.job.Job

property legendarium

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

Type

int

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(body: games.stardash.body.Body) → bool

Allows a miner to mine a asteroid.

Parameters

body (games.stardash.body.Body) – The object to be mined.

Returns

True if successfully acted, False otherwise.

Return type

bool

move(x: float, y: float) → bool

Moves this Unit from its current location to the new location specified.

Parameters
  • x (float) – The x value of the destination’s coordinates.

  • y (float) – The y value of the destination’s coordinates.

Returns

True if it moved, False otherwise.

Return type

bool

property moves

The distance this unit can still move.

Type

float

property mythicite

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

Type

int

property owner

The Player that owns and can control this Unit.

Type

games.stardash.player.Player or None

property protector

The martyr ship that is currently shielding this ship if any.

Type

games.stardash.unit.Unit or None

property rarium

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

Type

int

safe(x: float, y: float) → bool

Tells you if your ship can move to that location from were it is without clipping the sun.

Parameters
  • x (float) – The x position of the location you wish to arrive.

  • y (float) – The y position of the location you wish to arrive.

Returns

True if pathable by this unit, False otherwise.

Return type

bool

property shield

The shield that a martyr ship has.

Type

int

shootdown(missile: games.stardash.projectile.Projectile) → bool

Attacks the specified projectile.

Parameters

missile (games.stardash.projectile.Projectile) – The projectile being shot down.

Returns

True if successfully attacked, False otherwise.

Return type

bool

transfer(unit: games.stardash.unit.Unit, amount: int, material: str) → bool

Grab materials from a friendly unit. Doesn’t use a action.

Parameters
  • unit (games.stardash.unit.Unit) – The unit you are grabbing the resources from.

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

  • material ('genarium', 'rarium', 'legendarium', or 'mythicite') – The material the unit will pick up. ‘genarium’, ‘rarium’, ‘legendarium’, or ‘mythicite’.

Returns

True if successfully taken, False otherwise.

Return type

bool

property x

The x value this unit is on.

Type

float

property y

The y value this unit is on.

Type

float