Skip to content

API World

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

World

Import from proleak import world

The game world as live objects: players, teams, units and areas. Read-only. Main thread only.

Classes

Class
Area A rectangle of the map, such as a player's lane.
Unit One unit on the map.
Player A player in the game.
Team A team: its players and its king.

Functions

Returns Function
list[Player] players() Every playing player.
Player | None player(slot: int | None = ...) The Player in slot, or None.
list[Team] teams() Every team.
Unit | None unit(unit_id: int) The Unit with this id now, or None.
list[Unit] units(kind: str | None = None, type: str | None = None, name: str | None = None, legion: str | None = None, tier: int | None = None, role: str | None = None, spell: str | None = None, buff: str | None = None, attack_type: str | None = None, armor_type: str | None = None, owner: Player | int | None = None, wave: bool | None = None, near: tuple[float, float, float] | None = None, where: Callable[[Unit], bool] | None = None) Every unit matching the filters.

Values

Type Value
int wave read-only The wave being played or built for; 0 outside a game.
str phase read-only "build" or "fight"; "none" outside a game.
WaveInfo | None wave_info read-only The WaveInfo of wave, or None.

Detailed description

Values are read once per frame and cached (and read again when a unit appears or dies within the frame), so loops over many units cost one read. A Unit handle follows one unit: once that unit dies or a new unit takes its id, reading it raises UnitGone.

Function documentation

players

players() -> list[Player]

Every playing player.

player

player(slot: int | None = ...) -> Player | None

The Player in slot, or None.

Without a slot, the player this client controls (None outside a game).

teams

teams() -> list[Team]

Every team.

unit

unit(unit_id: int) -> Unit | None

The Unit with this id now, or None.

units

units(kind: str | None = None, type: str | None = None, name: str | None = None, legion: str | None = None, tier: int | None = None, role: str | None = None, spell: str | None = None, buff: str | None = None, attack_type: str | None = None, armor_type: str | None = None, owner: Player | int | None = None, wave: bool | None = None, near: tuple[float, float, float] | None = None, where: Callable[[Unit], bool] | None = None) -> list[Unit]

Every unit matching the filters.

owner takes a Player or a slot; wave=True keeps this wave's units (as kind="wave"); near=(x, z, radius); where any predicate. Name-like filters ignore case and take the display name or the id.

Value documentation

wave

wave: int [read-only]

The wave being played or built for; 0 outside a game.

phase

phase: str [read-only]

"build" or "fight"; "none" outside a game.

wave_info

wave_info: WaveInfo | None [read-only]

The WaveInfo of wave, or None.

Area class

A rectangle of the map, such as a player's lane.

Type Property
str name Its name, such as lane 1.
Player | None owner The player it belongs to, or None.
Returns Method
bool contains(x: float, z: float) True when map point (x, z) is inside.
list[Unit] units(**filters) The units standing in this area; filters are those of units.

Property documentation

name

name: str

Its name, such as lane 1.

owner

owner: Player | None

The player it belongs to, or None.

Method documentation

contains

contains(x: float, z: float) -> bool

True when map point (x, z) is inside.

units

units(**filters) -> list[Unit]

The units standing in this area; filters are those of units.

Unit class

One unit on the map. Members read this frame's values.

Type Property
int id Its id; a new unit may take it once this one is gone.
bool valid read-only False once the unit died or a new unit took its id.
str type read-only The unit type id, for example peewee_unit_id.
str kind read-only fighter, wave_fighter, worker, king, mercenary, wave or other.
UnitInfo | None info read-only The UnitInfo of the unit's type.
str name read-only Display name, for example Peewee.
str legion read-only Legion name, for example Element (empty for units without one).
int tier read-only Fighter tier, 1 to 6; 0 for a unit with none.
str role read-only The game's inforole field of its type; empty when the game sets none.
str attack_type read-only Attack type, such as atk_magic.
str armor_type read-only Armor type, such as arm_heavy.
list[UnitInfo] evolves_to read-only The unit types this unit can upgrade into.
Player | None owner read-only The owning Player, or None for units no player owns (wave units, kings).
float hp read-only Health now.
float max_hp read-only Maximum health.
float mana read-only Mana now.
float max_mana read-only Maximum mana.
float x read-only Map x position.
float z read-only Map z position.
bool alive read-only True while the unit is alive.
bool hidden read-only True for a placed fighter the game hides while its wave fighter fights.
list[str] upgrades read-only Upgrade ids bought for this unit.
list[str] researches read-only Research ids that apply to this unit.
list[str] abilities read-only Extra abilities on the unit, such as the one a legion spell grants.
dict[str, int] buffs read-only {buff_type: stacks} on the unit now.
SpellInfo | None spell read-only The SpellInfo of the legion spell placed on this fighter, or None.
Unit | None target read-only The unit this one attacks, or None.
list[Unit] targeted_by read-only The units attacking this one.
Unit | None placed read-only For a wave fighter, the placed fighter it fights for; else None.
Unit | None wave_fighter read-only For a placed fighter, the unit that fights for it during a wave; else None.
Area | None area read-only The lane the unit stands in, or None.

Property documentation

id

id: int

Its id; a new unit may take it once this one is gone.

valid

valid: bool [read-only]

False once the unit died or a new unit took its id.

type

type: str [read-only]

The unit type id, for example peewee_unit_id.

kind

kind: str [read-only]

fighter, wave_fighter, worker, king, mercenary, wave or other.

info

info: UnitInfo | None [read-only]

The UnitInfo of the unit's type.

name

name: str [read-only]

Display name, for example Peewee.

legion

legion: str [read-only]

Legion name, for example Element (empty for units without one).

tier

tier: int [read-only]

Fighter tier, 1 to 6; 0 for a unit with none.

role

role: str [read-only]

The game's inforole field of its type; empty when the game sets none.

attack_type

attack_type: str [read-only]

Attack type, such as atk_magic.

armor_type

armor_type: str [read-only]

Armor type, such as arm_heavy.

evolves_to

evolves_to: list[UnitInfo] [read-only]

The unit types this unit can upgrade into.

owner

owner: Player | None [read-only]

The owning Player, or None for units no player owns (wave units, kings).

hp

hp: float [read-only]

Health now.

max_hp

max_hp: float [read-only]

Maximum health.

mana

mana: float [read-only]

Mana now.

max_mana

max_mana: float [read-only]

Maximum mana.

x

x: float [read-only]

Map x position.

z

z: float [read-only]

Map z position.

alive

alive: bool [read-only]

True while the unit is alive.

hidden

hidden: bool [read-only]

True for a placed fighter the game hides while its wave fighter fights.

upgrades

upgrades: list[str] [read-only]

Upgrade ids bought for this unit.

researches

researches: list[str] [read-only]

Research ids that apply to this unit.

abilities

abilities: list[str] [read-only]

Extra abilities on the unit, such as the one a legion spell grants.

buffs

buffs: dict[str, int] [read-only]

{buff_type: stacks} on the unit now.

spell

spell: SpellInfo | None [read-only]

The SpellInfo of the legion spell placed on this fighter, or None.

target

target: Unit | None [read-only]

The unit this one attacks, or None.

targeted_by

targeted_by: list[Unit] [read-only]

The units attacking this one.

placed

placed: Unit | None [read-only]

For a wave fighter, the placed fighter it fights for; else None.

wave_fighter

wave_fighter: Unit | None [read-only]

For a placed fighter, the unit that fights for it during a wave; else None.

area

area: Area | None [read-only]

The lane the unit stands in, or None.

Player class

A player in the game. Members read this frame's values.

Type Property
int slot Its slot, 1 to 8.
str name read-only Display name.
bool is_local read-only True for the player this client controls.
Team | None team read-only The player's Team.
list[Player] teammates read-only The other players of the team.
Player | None attacking read-only The player this one sends to.
Player | None defending read-only The player sending to this one.
int gold read-only Gold now.
int mythium read-only Mythium now.
int income read-only Income.
float workers read-only Worker count (fractional while one trains).
int food read-only Food used.
int food_cap read-only Food available.
int value read-only Fighter value.
bool connected read-only True while connected.
bool afk read-only True when marked away from keyboard.
LegionInfo | None legion read-only The LegionInfo of the chosen legion, or None.
MastermindInfo | None mastermind read-only The MastermindInfo of the playstyle, or None.
SpellInfo | None spell read-only The SpellInfo of the chosen legion spell, or None.
list[UnitInfo] rolls read-only The fighters this player can build (a Mastermind roll).
dict[str, int] king_upgrades read-only {"attack": n, "regen": n, "spell": n} levels bought.
Area lane read-only The player's lane as an Area.
Returns Method
list[Unit] units(**filters) The player's units; filters are those of units.
list[Unit] fighters(**filters) The player's placed fighters.
list[Unit] workers_units() The player's worker units.
list[UnitInfo] mercenaries_sent(wave: int | None = None) The types of the mercenaries this player sent, in one wave or in every wave.
list[UnitInfo] mercenaries_received(wave: int | None = None) The types of the mercenaries sent at this player, in one wave or in every wave.
float leaked(wave: int | None = None) Leaked percent for a wave (the current one by default).
list[Unit] selected() The units this player has selected; empty for other players (the game keeps only yours).

Property documentation

slot

slot: int

Its slot, 1 to 8.

name

name: str [read-only]

Display name.

is_local

is_local: bool [read-only]

True for the player this client controls.

team

team: Team | None [read-only]

The player's Team.

teammates

teammates: list[Player] [read-only]

The other players of the team.

attacking

attacking: Player | None [read-only]

The player this one sends to.

defending

defending: Player | None [read-only]

The player sending to this one.

gold

gold: int [read-only]

Gold now.

mythium

mythium: int [read-only]

Mythium now.

income

income: int [read-only]

Income.

workers

workers: float [read-only]

Worker count (fractional while one trains).

food

food: int [read-only]

Food used.

food_cap

food_cap: int [read-only]

Food available.

value

value: int [read-only]

Fighter value.

connected

connected: bool [read-only]

True while connected.

afk

afk: bool [read-only]

True when marked away from keyboard.

legion

legion: LegionInfo | None [read-only]

The LegionInfo of the chosen legion, or None.

mastermind

mastermind: MastermindInfo | None [read-only]

The MastermindInfo of the playstyle, or None.

spell

spell: SpellInfo | None [read-only]

The SpellInfo of the chosen legion spell, or None.

rolls

rolls: list[UnitInfo] [read-only]

The fighters this player can build (a Mastermind roll).

king_upgrades

king_upgrades: dict[str, int] [read-only]

{"attack": n, "regen": n, "spell": n} levels bought.

lane

lane: Area [read-only]

The player's lane as an Area.

Method documentation

units

units(**filters) -> list[Unit]

The player's units; filters are those of units.

fighters

fighters(**filters) -> list[Unit]

The player's placed fighters.

workers_units

workers_units() -> list[Unit]

The player's worker units.

mercenaries_sent

mercenaries_sent(wave: int | None = None) -> list[UnitInfo]

The types of the mercenaries this player sent, in one wave or in every wave.

mercenaries_received

mercenaries_received(wave: int | None = None) -> list[UnitInfo]

The types of the mercenaries sent at this player, in one wave or in every wave.

leaked

leaked(wave: int | None = None) -> float

Leaked percent for a wave (the current one by default).

selected

selected() -> list[Unit]

The units this player has selected; empty for other players (the game keeps only yours).

Team class

A team: its players and its king.

Type Property
int id Its id.
list[Player] players read-only The team's players.
Unit | None king read-only The team's king as a Unit, or None.
Returns Method
float leaked(wave: int | None = None) Sum of the players' leaked percent for a wave (the current one by default).

Property documentation

id

id: int

Its id.

players

players: list[Player] [read-only]

The team's players.

king

king: Unit | None [read-only]

The team's king as a Unit, or None.

Method documentation

leaked

leaked(wave: int | None = None) -> float

Sum of the players' leaked percent for a wave (the current one by default).


Previous: User interface | Next: Events

Clone this wiki locally