Port

class games.pirates.port.Port

Bases: games.pirates.game_object.GameObject

The class representing the Port in the Pirates game.

A port on a Tile.

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 gold

For players, how much more gold this Port can spend this turn. For merchants, how much gold this Port has accumulated (it will spawn a ship when the Port can afford one).

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 investment

(Merchants only) How much gold was invested into this Port. Investment determines the strength and value of the next ship.

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]

property owner

The owner of this Port, or None if owned by merchants.

Type

games.pirates.player.Player or None

spawn(type: str) → bool

Spawn a Unit on this port.

Parameters

type ('crew' or 'ship') – What type of Unit to create (‘crew’ or ‘ship’).

Returns

True if Unit was created successfully, False otherwise.

Return type

bool

property tile

The Tile this Port is on.

Type

games.pirates.tile.Tile