Skip to content

API Game state

Alexandre 'kidev' Poumaroux edited this page Oct 21, 2026 · 4 revisions

Game state

Import from proleak import game

Read-only view of the game: players and units. Main thread only.

Classes

Class
UnitDict A unit as unit and units give it.

Functions

Returns Function
int local_player() The player slot you control (1 to 8).
UnitDict | None unit(unit_id: int) The unit with this id, or None.
list[UnitDict] units() Every unit on the map.
str version() The running game's version (gameversion.txt), such as 26.10a.
str built_for() The game version this ProLeak was built for.
Literal[True] | str available(name: str) True when an event, an action (actions.hire) or a ProLeak feature (world) runs on this game.

Function documentation

local_player

local_player() -> int

The player slot you control (1 to 8).

unit

unit(unit_id: int) -> UnitDict | None

The unit with this id, or None.

In a wave a placed fighter sends a separate unit to fight: wave_fighter is that unit for a placed fighter and placed is the placed fighter for a wave fighter; both are -1 otherwise.

units

units() -> list[UnitDict]

Every unit on the map.

version

version() -> str

The running game's version (gameversion.txt), such as 26.10a.

built_for

built_for() -> str

The game version this ProLeak was built for.

available

available(name: str) -> Literal[True] | str

True when an event, an action (actions.hire) or a ProLeak feature (world) runs on this game.

Otherwise the reason, as a string: what it depends on changed in the game, or is missing. The player can run a changed one anyway from Mods > Advanced > Game version.

UnitDict class

A unit as unit and units give it.

A plain dict with these keys.

Type Key
int id Its id.
str type Its unit type id, such as peewee_unit_id.
int owner Its owner's slot.
float x Map x position.
float z Map z position.
bool alive True while it is alive.
int placed For a wave fighter, the id of the placed fighter it fights for; else -1.
int wave_fighter For a placed fighter, the id of the unit that fights for it during a wave; else -1.

Key documentation

id

id: int

Its id.

type

type: str

Its unit type id, such as peewee_unit_id.

owner

owner: int

Its owner's slot.

x

x: float

Map x position.

z

z: float

Map z position.

alive

alive: bool

True while it is alive.

placed

placed: int

For a wave fighter, the id of the placed fighter it fights for; else -1.

wave_fighter

wave_fighter: int

For a placed fighter, the id of the unit that fights for it during a wave; else -1.


Previous: Game modes | Next: Logging

Clone this wiki locally