Skip to content

Castle

Castles, buildings, resources, research and the mercenary camp behind client.castle.

castle.service

Your castles: resources, buildings, the construction queue, research and the mercenary camp.

It covers:

  • Castle management (list, join, rename, abandon)
  • Resources and production
  • Buildings and the construction queue
  • Tax collection
  • Opening and closing a castle's gate (Open Gate)
  • Research and the mercenary camp's missions
  • The refinery and toolsmith crafting queues, construction item crafting and the decoration fusion forge
  • A monument's or laboratory's upgrade progress
  • The ruby wishing well

Sending goods, support and troops from a castle is on client.movements.

Actions raise CommandError when the server refuses them.

Methods that take one of your castles send its kingdom from the castle list the server sent at login (client.state.get_castles()), as the client does, and raise UnknownCastleError for an id not in it.

Building methods act on the castle joined last (CastleService.join) and name buildings by object id, a BuildingRow.object_id from join(...).buildings; upgrade_building, upgrade_defense and finish_construction take the castle and join it themselves. Their typed replies (BuildResponse and the others) can be read with client.request.

Modules:

Name Description
buildings

Buildings, the construction queue and the building lookups.

castles

Your castles: the castle list, joining a castle, resources and horses.

construction_items

Construction items: equipping, removing, disassembling and boosting them.

crafting

The crafting queues and construction item crafting.

decorations

Decoration storage and the decoration fusion forge.

economy

The brewery, private resource villages and tax.

gates

Open Gate: open a castle's gate so attackers loot it without a battle, and close it again.

mercenaries

The mercenary camp's missions.

modification

Renaming, abandoning and relocating a castle.

research

Research.

wishing_well

The ruby wishing well in your main castle: throw in rubies and a lucky penny, collect twice the rubies later.

Classes:

Name Description
CastleService

Your castles, their buildings and resources, research and the mercenary camp.

CastleService

CastleService(client: EmpireClient)

Bases: ConstructionItemsMixin, CastleModificationMixin, BuildingsMixin, CastlesMixin, DecorationsMixin, EconomyMixin, OpenGateMixin, ResearchMixin, MercenaryCampMixin, CraftingMixin, WishingWellMixin, BaseService

Your castles, their buildings and resources, research and the mercenary camp.

Reached as client.castle.

Usage
client = EmpireClient(...)
client.login()

# Get all castles
castles = client.castle.get_all()
for c in castles:
    print(f"{c.castle_name} at ({c.x}, {c.y})")

# Join a castle and read its buildings
castle = client.castle.join(castle_id=12345)

# Get resources
resources = client.castle.get_resources(castle_id=12345)

Methods:

Name Description
on_joined_area_moved

Register a callback for the castle you have joined moving on the map (ghw).

on_building_finished

Register a callback for a building in the joined castle that finished (fbe), with the

on_building_xp

Register a callback for XP a building in the joined castle gave (cbx). Runs on the

on_buildings_changed

Register a callback for buildings of the joined castle that were damaged (gdb) or

on_castle_buildings

Register a callback for the joined castle's buildings sent whole (gca), called after

get_construction_items

Request all construction items in storage, including an empty inventory.

equip_construction_item

Join a castle and equip an item, returning the server's complete placement.

remove_construction_item

Join a castle and return an equipped item to storage for its coin removal cost.

disassemble_construction_item

Disassemble stored items and resolve their drawn rewards from game data.

get_construction_item_space

Ask how many more construction items fit in storage; the reply also reaches the state.

get_construction_item_expiry

Ask when the next of your construction items expires; the reply also reaches the state.

get_expired_construction_items

Request expired items across your castles.

mark_expired_construction_items_seen

Mark a castle's expired items as viewed, as closing their list does.

move_construction_slot

Move a building in its construction queue and read the resulting queue.

boost_construction_item

Consume one selected inventory booster on a temporary equipped item.

rename

Rename one of your castles.

abandon_castle

Start abandoning one of your castles; it is given up a day later unless cancelled.

cancel_abandon

Keep a castle abandon_castle started to give up.

relocate

Move your main castle in the green kingdom to a new position.

leave_area

Leave the area you joined last, as the client does when it opens the kingdom overview.

get_build_queue

Get the joined castle's construction slots.

build

Place a new building in the joined castle.

upgrade_building

Upgrade a building in one of your castles.

move_building

Move a building in the joined castle.

move_to_district

Move a building of the joined castle into a district, such as a decoration district.

remove_from_district

Move a building out of its district onto the joined castle's grounds.

sell_decoration

Sell a decoration placed in the joined castle.

destroy_building

Start taking a building in the joined castle down.

finish_construction

Finish a building's running build or upgrade at once.

skip_construction_time

Shorten a building's running construction with a minute skip.

upgrade_defense

Upgrade a wall, gate or tower of one of your castles, by its object id.

repair_building

Repair a damaged building in the joined castle.

repair_all

Repair every damaged building in the joined castle at once, for rubies; see "Spending

buy_expansion

Buy an expansion of the joined castle's grounds, with resources (NORMAL) or rubies (PREMIUM).

open_treasure_chest

Open a treasure chest found on an expansion of the joined castle.

collect_mine

Collect what a mine in the joined castle has produced.

collect_resource_cart

Collect the joined castle's resource cart of one resource.

collect_resource_citizen

Collect what the citizen walking in the joined castle carries.

get_upgradable_buildings

Find your castles holding a building of one type that a prime sale can upgrade.

get_transportation_buildings

The main castle's buildings a castle transport to the Outer Realms takes along.

get_feast_cost_reduction

The discount on feasts, in percent.

unlocks

One of your castles' unlocked units and horses, from the last gpc that named it.

set_hunter

Set the joined castle's hunter to turn wood and stone production into food_boost more food.

judge_citizen

Give your verdict on the open citizen judgement, which ends it.

resource_cart

The cart of one resource in the last rci; None before any.

get_kingdoms

Ask for your kingdoms and the transfers to them; the reply also updates kingdoms.

get_villages

Ask for your villages and private resource villages; the reply also updates villages.

unlock_kingdom

Unlock a kingdom with one of its prebuilt castles, e.g. PrebuiltCastle.ICE_KNIGHTLY_CASTLE.

get_all

Get list of all player's castles.

get_details

Get resources and stationed units for one castle.

get_landmark_progress

A monument's or laboratory's upgrade points, asked for by its map row's object id.

select

Select/jump to a castle (makes it the active castle).

join

Join a castle, making it the active castle, and return its state.

join_area

Join an area by its position (jaa), making it the active area, and return its state.

get_resources

Get one of your castles' resources.

get_production

Get the joined castle's production area: production, storage, population and the rest.

horses

The horses one of your castles can send movements with, by wod id.

get_decoration_storages

Read the decoration storages; they also reach decoration_storages.

mark_storage_seen

Mark a storage's new decorations as seen.

store_decoration

Put a decoration of the joined castle into the storage.

sell_stored_decoration

Sell decorations from the storage for coins; they are gone for good.

place_stored_decoration

Place a custom or unique decoration from the storage in the joined castle.

get_fusion_forges

Fusion forges' level and energy; the reply also reaches fusion_forges.

level_up_fusion_forge

Level a fusion forge up for decoration dust, and return its new level.

refill_fusion_forge

Refill a fusion forge's energy for rubies, and return the energy added.

convert_catalysts

Assemble fusion catalysts, or disassemble them into decoration dust.

get_fusion_targets

Your areas with the placed decorations a fusion can target.

fuse_decoration

Fuse a stored decoration into a placed one. The stored decoration is used up.

get_brewery_production

Read one of your castles' brewery production.

set_brewery_production

Set how much of one of your castles' brewery makes mead, and the stocks at which it stops.

set_mead_priority

Give one of your castles' mead production priority, or take it away.

buy_private_village

Buy a private resource village with resource village tokens.

upgrade_private_village

Upgrade one of your private resource villages to the next level, with resource village tokens.

remove_private_village

Remove one of your private resource villages; it is gone for good, its tokens are not returned.

get_tax_info

Read the tax collection status.

start_tax

Start a tax collection.

collect_tax

Collect the tax.

bribe_tax_collector

Bribe the tax collector, a tax booster bought with rubies; see "Spending rubies" in the guides.

open_gate_quote

What opening one of your castles' gate would cost now, and whether the client offers it; nothing is sent.

open_gate

Buy an Open Gate for one of your castles: attackers loot it without a battle, so its buildings

close_gate

Close one of your castles' open gate; nothing is refunded.

get_research

Read your research; the reply also reaches research.

start_research

Start a research, paying what it costs.

skip_research

Shorten the running research with a minute skip from your inventory.

finish_research

Finish the running research now, for rubies; see "Spending rubies" in the guides.

list_missions

The mercenary camp's missions, and when new ones come.

start_mission

Start an open mercenary mission, paying its price in coins.

collect_mission

Collect a finished mercenary mission's rewards.

refresh_mission

Swap an open mercenary mission for another, for REFRESH_MISSION_COST (240) rubies; see

get_crafting_queues

The crafting queues of the refinery and toolsmith in every castle, as the crafting dialog asks for them.

start_crafting

Start a recipe in a crafting queue, paying its costs.

cancel_crafting

Cancel the craft in one slot of a crafting queue.

move_crafting_slot

Move a waiting craft to another waiting slot.

skip_crafting

Finish the craft in one slot for rubies.

unlock_crafting_slot

Unlock a temporary slot of a crafting queue for coins.

get_construction_crafting

The construction item being crafted and the time left; both None while nothing is crafted.

craft_construction_item

Craft a construction item from a recipe, paying its costs; one craft runs at a time.

skip_construction_crafting_time

Shorten the running construction item craft with a minute skip.

finish_construction_crafting

Finish the running construction item craft for rubies.

get_wishing_well

Read the wishing well's level and time from the server; its reply also updates wishing_well.

start_wishing_well

Start the wishing well: it takes its level's entry rubies and lucky pennies, and gives twice the rubies

finish_wishing_well

Finish the running wishing well now, for rubies; see "Spending rubies" in the guides. Whether the

collect_wishing_well

Collect the rubies of a finished wishing well.

upgrade_wishing_well

Upgrade the wishing well to its next level, for the wood and stone that level costs.

Attributes:

Name Type Description
construction_items ConstructionItemInventory | None

The last construction inventory received; None before the first inventory reply.

placed_construction_items tuple[BuildingConstructionItems, ...] | None

Items on the joined castle's buildings; None before joining or after the area is lost or relocated.

construction_item_space ConstructionItemSpace | None

Free construction storage capacity, from the last inventory or capacity push.

expired_construction_items ExpiredConstructionItemsResponse | None

The last complete list of expired items; None before a successful read.

construction_list ConstructionList | None

The joined castle's construction slots, as the last join, push or building reply left them; None before

buildings dict[int, PlacedBuilding] | None

The joined castle's placed objects by object id, kept current by the server's pushes and the building

castles list[Castle]

A snapshot of the player's castles.

hunter HunterInfo | None

The hunter's food boost, from the last hin or castle join that carried it; None until one did.

judgement_id Judgement | int | None

The open citizen judgement, from the last sjc; None while none is open.

joined_area JoinedArea | None

The area joined, with its slum level and builder discount; None before any join.

session_location SessionLocation | None

See GameState.get_session_location.

is_on_map bool

See GameState.is_on_map.

is_in_own_castle bool

See GameState.is_in_own_castle.

is_in_spectated_castle bool

See GameState.is_in_spectated_castle.

is_in_occupied_castle bool

See GameState.is_in_occupied_castle.

mines dict[int, MineStatus]

The joined castle's mines by object id, as the last gsm sent them.

resource_carts list[ResourceCart]

The joined castle's resource carts, wood, stone and food, as the last rci sent them.

laboratories LaboratoryListResponse | None

Your laboratories, from the last gll; None until one arrived.

laboratory_reset LaboratoryResetResponse | None

When the laboratories reset next, from the last lrr that counted down; None until one arrived.

royal_towers RoyalTowerListResponse | None

Your royal towers, from the last gkl; None until one arrived.

monuments MonumentListResponse | None

Your monuments, from the last gml; None until one arrived.

monument_reset MonumentResetResponse | None

When the monuments reset next, from the last mre that counted down; None until one arrived.

villages VillageListResponse | None

Your villages and private resource villages, from the last kgv; None until one arrived.

tax TaxInfo | None

The tax collection, from the last txi; None until one arrived.

kingdoms KingdomInfoResponse | None

Your kingdoms and the transfers to them; None until a kpi arrived.

construction_item_expiry ConstructionItemExpiryResponse | None

When the next construction item expires, from the last nec; None until one arrived.

resource_pool ResourcePoolResponse | None

What the citizen in your castle carries, from the last irc push; None until one arrived.

wishing_well WishingWellResponse | None

The ruby wishing well, from the last rww; None until one arrived.

research ResearchInfoResponse

Your finished and running research, from the last rei.

mercenary_missions MercenaryMissionsResponse | None

The mercenary camp's missions, from the last mpe; None until one arrived.

decoration_storages dict[int, DecorationStorage]

The decoration storages by storage id, from the last sin that named each; empty until one arrived.

fusion_forges dict[FusionForgeId | int, FusionForge] | None

The fusion forges by id, as the last ffi left them; None until one arrived.

crafting_queues tuple[CraftingQueue, ...] | None

Every crafting queue known, as the last crin or crafting action left it; None until one arrived.

construction_items property

construction_items: ConstructionItemInventory | None

The last construction inventory received; None before the first inventory reply.

placed_construction_items property

placed_construction_items: tuple[BuildingConstructionItems, ...] | None

Items on the joined castle's buildings; None before joining or after the area is lost or relocated.

construction_item_space property

construction_item_space: ConstructionItemSpace | None

Free construction storage capacity, from the last inventory or capacity push.

expired_construction_items property

expired_construction_items: ExpiredConstructionItemsResponse | None

The last complete list of expired items; None before a successful read.

construction_list property

construction_list: ConstructionList | None

The joined castle's construction slots, as the last join, push or building reply left them; None before a join, after the area is lost or relocated, or when the join sent none.

buildings property

buildings: dict[int, PlacedBuilding] | None

The joined castle's placed objects by object id, kept current by the server's pushes and the building replies; None before a join and after the area is lost or relocated.

castles property

castles: list[Castle]

A snapshot of the player's castles.

hunter property

hunter: HunterInfo | None

The hunter's food boost, from the last hin or castle join that carried it; None until one did.

judgement_id property

judgement_id: Judgement | int | None

The open citizen judgement, from the last sjc; None while none is open.

joined_area property

joined_area: JoinedArea | None

The area joined, with its slum level and builder discount; None before any join.

session_location property

session_location: SessionLocation | None

See GameState.get_session_location.

is_on_map property

is_on_map: bool

See GameState.is_on_map.

is_in_own_castle property

is_in_own_castle: bool

See GameState.is_in_own_castle.

is_in_spectated_castle property

is_in_spectated_castle: bool

See GameState.is_in_spectated_castle.

is_in_occupied_castle property

is_in_occupied_castle: bool

See GameState.is_in_occupied_castle.

mines property

mines: dict[int, MineStatus]

The joined castle's mines by object id, as the last gsm sent them.

resource_carts property

resource_carts: list[ResourceCart]

The joined castle's resource carts, wood, stone and food, as the last rci sent them.

laboratories property

laboratories: LaboratoryListResponse | None

Your laboratories, from the last gll; None until one arrived.

laboratory_reset property

laboratory_reset: LaboratoryResetResponse | None

When the laboratories reset next, from the last lrr that counted down; None until one arrived.

royal_towers property

royal_towers: RoyalTowerListResponse | None

Your royal towers, from the last gkl; None until one arrived.

monuments property

monuments: MonumentListResponse | None

Your monuments, from the last gml; None until one arrived.

monument_reset property

monument_reset: MonumentResetResponse | None

When the monuments reset next, from the last mre that counted down; None until one arrived.

villages property

villages: VillageListResponse | None

Your villages and private resource villages, from the last kgv; None until one arrived.

tax property

tax: TaxInfo | None

The tax collection, from the last txi; None until one arrived.

kingdoms property

kingdoms: KingdomInfoResponse | None

Your kingdoms and the transfers to them; None until a kpi arrived.

construction_item_expiry property

construction_item_expiry: ConstructionItemExpiryResponse | None

When the next construction item expires, from the last nec; None until one arrived.

resource_pool property

resource_pool: ResourcePoolResponse | None

What the citizen in your castle carries, from the last irc push; None until one arrived.

wishing_well property

wishing_well: WishingWellResponse | None

The ruby wishing well, from the last rww; None until one arrived.

research property

Your finished and running research, from the last rei.

Raises:

Type Description
StateNotLoadedError

No login has brought it

mercenary_missions property

mercenary_missions: MercenaryMissionsResponse | None

The mercenary camp's missions, from the last mpe; None until one arrived.

decoration_storages property

decoration_storages: dict[int, DecorationStorage]

The decoration storages by storage id, from the last sin that named each; empty until one arrived.

fusion_forges property

fusion_forges: dict[FusionForgeId | int, FusionForge] | None

The fusion forges by id, as the last ffi left them; None until one arrived.

crafting_queues property

crafting_queues: tuple[CraftingQueue, ...] | None

Every crafting queue known, as the last crin or crafting action left it; None until one arrived.

Each has every slot of its game-data row (CraftingQueue.with_definition).

Raises:

Type Description
GameDataNotLoadedError

The game data cannot be loaded

on_joined_area_moved

on_joined_area_moved(callback: Callable[[JoinedAreaMoved], object]) -> None

Register a callback for the castle you have joined moving on the map (ghw).

Called with its new position, after joined_area has it, and also when no area is joined, which the push leaves alone. Callbacks run on the receive thread: they must not block, and a call that waits for a reply raises ReceiveThreadError.

Client: GHWCommand.executeCommand (bundle line 129574)

Unregister a callback with on_joined_area_moved.remove(callback).

on_building_finished

on_building_finished(callback: Callable[[BuildingFinished], object]) -> None

Register a callback for a building in the joined castle that finished (fbe), with the building's object id and the XP it gave. Runs on the receive thread, as on_joined_area_moved.

Client: FBECommand.exec (bundle line 122879), AreaDataUpdater.parseCBX (bundle line 131521)

Unregister a callback with on_building_finished.remove(callback).

on_building_xp

on_building_xp(callback: Callable[[BuildingXP], object]) -> None

Register a callback for XP a building in the joined castle gave (cbx). Runs on the receive thread, as on_joined_area_moved.

Client: CBXCommand.executeCommand (bundle line 123345)

Unregister a callback with on_building_xp.remove(callback).

on_buildings_changed

on_buildings_changed(callback: Callable[[DamagedBuildings], object]) -> None

Register a callback for buildings of the joined castle that were damaged (gdb) or whose efficiency changed (gcb, a BuildingEfficiencyChanged), with their new rows, after buildings has them. The building replies and the ego push change buildings too, without this callback. Runs on the receive thread, as on_joined_area_moved.

Client: GDBCommand and GCBCommand (bundle lines 122998, 122968), IsoUpdaterData.updateMultipleObjectInfos (bundle line 130259)

Unregister a callback with on_buildings_changed.remove(callback).

on_castle_buildings

on_castle_buildings(callback: Callable[[CastleBuildingsPushed], object]) -> None

Register a callback for the joined castle's buildings sent whole (gca), called after get_placed_construction_items has the construction items they carry; not called while no castle is joined. Runs on the receive thread, as on_joined_area_moved.

Client: GCACommand.executeCommand (bundle line 122991)

Unregister a callback with on_castle_buildings.remove(callback).

get_construction_items

get_construction_items(*, timeout: float = 5.0) -> ConstructionItemInventory

Request all construction items in storage, including an empty inventory.

Client: C2SGetContructionItemsInventoryVO and GIICommand (bundle lines 28546, 123270).

equip_construction_item

equip_construction_item(castle_id: int, object_id: int, construction_item_id: ConstructionItem | int, slot: int, *, mode: ConstructionItemMode = ADD, timeout: float = 5.0) -> EquipConstructionItemResponse

Join a castle and equip an item, returning the server's complete placement.

ADD fills an empty slot. REPLACE keeps the old item for its coin removal cost; OVERWRITE discards it. A failed inventory refresh is logged and leaves construction_items unknown after the accepted placement.

Client: AConstructionItemsActionDialog.sendReplaceCommand (bundle 28680), CastleConstructionItemsOverwriteDialog (bundle 79306-79307).

remove_construction_item

remove_construction_item(castle_id: int, object_id: int, construction_item_id: ConstructionItem | int, slot: int, *, timeout: float = 5.0) -> RemoveConstructionItemResponse

Join a castle and return an equipped item to storage for its coin removal cost.

Refusals and transport failures propagate. A failed inventory refresh is logged and leaves construction_items unknown after the accepted removal.

Client: CastleConstructionItemsExtractDialog.onClickAccept (bundle 79277), CRICommand.executeCommand (bundle 123255-123256).

disassemble_construction_item

disassemble_construction_item(castle_id: int, construction_item_id: ConstructionItem | int, *, amount: int = 1, lost_and_found_id: int = -1, timeout: float = 5.0) -> DisassembleConstructionItemResponse

Disassemble stored items and resolve their drawn rewards from game data.

Items are consumed. lost_and_found_id=-1 selects storage. The reply exposes the drawn reward ids and their collectables; permanent items' recipe materials are not listed by the server. A failed inventory refresh is logged and leaves construction_items unknown after success.

Client: C2SDisassembleConstructionItemVO (bundle 79223-79227), onClickAccept / onDCIArrived (bundle 35727-35729), showTempCIDisassembling (bundle 48984).

get_construction_item_space

get_construction_item_space(*, timeout: float = 5.0) -> ConstructionItemSpace

Ask how many more construction items fit in storage; the reply also reaches the state.

Client: C2SConstructionItemInventorySpaceLeftVO (bundle line 41293), CSPCommand.exec (bundle line 123855)

get_construction_item_expiry

get_construction_item_expiry(*, timeout: float = 5.0) -> ConstructionItemExpiryResponse

Ask when the next of your construction items expires; the reply also reaches the state.

Client: ConstructionItemData.onCIExpiration (bundle line 22993) sends C2SGetNextExpiringConstructionItemVO; NECCommand.executeCommand (bundle line 123336)

get_expired_construction_items

get_expired_construction_items(*, timeout: float = 5.0) -> ExpiredConstructionItemsResponse

Request expired items across your castles.

Client: C2SGetAllExpiredConstructionItemsVO / AECCommand (bundle 79379 / 123264).

mark_expired_construction_items_seen

mark_expired_construction_items_seen(castle_id: int, *, timeout: float = 5.0) -> MarkExpiredConstructionItemsSeenResponse

Mark a castle's expired items as viewed, as closing their list does.

This acknowledgement does not remove expired records from the cached list. Client: assign sublayer hide / switchCastle (bundle 77574 / 77583), MECCommand (123308).

move_construction_slot

move_construction_slot(castle_id: int, old_position: int, new_position: int, *, timeout: float = 5.0) -> ConstructionList

Move a building in its construction queue and read the resulting queue.

Both positions must contain a building. The move acknowledgement carries no queue; a failed follow-up read propagates after the accepted move. Client: CastleBuildingListComponent (bundle 108280-108281), MCICommand (123383).

boost_construction_item

boost_construction_item(castle_id: int, object_id: int, construction_item_id: ConstructionItem | int, slot: int, *, consumable: CurrencyId, timeout: float = 5.0) -> BoostConstructionItemResponse

Consume one selected inventory booster on a temporary equipped item.

Select currency id 2000 (rare), 2001 (epic) or 2002 (legendary). The item must still have time remaining and the selected booster must improve its rarity. Client: updateBoosterButton / boostConstructionItem (bundle 77588-77591 / 77624-77625), ConstructionItemConst (dll 18989). This command has no ruby purchase branch.

rename

rename(castle_id: int, new_name: str, *, is_initial_name: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> None

Rename one of your castles.

Looks the castle up in the castle list for the type and kingdom the server needs, so this costs one extra round trip. Pass is_initial_name=True to name a newly acquired castle, such as a monument or laboratory, instead of renaming one. A rename costs PlayerConst.CHANGE_CASTLE_NAME_C2 (2500) rubies unless a premium account runs; see "Spending rubies" in the guides.

Parameters:

Name Type Description Default
castle_id int

One of your castles, from client.castle.get_all() (CastleInfo.castle_id)

required
new_name str

The new name

required
is_initial_name bool

Name a newly acquired castle instead of renaming one, which is free

False
spend_rubies bool

Allow a rename while no premium account is known to run

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

A rename, no premium account is known to run, and spend_rubies is False

UnknownCastleError

castle_id is not one of your castles.

Client: CastleRenameCastleDialog.showLoaded and sendCommand (bundle lines 57219, 57231) price a rename, sent with 1; CastleNameCastleDialog.sendCommand (bundle line 32589) sends the first name with 0 and shows no price; CHANGE_CASTLE_NAME_C2 (dll line 19599)

Example
client.castle.rename(12345, "My Fortress", spend_rubies=True)

abandon_castle

abandon_castle(castle_id: int, *, timeout: float = 5.0) -> AbandonCastleResponse

Start abandoning one of your castles; it is given up a day later unless cancelled.

Looks the castle up in the castle list for its kingdom, as rename does. Any castle may be abandoned but the kingdom's main castle; a Battle for Berimond main camp, which the client also counts as one, is left to the server. It is free. The castle goes after OutpostConst.ABANDON_TIME (86400 s) and cancel_abandon keeps it within ABANDON_CANCEL_TIME (10800 s).

Parameters:

Name Type Description Default
castle_id int

One of your castles, from client.castle.get_all() (CastleInfo.castle_id)

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

castle_id is the main castle of its kingdom

UnknownCastleError

castle_id is not one of your castles.

CommandError

The server refused, as for a castle held too briefly (CastleInfo.no_abandon_seconds above 0), which the client refuses itself with NOT_OWNED_LONG_ENOUGH

Client: CastleManagementDialog.setDeleteOutpostAndRelocateButton (bundle line 24592) offers it for any castle but CastleListVO.getMainCastleByKingdomID (bundle line 13864), the kingdom's castle of type CASTLE or KINGDOM_CASTLE; onAbandonOutpost (bundle line 24630) sends C2SAbandonOutpostStartVO; OutpostConst (dll line 19530)

Example
reply = client.castle.abandon_castle(12345)
print(f"Abandoned in {reply.abandon_seconds} s")

cancel_abandon

cancel_abandon(castle_id: int, *, timeout: float = 5.0) -> None

Keep a castle abandon_castle started to give up.

Looks the castle up in the castle list for its kingdom. The client offers it while CastleInfo.cancel_abandon_seconds is above 0.

Parameters:

Name Type Description Default
castle_id int

One of your castles, from client.castle.get_all() (CastleInfo.castle_id)

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

castle_id is not one of your castles.

CommandError

The server refused.

Client: CastleManagementDialog.onDeleteOutpostClick and onCancelAbandoning (bundle lines 24624, 24629) send C2SAbandonOutpostCancelVO

Example
client.castle.cancel_abandon(12345)

relocate

relocate(x: int, y: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Move your main castle in the green kingdom to a new position.

The client offers it on the green kingdom's map, at a free position or a ruin. The first relocation is free; the next cost RelocationConst.RELOCATION_COST_C2 (5000, 20000, then 35000 rubies each), less any ruby discount, and need spend_rubies, as does any relocation while no gri has said how many were made. The cooldown (client.player.relocation) is left to the server.

Parameters:

Name Type Description Default
x int

Map x of the new position

required
y int

Map y of the new position

required
spend_rubies bool

Allow a relocation that costs rubies

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The relocation costs rubies, or its price is not known, and spend_rubies is False

CommandError

The server refused, as with CASTLE_HAS_MOVEMENTS while armies are on the way

Client: CastleRelocateDialog.getCost and onClick (bundle line 109656), SwitchToRelocateWorldmapCommand.execute (bundle line 100959), RSTCommand.executeCommand (bundle line 126855); RelocationConst.getRelocationCost (dll line 19674)

leave_area

leave_area() -> None

Leave the area you joined last, as the client does when it opens the kingdom overview.

The client has no handler for a reply, so none is waited for.

Client: CastleKingdomOverviewScreen.show (bundle line 108518) sends C2SLeaveAreaVO

get_build_queue

get_build_queue(*, timeout: float = 5.0) -> ConstructionList

Get the joined castle's construction slots.

Example
queue = client.castle.get_build_queue()
print(queue.building_object_ids, queue.free_slots)

build

build(wod_id: Building, x: int, y: int, rotation: int = 0, *, spend_rubies: bool = False, private_offer_id: int = -1, district_object_id: int = -1, timeout: float = 5.0) -> None

Place a new building in the joined castle.

Spends rubies when the building has a ruby price (BuildingDef.rubies_to_build at your level), and with spend_rubies on missing resources; see "Spending rubies" in the guides.

Parameters:

Name Type Description Default
wod_id Building

The building type

required
x int

Castle grid x, -1 when placing into a district

required
y int

Castle grid y, -1 when placing into a district

required
rotation int

Rotation

0
spend_rubies bool

Allow a ruby price, and pay the missing resources with rubies

False
private_offer_id int

The private offer the purchase uses, -1 for none

-1
district_object_id int

Object id of the district to place into, -1 for none

-1
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building has a ruby price, or is not in the game data, and spend_rubies is False

GameDataNotLoadedError

spend_rubies is False and the game data cannot be loaded

Client: IsoServerCommands.buyObjectFromShop (bundle line 63766); ABasicBuildingVO.costC2 (bundle lines 17950-17953)

upgrade_building

upgrade_building(castle_id: int, object_id: int, *, spend_rubies: bool = False, private_offer_id: int = -1, timeout: float = 5.0) -> None

Upgrade a building in one of your castles.

Joins the castle first, as the client is inside it, and prices the building from the join's reply: the level it upgrades to, by BuildingDef.rubies_to_build at your level, needs spend_rubies when it has a ruby price; see "Spending rubies" in the guides. spend_rubies also pays missing resources with rubies.

A ruby wishing well is upgraded as upgrade_wishing_well does, without private_offer_id.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
object_id int

The building's object id

required
spend_rubies bool

Allow a ruby price, and pay the missing resources with rubies

False
private_offer_id int

The prime sale offer the upgrade uses, -1 for none

-1
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The next level has a ruby price, or the building or its next level is not known, and spend_rubies is False

GameDataNotLoadedError

spend_rubies is False and the game data cannot be loaded

UnknownCastleError / CommandError

see join

Client: RingMenuButtonUpgradeBuilding.onClick (bundle line 50092), IsoServerCommands.upgradeBuilding (split.js line 328747), which sends rww for a wishing well; the price is the next level's costC2, BuildingCostHelper.getUpgradeCostList (bundle lines 41106-41116) through AShopVO.getCost (bundle line 31766) and ABasicBuildingVO.costC2 (bundle lines 17950-17953)

move_building

move_building(object_id: int, x: int, y: int, rotation: int = 0, *, timeout: float = 5.0) -> None

Move a building in the joined castle.

move_to_district

move_to_district(object_id: int, district_object_id: int, *, timeout: float = 5.0) -> BuildingRow | None

Move a building of the joined castle into a district, such as a decoration district.

Returns:

Type Description
BuildingRow | None

The building's row as it now stands; None when the reply has none

Client: C2SMoveToDistrictVO (bundle line 41105), MDECommand.executeCommand (bundle line 123166)

remove_from_district

remove_from_district(object_id: int, x: int, y: int, rotation: int = 0, *, timeout: float = 5.0) -> BuildingRow | None

Move a building out of its district onto the joined castle's grounds.

move_building moves a building that is in no district.

Returns:

Type Description
BuildingRow | None

The building's row as it now stands; None when the reply has none

Client: IsoServerCommands.moveObject (bundle line 63799) sends C2SRemoveFromDistrictVO for a building in a district; RDECommand.executeCommand (bundle line 123249)

sell_decoration

sell_decoration(object_id: int, *, timeout: float = 5.0) -> None

Sell a decoration placed in the joined castle.

destroy_building

destroy_building(object_id: int, *, timeout: float = 5.0) -> None

Start taking a building in the joined castle down.

finish_construction

finish_construction(castle_id: int, object_id: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Finish a building's running build or upgrade at once.

Joins the castle first, as the client is inside it, and works out the time left from the join's reply as the client does. With at most FREE_SKIP_TIME (240) seconds left it finishes for free, sent as a free skip; with more left, or the time left not known (a repair or tear-down, an unknown building or player level), it costs rubies; see "Spending rubies" in the guides. A subscription that lengthens the free time is not checked.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
object_id int

The building's object id

required
spend_rubies bool

Allow finishing a construction that costs rubies

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

More than 240 seconds are left, or the time left is not known, and spend_rubies is False

GameDataNotLoadedError

the game data cannot be loaded

UnknownCastleError / CommandError

see join

Client: IsoServerCommands.fastCompleteBuilding (bundle line 63773) sends FS 1 when CastleSpecialEventData.hasSkipForFree (bundle line 139853), which calculateSkipCosts (bundle line 139849) decides from getTimeLeftForBuilding (bundle line 17967); FREE_SKIP_TIME (dll line 18962)

skip_construction_time

skip_construction_time(object_id: int, minute_skip: Currency | str, *, timeout: float = 5.0) -> None

Shorten a building's running construction with a minute skip.

Parameters:

Name Type Description Default
object_id int

The building's object id

required
minute_skip Currency | str

The minute skip to use, Currency.SKIP_1_MINUTE to SKIP_24_HOURS; its key ("MS1") also works, for a skip newer than the generated enum

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

minute_skip is no minute skip, or the special currencies hold none of it

Client: BuildingMinuteSkipProperties.getMinuteSkipCommand (bundle line 50021), CastleMinuteSkipDialog.showLoaded (bundle line 7671)

upgrade_defense

upgrade_defense(castle_id: int, object_id: int, *, spend_rubies: bool = False, private_offer_id: int = -1, timeout: float = 5.0) -> None

Upgrade a wall, gate or tower of one of your castles, by its object id.

Joins the castle first, as the client is inside it, and prices the building from the join's reply: the level it upgrades to, by BuildingDef.rubies_to_build at your level, needs spend_rubies when it has a ruby price; see "Spending rubies" in the guides. spend_rubies also pays missing resources with rubies.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
object_id int

The wall's, gate's or tower's object id

required
spend_rubies bool

Allow a ruby price, and pay the missing resources with rubies

False
private_offer_id int

The private offer the upgrade uses, -1 for none

-1
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The next level has a ruby price, or the object or its next level is not known, and spend_rubies is False

GameDataNotLoadedError

spend_rubies is False and the game data cannot be loaded

UnknownCastleError / CommandError

see join

Client: C2SIsoUpgradeDefenceVO, sent with PWR 1 by CastleResourceWaitDialogProperties.getResourceSkipCommand (bundle line 35220); the price as for upgrade_building

repair_building

repair_building(object_id: int, *, spend_rubies: bool = False, private_offer_id: int = -1, timeout: float = 5.0) -> None

Repair a damaged building in the joined castle.

Parameters:

Name Type Description Default
object_id int

The building's object id

required
spend_rubies bool

Pay the missing resources with rubies; see "Spending rubies" in the guides

False
private_offer_id int

The private offer the repair uses, -1 for none

-1
timeout float

Timeout in seconds

5.0

Client: IsoServerCommands.repairBuilding (bundle line 63770); with rubies, CastleResourceWaitDialogProperties.getResourceSkipCommand (bundle line 35221)

repair_all

repair_all(*, spend_rubies: bool = False, timeout: float = 5.0) -> None

Repair every damaged building in the joined castle at once, for rubies; see "Spending rubies" in the guides.

The price follows the damage's total repair time and is not worked out here, so this always needs spend_rubies.

Parameters:

Name Type Description Default
spend_rubies bool

Allow the rubies it costs; without it nothing is sent

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

spend_rubies is False

Client: CastleRepairTipDialog (bundle lines 97414, 97430) prices it with AreaData.getTotalRepairCostC2 (bundle line 131460), ConstructionConst.getRepairAllCostsC2 (dll lines 18966-18969)

buy_expansion

buy_expansion(x: int, y: int, rotation: int = 0, expansion_type: ExpansionType = NORMAL, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Buy an expansion of the joined castle's grounds, with resources (NORMAL) or rubies (PREMIUM).

Parameters:

Name Type Description Default
x int

Castle grid x of the expansion

required
y int

Castle grid y of the expansion

required
rotation int

Rotation

0
expansion_type ExpansionType

NORMAL or PREMIUM; PREMIUM costs rubies, see "Spending rubies" in the guides

NORMAL
spend_rubies bool

Allow a PREMIUM expansion

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

expansion_type is PREMIUM and spend_rubies is False

Client: CastleExpansionVE (bundle line 86849) needs userHasC2ForBuy for a premium expansion before sendBuyRequestToServer (bundle line 86854)

open_treasure_chest

open_treasure_chest(object_id: int, *, timeout: float = 5.0) -> None

Open a treasure chest found on an expansion of the joined castle.

collect_mine

collect_mine(object_id: int, *, timeout: float = 5.0) -> None

Collect what a mine in the joined castle has produced.

collect_resource_cart

collect_resource_cart(cart_type: ResourceCartType, *, timeout: float = 5.0) -> None

Collect the joined castle's resource cart of one resource.

collect_resource_citizen

collect_resource_citizen(*, timeout: float = 5.0) -> ResourcePoolResponse

Collect what the citizen walking in the joined castle carries.

Returns:

Type Description
ResourcePoolResponse

The irc reply, which also reaches resource_pool

Client: IsoServerCommands.collectResourcePool (bundle line 63801) sends C2SIsoResourceCitizenVO; IRCCommand.executeCommand (bundle line 123132)

get_upgradable_buildings

get_upgradable_buildings(wod_id: Building, *, prime_sale_upgrade: bool = True, timeout: float = 5.0) -> ShowUpgradableBuildingsResponse

Find your castles holding a building of one type that a prime sale can upgrade.

Parameters:

Name Type Description Default
wod_id Building

The building type the sale is for

required
prime_sale_upgrade bool

The sale discounts the upgrade of every level, as the client sends by default

True

Client: CastlePrimeSaleDialog.onOkButton (bundle line 37771) sends C2SShowMeUpgradeBuildingsVO; SUBCommand.executeCommand (bundle line 129862)

get_transportation_buildings

get_transportation_buildings(*, timeout: float = 5.0) -> list[TransportationBuilding]

The main castle's buildings a castle transport to the Outer Realms takes along.

Client: CastleSpecialServerPreBuildCastleSelectionDialog.showLoaded (bundle line 27960) sends C2SGetCastleTransportationBuildingsVO; GCTBCommand.executeCommand (bundle line 128860)

get_feast_cost_reduction

get_feast_cost_reduction(*, timeout: float = 5.0) -> int | float

The discount on feasts, in percent.

Client: CastleFestivalDialog.showLoaded (bundle line 65030) sends C2SGetFeastCostReductionVO; CastleFestivalDialog.onFCEArrived (bundle line 65044) reads FRM

unlocks

unlocks(castle_id: int) -> PermanentCastle | None

One of your castles' unlocked units and horses, from the last gpc that named it.

set_hunter

set_hunter(food_boost: int, *, timeout: float = 5.0) -> HunterInfo

Set the joined castle's hunter to turn wood and stone production into food_boost more food.

Raises:

Type Description
CommandError

The server refused, e.g. a boost above the hunter's maximum

Client: CastleHunterDialog.onClick (bundle line 51530) sends C2SHunterInfoVO with a value from 0 to the hunter building's hunterMax; HINCommand.executeCommand (bundle line 124591)

judge_citizen

judge_citizen(option: JudgementOption, *, timeout: float = 5.0) -> None

Give your verdict on the open citizen judgement, which ends it.

Raises:

Type Description
CommandError

The server refused, e.g. no judgement is open or the verdict's requirements are unmet

Client: CastleJudgementChooseOptionDialog.onClick (bundle lines 95550-95552), JJCCommand.executeCommand (bundle line 124666)

resource_cart

resource_cart(cart_type: ResourceCartType) -> ResourceCart | None

The cart of one resource in the last rci; None before any.

get_kingdoms

get_kingdoms(*, timeout: float = 5.0) -> KingdomInfoResponse

Ask for your kingdoms and the transfers to them; the reply also updates kingdoms.

It lists the kingdoms the server sends, which kingdoms merges over those known.

Client: CastleHandleKingdomDialog.showLoaded (bundle line 55406) sends C2SKingdomPayInfoVO

get_villages

get_villages(*, timeout: float = 5.0) -> VillageListResponse

Ask for your villages and private resource villages; the reply also updates villages.

Client: CastleListVillagesOverviewDialog.getData (bundle line 108009) sends C2SKingdomGetVillageListVO

unlock_kingdom

unlock_kingdom(castle: PrebuiltCastle, direction: KingdomDirection | None = None, *, ruby_price: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> None

Unlock a kingdom with one of its prebuilt castles, e.g. PrebuiltCastle.ICE_KNIGHTLY_CASTLE.

The castle names its kingdom and price. One whose only price is rubies is bought with them; one priced in resources is bought with those, or with ruby_price at its ruby price, as the client's two buttons offer. Rubies spent need spend_rubies; buying with resources, spend_rubies pays any missing ones with rubies. A Storm Islands castle is priced by the islands' castle selection alone and asks for no level.

Parameters:

Name Type Description Default
castle PrebuiltCastle

The prebuilt castle

required
direction KingdomDirection | None

The side of the map to place the castle on; None for the Storm Islands, which take none

None
ruby_price bool

Buy the castle at its ruby price

False
spend_rubies bool

Allow spending rubies

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The castle starts no kingdom (Battle for Berimond's camps join with client.events.join_berimond, season camps unlock with client.events.unlock_season_camp, special-server castles with client.events.select_special_server_castle), needs a higher level, has no direction outside the Storm Islands or one on them, has no ruby price for ruby_price, or costs rubies without spend_rubies

GameDataNotLoadedError

The game data cannot be loaded

StateNotLoadedError

Outside the Storm Islands, no login has brought your level

CommandError

The server refused

Client: AUnlockPrebuiltCastle.buyPrebuiltCastle (bundle line 55479) sends the castle's first space and asks the direction (CastleKingdomChooseLocalizationDialog), offering only a castle your level reaches (PrebuiltCastleSelector.validateSelection, bundle line 54604); UnlockPrebuiltCastleForRubies (bundle line 55514) sets OC2 for the castle CastleKingdomCastleDetails.getSublayerForCastle (bundle line 97911) shows as premium; the Storm Islands castle selection, which checks no level, always sends a direction of 0 and OC2 when its costs hold rubies (CastleSpecialServerPreBuildCastleSelectionDialog.onConfirmed, bundle line 27956); CastleResourceWaitDialogProperties.getResourceSkipCommand (bundle line 35239) sends PWR

get_all

get_all(*, timeout: float = 5.0) -> list[CastleInfo]

Get list of all player's castles.

Sends the logged-in player's id, as the client does, once the state knows it.

Example
castles = client.castle.get_all()
for c in castles:
    print(f"{c.castle_name} (ID: {c.castle_id}) at ({c.x}, {c.y})")

get_details

get_details(castle_id: int, *, timeout: float = 5.0) -> DetailedCastleInfo

Get resources and stationed units for one castle.

The server answers with every castle of yours; the one asked for is picked out here.

Parameters:

Name Type Description Default
castle_id int

One of your castles, from client.castle.get_all() (CastleInfo.castle_id) or client.state.get_castles() (Castle.id)

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

The reply lists no castle with that id

Example
details = client.castle.get_details(12345)
print(f"Wood: {details.wood}, units: {details.units}")

get_landmark_progress

get_landmark_progress(landmark: MapAreaItem, *, timeout: float = 5.0) -> LandmarkProgress

A monument's or laboratory's upgrade points, asked for by its map row's object id.

A laboratory is asked with glp, a monument with gmp, as their upgrade dialogs ask.

Parameters:

Name Type Description Default
landmark MapAreaItem

The landmark's map row, e.g. from client.map.scan_map_area

required

Raises:

Type Description
ValueError

The row is neither a monument nor a laboratory

CommandError / EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: CastleUpgradeLaboratoryDialogProperties.progressCommandVO and CastleUpgradeLandmarkDialogProperties.progressCommandVO (bundle lines 51665, 51709)

select

select(castle_id: int, *, timeout: float = 5.0) -> None

Select/jump to a castle (makes it the active castle).

Use join for the castle's state the server sends back.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

Client: C2SJoinCastleVO sent with the castle's objectId and kingdomID (JoinAreaAndSavePositionCommand.execute, bundle line 100892)

Example
client.castle.select(12345)

join

join(castle_id: int, *, timeout: float = 5.0) -> SelectCastleResponse

Join a castle, making it the active castle, and return its state.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

CommandError

The server refused the join.

Client: C2SJoinCastleVO sent with the castle's objectId and kingdomID (JoinAreaAndSavePositionCommand.execute, bundle line 100892)

Example
castle = client.castle.join(12345)
if castle.buildings:
    print([b.wod_id for b in castle.buildings.buildings])

join_area

join_area(x: int, y: int, kingdom_id: Kingdom = GREEN, *, timeout: float = 5.0) -> SelectCastleResponse

Join an area by its position (jaa), making it the active area, and return its state.

The client joins this way the objects it may visit that are not castles: outposts, capitals, metropolises and Berimond camps that are not destroyed, and a kingdom castle just after its first naming. It joins main and kingdom castles otherwise by id, as join does. It never joins anything else (see JoinAreaRequest).

Parameters:

Name Type Description Default
x int

Map x of the area

required
y int

Map y of the area

required
kingdom_id Kingdom

The kingdom it lies in

GREEN
timeout float

Timeout in seconds

5.0

Raises:

Type Description
CommandError

The server refused the join; a live server answered INVALID_POSITION (6) for objects the client never joins, such as NPC camps and royal towers

Client: JoinAreaAndSavePositionCommand.execute (bundle line 100892), JAACommand.executeCommand (bundle line 130190)

get_resources

get_resources(castle_id: int, *, timeout: float = 5.0) -> CastleResources

Get one of your castles' resources.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

Client: C2SGetCastleResourcesVO sent with the castle's objectId and kingdomID (CastleTransferResourcesDialog.onSelectCastle, bundle line 38076)

Example
resources = client.castle.get_resources(12345)
print(f"Wood: {resources.wood}")

get_production

get_production(*, timeout: float = 5.0) -> CastleProductionArea

Get the joined castle's production area: production, storage, population and the rest.

Join the castle first with join; the server answers for the joined castle.

Example
client.castle.join(12345)
area = client.castle.get_production()
print(f"Wood/hr: {area.production.wood}")

horses

horses(castle_id: int) -> list[HorseStats] | None

The horses one of your castles can send movements with, by wod id.

Read from the login data's gpc section and its pushes; nothing is sent. A horse whose is_instant_spy_horse is set can be paid with rubies or, sent as feathers=True, with feathers; the client shows it twice, once per payment. An id missing from the game data is left out, as the client leaves it out.

Parameters:

Name Type Description Default
castle_id int

One of your castles, Castle.id from client.state.get_castles(); its kingdom is taken from the castle list

required

Returns:

Type Description
list[HorseStats] | None

The horses sorted by wod id, or None when no gpc named the castle yet

Raises:

Type Description
GameDataNotLoadedError

the game data cannot be loaded

UnknownCastleError

castle_id is not in your castle list

Client: CastleHorsesVO.parseParamObject (bundle line 139177), CastlePermanentCastleData.getCastleByWorldAreaId (bundle line 139145)

get_decoration_storages

get_decoration_storages(*, timeout: float = 5.0) -> list[DecorationStorage]

Read the decoration storages; they also reach decoration_storages.

Client: CastleDecoShopPanel.show (bundle line 9302) sends C2SShowInventoryVO with no parameter; SINCommand.exec (bundle line 124638)

mark_storage_seen

mark_storage_seen(storage_id: DecorationStorageKey, *, timeout: float = 5.0) -> None

Mark a storage's new decorations as seen.

Parameters:

Name Type Description Default
storage_id DecorationStorageKey

A DecorationStorage.storage_id

required

Client: SendMarkedBuildingsInStorage.execute (bundle line 101099) sends C2SMarkBuildingInStorageVO for each storage shown

store_decoration

store_decoration(object_id: int, *, timeout: float = 5.0) -> StoreBuildingResponse

Put a decoration of the joined castle into the storage.

Returns:

Type Description
StoreBuildingResponse

The stored object's id and the storages after, which also reach decoration_storages

Client: IsoServerCommands.storeBuildingToLocalInventory (bundle line 63795) sends C2SIsoStoreObjectVO; SOBCommand.executeCommand (bundle line 124651)

sell_stored_decoration

sell_stored_decoration(wod_id: Building, amount: int = 1, *, unique_id: int = -1, timeout: float = 5.0) -> SellStoredDecorationResponse

Sell decorations from the storage for coins; they are gone for good.

Parameters:

Name Type Description Default
wod_id Building

The decoration's type, a stored decoration's wod_id

required
amount int

How many to sell

1
unique_id int

A unique decoration's unique_id, -1 for regular ones

-1

Returns:

Type Description
SellStoredDecorationResponse

Coins and rubies, and the storages after, which also reach decoration_storages

Raises:

Type Description
ValueError

amount is below 1

Client: CastleConstructionSellDialog.onClick (bundle line 28636) sends C2SellStoredDeco; SDSCommand.executeCommand (bundle line 131786)

place_stored_decoration

place_stored_decoration(decoration_id: int, x: int, y: int, rotation: int = 0, *, timeout: float = 5.0) -> PlaceStoredDecorationResponse

Place a custom or unique decoration from the storage in the joined castle.

A regular stored decoration is placed with build of its type, as the client does.

Parameters:

Name Type Description Default
decoration_id int

A stored custom_id or unique_id

required

Returns:

Type Description
PlaceStoredDecorationResponse

The placed decoration and the storages after, which also reach decoration_storages

Client: IsoServerCommands.placeCustomInventoryObject (bundle line 63790), sent for a decoration with a uniqueBuildingId (bundle line 64041); PIOCommand.executeCommand (bundle line 123181)

get_fusion_forges

get_fusion_forges(forge_ids: Sequence[FusionForgeId] = (DECORATIONS,), *, timeout: float = 5.0) -> tuple[FusionForge, ...]

Fusion forges' level and energy; the reply also reaches fusion_forges.

Client: FusionForgeData.onGbdArrived (bundle line 142012), FusionForgeVO.requestDataFromServer (bundle line 142199)

level_up_fusion_forge

level_up_fusion_forge(forge_id: FusionForgeId = DECORATIONS, *, timeout: float = 5.0) -> int

Level a fusion forge up for decoration dust, and return its new level.

Client: DecorationForgeUpgradeDialog.onLevelUpButtonClicked (bundle line 78274), FusionForgeVO.getCostForForgeLevelUp (bundle line 142209)

refill_fusion_forge

refill_fusion_forge(forge_id: FusionForgeId = DECORATIONS, *, spend_rubies: bool = False, timeout: float = 5.0) -> int

Refill a fusion forge's energy for rubies, and return the energy added.

The price rises with each refill (FusionForge.used_ruby_refills) by the forge's GameData.fusion_systems row (refill_cost_rubies, refill_cost_factor).

Raises:

Type Description
ValueError

spend_rubies is False

Client: DecorationForgeRechargeEnergyDialog (bundle line 35619), FusionForgeVO.getC2PriceForEnergyPremiumSkip (bundle line 142206)

convert_catalysts

convert_catalysts(catalyst_id: CurrencyId | int, amount: int, direction: CatalystConversion, forge_id: FusionForgeId = DECORATIONS, *, timeout: float = 5.0) -> ConvertCatalystResponse

Assemble fusion catalysts, or disassemble them into decoration dust.

Client: ADecorationForgeCatalystConversionDialogInfoBox.onConfirmButtonClicked (bundle line 48367)

get_fusion_targets

get_fusion_targets(*, timeout: float = 5.0) -> tuple[FusionTargetArea, ...]

Your areas with the placed decorations a fusion can target.

Client: DecoStorageData.requestGTD (bundle line 141447)

fuse_decoration

fuse_decoration(source_wod_id: Building, source_unique_id: int, target_area: FusionTargetArea, target: FusionDecoration, catalyst_id: CurrencyId | int, *, pay_with_rubies: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> FuseDecorationResponse

Fuse a stored decoration into a placed one. The stored decoration is used up.

The fusion spends the forge's energy and the catalyst, and the fusion currency, or rubies with pay_with_rubies (the premium fusion).

Parameters:

Name Type Description Default
source_wod_id Building

The stored decoration's building type

required
source_unique_id int

The stored decoration's unique id

required
target_area FusionTargetArea

The area of get_fusion_targets the target stands in

required
target FusionDecoration

One of target_area.decorations

required
catalyst_id CurrencyId | int

The catalyst used, a currency

required
pay_with_rubies bool

The premium fusion

False
spend_rubies bool

Allow the premium fusion's rubies

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

target is not in target_area, or rubies are spent without spend_rubies

Client: DecorationForgeMainDialog.onFuseButtonClicked (bundle line 35455)

get_brewery_production

get_brewery_production(castle_id: int, brewery: BuildingRow, *, timeout: float = 5.0) -> BreweryProductionResponse

Read one of your castles' brewery production.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
brewery BuildingRow

The brewery's row, from join(castle_id).buildings

required

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

Client: CastleBreweryShortageDialog.showLoaded (bundle line 138227) sends C2SGetAreaBuildingProductionVO; ABPICommand.executeCommand (bundle line 122711)

set_brewery_production

set_brewery_production(castle_id: int, brewery: BuildingRow, mead_percent: int, *, stop_at_food: int = 0, stop_at_honey: int = 0, timeout: float = 5.0) -> BreweryProductionResponse

Set how much of one of your castles' brewery makes mead, and the stocks at which it stops.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
brewery BuildingRow

The brewery's row, from join(castle_id).buildings

required
mead_percent int

The share of the brewery producing mead, in percent

required
stop_at_food int

Food left at which production stops

0
stop_at_honey int

Honey left at which production stops

0

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

Client: the brewery dialog's save button (bundle line 36458) sends C2SSetBreweryProductionVO; ABPICommand.executeCommand (bundle line 122711)

set_mead_priority

set_mead_priority(castle_id: int, enabled: bool, *, timeout: float = 5.0) -> None

Give one of your castles' mead production priority, or take it away.

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

Client: the brewery dialog's priority checkbox (bundle line 36462) sends C2SSetMeadPrioVO for the active castle; BFLCommand.executeCommand (bundle line 122726)

buy_private_village

buy_private_village(village_type_id: PrivateVillageType, *, timeout: float = 5.0) -> None

Buy a private resource village with resource village tokens.

Parameters:

Name Type Description Default
village_type_id PrivateVillageType

The village, e.g. PrivateVillageType.ICE_PRIVATE_WOOD_VILLAGE_L1

required

Client: PrivateResourceVillageBuyDialog.onConfirm (bundle line 81673) sends C2SBuyPrivateResourceVillageVO once APrivateResourceVillageActionDialog.onClick (bundle line 36219) found the tokens; BPVCommand.exec (bundle line 126459)

upgrade_private_village

upgrade_private_village(village: PrivateVillage, *, timeout: float = 5.0) -> None

Upgrade one of your private resource villages to the next level, with resource village tokens.

Parameters:

Name Type Description Default
village PrivateVillage

The village, a row of villages or get_villages; its id and the type of its current level are sent

required

Client: PrivateResourceVillageUpgradeDialog.onConfirm (bundle line 81600) sends C2SUpgradePrivateResourceVillageVO; UPVCommand.exec (bundle line 126489)

remove_private_village

remove_private_village(village: PrivateVillage, *, timeout: float = 5.0) -> None

Remove one of your private resource villages; it is gone for good, its tokens are not returned.

Parameters:

Name Type Description Default
village PrivateVillage

The village, a row of villages or get_villages

required

Client: PrivateResourceVillageDestroyDialog.onConfirm (bundle line 81568) sends C2SRemovePrivateResourceVillageVO; RPVCommand.exec (bundle line 126474)

get_tax_info

get_tax_info(*, timeout: float = 5.0) -> TaxInfo

Read the tax collection status.

Example
tax = client.castle.get_tax_info()
print(tax.status, tax.remaining_seconds, tax.expected_income)

Client: C2SGetTaxInfoVO (bundle line 37186), TXICommand (bundle line 128792)

start_tax

start_tax(tax_type: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> StartTaxResponse

Start a tax collection.

Tax types 0 to 6 collect for TAX_DURATIONS[tax_type] seconds. Type 0 is free and types 1 to 4 cost a tenth of their income in coins. Types 5 and 6 cost TAX_RUBY_COSTS rubies unless a premium account, a VIP level or the tax research waives it; this method refuses them unless spend_rubies is True, and does not check for a waiver.

Parameters:

Name Type Description Default
tax_type int

The tax type, 0 to 6

required
spend_rubies bool

Allow types 5 and 6, which may spend rubies

False
timeout float

Timeout in seconds

5.0

Returns:

Type Description
StartTaxResponse

The reply: coins and rubies after, and the tax status.

Raises:

Type Description
ValueError

tax_type is not 0 to 6, or costs rubies and spend_rubies is False

CommandError / EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: C2SStartCollectTaxVO (bundle line 91088), sent by CastleCollectTaxElement.onStartTaxCollection (bundle line 91069), which shows a ruby cost when CollectTaxElementVO.hasC2CostWithoutPremium (bundle line 91050); TaxConst (dll lines 19771-19790)

collect_tax

collect_tax(*, timeout: float = 5.0) -> CollectTaxResponse

Collect the tax.

Collecting while the collection runs brings the share of its income earned so far; the client asks first when that is nothing.

Returns:

Type Description
CollectTaxResponse

The reply: the coins collected, coins and rubies after, and the tax status.

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: C2SCollectTaxVO (bundle line 41083), sent by CastleCollectTaxDialog.collectTax (bundle line 91027) after onCollectTaxClick (bundle line 91015); TaxConst.getCollectedMoney (dll line 19784); TXCCommand (bundle line 128747)

bribe_tax_collector

bribe_tax_collector(*, spend_rubies: bool = False, private_offer_id: int = -1, timeout: float = 5.0) -> BribeTaxCollectorResponse

Bribe the tax collector, a tax booster bought with rubies; see "Spending rubies" in the guides.

Its price comes with the boosters and is not worked out here, so this always needs spend_rubies.

Parameters:

Name Type Description Default
spend_rubies bool

Allow the rubies it costs; without it nothing is sent

False
private_offer_id int

The booster sale the bribe uses, -1 for none

-1

Returns:

Type Description
BribeTaxCollectorResponse

Coins and rubies, and the tax status after; the booster reaches client.state.get_boosts()

Raises:

Type Description
ValueError

spend_rubies is False

Client: CastleBribeDialog.onClick (bundle line 90878) sends it once the rubies are there, with CastleBoosterSaleData.getOfferId (bundle line 9696); BTXCommand.executeCommand (bundle line 128770)

open_gate_quote

open_gate_quote(castle_id: int) -> OpenGateQuote

What opening one of your castles' gate would cost now, and whether the client offers it; nothing is sent.

The open time and opening count come from the castle list and the mos replies since, the prices before ruby discounts from that count, as the client's start dialog shows them.

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

StateNotLoadedError

No login has brought the player

Client: CastleStartOpenGateDialog.updateCosts (bundle line 35144) and getCastleList (bundle line 35133); CastleOpenGatePremiumShopVO.canBeBought (bundle line 76693)

open_gate

open_gate(castle_id: int, duration: OpenGateDuration, *, spend_rubies: bool = False, timeout: float = 5.0) -> OpenGateResponse

Buy an Open Gate for one of your castles: attackers loot it without a battle, so its buildings take no damage and it loses no units, for duration. On an open gate it extends it, as the client's extend button does. Each opening this week raises the castle's next price.

The reply updates the castle's Open Gate and your rubies in state. A timeout is not retried: the purchase may still have gone through, so read open_gate_quote before trying again.

Parameters:

Name Type Description Default
castle_id int

One of your castles, a Castle.id from client.state.get_castles()

required
duration OpenGateDuration

How long

required
spend_rubies bool

Allow the rubies it costs; open_gate_quote has the price before discounts

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

spend_rubies is False, or the client offers no Open Gate for the castle (see OpenGateRefusal)

UnknownCastleError

castle_id is not in your castle list

StateNotLoadedError

No login has brought the player

CommandError

The server refused it; INVALID_PARAMETER_VALUE while the castle's peace mode is on

EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: CastleStartOpenGateDialog.onClick (bundle line 35154); MOSCommand.executeCommand (bundle line 125119) shows error_openGate_eilandProtection for INVALID_PARAMETER_VALUE

close_gate

close_gate(castle_id: int, *, timeout: float = 5.0) -> OpenGateResponse

Close one of your castles' open gate; nothing is refunded.

Raises:

Type Description
UnknownCastleError

castle_id is not in your castle list

CommandError / EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: CastleManagementDialog.cancelOpenGateMode (bundle line 24683) sends C2SOpenGateStartVO with -1

get_research

get_research(*, timeout: float = 5.0) -> ResearchInfoResponse

Read your research; the reply also reaches research.

Client: CastleResearchDialog.showLoaded (bundle line 16731) sends C2SResearchInfoVO; REICommand.executeCommand (bundle line 126899)

start_research

start_research(research: Research | int, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Start a research, paying what it costs.

Missing resources are never paid with rubies: the request sends PWR 0, as the research dialog does. Some researches cost rubies themselves (ResearchDef.cost_rubies), and the client sends the same request for them; this method refuses those unless spend_rubies is True. Other costs, legendary tokens included, are a normal game currency and are paid. The reply's research reaches client.state.get_research().

Parameters:

Name Type Description Default
research Research | int

The research to start

required
spend_rubies bool

Allow a research that costs rubies, on either kind of server

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
GameDataNotLoadedError

the game data cannot be loaded

ValueError

The game data has no such research, or it costs rubies and spend_rubies is False

Client: ResearchInfo.buyResearch (bundle line 79704) sends C2SResearchStartVO whatever the costs; updateBuyArea shows the ruby overlay when getFinalCosts holds rubies (bundle lines 79679-79680), and AResearchVO.getBaseCosts takes the Outer Realms' costs there (bundle line 61530); RESCommand (bundle line 126872)

skip_research

skip_research(minute_skip: Currency | str, *, timeout: float = 5.0) -> None

Shorten the running research with a minute skip from your inventory.

The reply's research reaches client.state.get_research().

Parameters:

Name Type Description Default
minute_skip Currency | str

The minute skip to use, Currency.SKIP_1_MINUTE to SKIP_24_HOURS; its key ("MS1") also works, for a skip newer than the generated enum

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

minute_skip is no minute skip, or the special currencies hold none of it

Client: ResearchMinuteSkipProperties.getMinuteSkipCommand (bundle line 79784), CastleMinuteSkipDialog.showLoaded (bundle line 7671), MSRCommand (bundle line 125825)

finish_research

finish_research(*, spend_rubies: bool = False, timeout: float = 5.0) -> None

Finish the running research now, for rubies; see "Spending rubies" in the guides.

The price follows the time left and is not worked out here, so this always needs spend_rubies.

Parameters:

Name Type Description Default
spend_rubies bool

Allow the rubies it costs; without it nothing is sent

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

spend_rubies is False

CommandError

The server refused, NOTHING_TO_SKIP included, which the client takes without a dialog

Client: ResearchProgressInfo.buyResearchInstant (bundle line 413633), priced by ResearchConst.getFastCompleteCostC2 (ResearchMinuteSkipProperties.getSkipCost, bundle line 413787); RFICommand.executeCommand (bundle line 641922)

list_missions

list_missions(*, timeout: float = 5.0) -> MercenaryMissionsResponse

The mercenary camp's missions, and when new ones come.

Sends mpe with MID -1, as the client does when it opens the camp and when new missions are due; the reply also reaches client.state.get_mercenary_missions().

Client: CastleMercenaryOverviewDialog.showLoaded and CastleMercenaryData.onNewMissions (bundle lines 51996, 28851)

start_mission

start_mission(mission_id: int, *, timeout: float = 5.0) -> None

Start an open mercenary mission, paying its price in coins.

Lists the missions first and decides from that reply, as the client decides from its mission state: only an open mission starts, and only while no mission runs or waits to be collected. While one runs the client would first finish it for rubies; that is left out.

Parameters:

Name Type Description Default
mission_id int

A MercenaryMission.mission_id from list_missions

required
timeout float

Timeout in seconds, for each request

5.0

Raises:

Type Description
ValueError

The missions list no such mission, it is not open, or another mission runs or waits to be collected

Client: CastleMercenaryMissionItem.startMission, showStartAndRefreshButton and startMissionCallback (bundle lines 87377, 87361, 87379)

collect_mission

collect_mission(mission_id: int, *, timeout: float = 5.0) -> None

Collect a finished mercenary mission's rewards.

The collect is the same mpe as the ruby skip of a running mission, which costs ceil(remaining seconds / 60 * 5) rubies. So this lists the missions first and sends the collect only for one the server lists as collectable, as started with no RD (finished for the client, and a skip of it would cost 0 rubies), or as started with its time run out at least two seconds ago, since RD is rounded. A started mission whose RD still counts down is refused. Another session can still change the mission between the list and the send; that window is not closed.

Parameters:

Name Type Description Default
mission_id int

A MercenaryMission.mission_id from list_missions

required
timeout float

Timeout in seconds, for each request

5.0

Raises:

Type Description
ValueError

The missions list no such mission, or it is not collectable by that rule

Client: CastleMercenaryMissionItem.showCollectButton and collectMissionRewards (bundle lines 87365, 87382); CastleMercenaryMissionItemVO.fillFromParamObject sets no end time without RD (bundle line 81134); CastleMercenarySkipMissionDialog.confirmSkip (bundle line 87459) sends the same id, MercenaryConst.getSkipC2Cost (dll line 19508)

refresh_mission

refresh_mission(mission_id: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Swap an open mercenary mission for another, for REFRESH_MISSION_COST (240) rubies; see "Spending rubies" in the guides.

Lists the missions first and decides from that reply, as the client decides from its mission state: only an open mission is swapped, and only while no mission waits to be collected.

Parameters:

Name Type Description Default
mission_id int

A MercenaryMission.mission_id from list_missions

required
spend_rubies bool

Allow the rubies it costs; without it nothing is sent

False
timeout float

Timeout in seconds, for each request

5.0

Raises:

Type Description
ValueError

spend_rubies is False, the missions list no such mission, it is not open, or a mission waits to be collected

Client: CastleMercenaryMissionItem.updateButtons and showStartAndRefreshButton (bundle lines 87390, 87396), refreshMissionCallback (bundle line 87416); RMMCommand.executeCommand (bundle line 125166); MercenaryConst.REFRESH_MISSION_COST (dll line 19511)

get_crafting_queues

get_crafting_queues(*, timeout: float = 5.0) -> tuple[CraftingQueue, ...]

The crafting queues of the refinery and toolsmith in every castle, as the crafting dialog asks for them.

Each has every slot of its game-data row (CraftingQueue.with_definition). The reply also reaches crafting_queues.

Raises:

Type Description
GameDataNotLoadedError

The game data cannot be loaded

Client: CastleCraftingData.getCraftingInfo (bundle line 111423), from CastleRefineryToolsmithDialog.showLoaded (bundle line 29337)

start_crafting

start_crafting(queue: CraftingQueue, recipe_id: CraftingRecipeId, *, timeout: float = 5.0) -> CraftingQueue

Start a recipe in a crafting queue, paying its costs.

The recipe must be one the queue's building crafts, with a free unlocked slot; the queue after reaches crafting_queues.

Parameters:

Name Type Description Default
queue CraftingQueue

A queue of crafting_queues or get_crafting_queues

required
recipe_id CraftingRecipeId

The crafting recipe, a key of GameData.crafting_recipes

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building is not working (CraftingQueue.is_working)

CommandError

The server refused, NO_FREE_CONSTRUCTION_SLOT for a full queue

Client: CastleCraftingData.startCrafting (bundle line 111424)

cancel_crafting

cancel_crafting(queue: CraftingQueue, slot: CraftingSlot, *, timeout: float = 5.0) -> CraftingQueue

Cancel the craft in one slot of a crafting queue.

Parameters:

Name Type Description Default
queue CraftingQueue

A queue of crafting_queues

required
slot CraftingSlot

One of its production or queue slots

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building is not working (CraftingQueue.is_working)

Client: CastleCraftingData.cancelCrafting (bundle line 111426)

move_crafting_slot

move_crafting_slot(queue: CraftingQueue, slot: CraftingSlot, to_index: int, *, timeout: float = 5.0) -> CraftingQueue

Move a waiting craft to another waiting slot.

Parameters:

Name Type Description Default
queue CraftingQueue

A queue of crafting_queues

required
slot CraftingSlot

One of its queue slots

required
to_index int

Where the craft goes, from 0

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building is not working (CraftingQueue.is_working)

Client: CastleCraftingData.moveQueueSlot (bundle line 111433)

skip_crafting

skip_crafting(queue: CraftingQueue, slot: CraftingSlot, price: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> CraftingQueue

Finish the craft in one slot for rubies.

The client prices the skip as the recipe's skipCostC2 times the share of its time left, rounded up, and sends that price; the game data here has no crafting recipes to price it.

Parameters:

Name Type Description Default
queue CraftingQueue

A queue of crafting_queues

required
slot CraftingSlot

One of its production or queue slots

required
price int

The rubies the skip costs

required
spend_rubies bool

Allow spending them

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building is not working, or spend_rubies is False

Client: CastleCraftingData.skipCrafting (bundle line 111428), CraftingSlotVO.getAdjustedSkipCostC2 (bundle line 17012)

unlock_crafting_slot

unlock_crafting_slot(queue: CraftingQueue, slot: CraftingSlot, *, timeout: float = 5.0) -> CraftingQueue

Unlock a temporary slot of a crafting queue for coins.

Every locked slot right before it is unlocked with it, as the client buys them (CraftingQueue.unlock_indices).

Parameters:

Name Type Description Default
queue CraftingQueue

A queue of crafting_queues

required
slot CraftingSlot

One of its locked temporary slots

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The building is not working (CraftingQueue.is_working)

Client: CastleCraftingData.buySlot (bundle line 111430), CraftingSlotVO.getUnlockCostC1 (bundle line 17009)

get_construction_crafting

get_construction_crafting(*, timeout: float = 5.0) -> ConstructionCraftingResponse

The construction item being crafted and the time left; both None while nothing is crafted.

Client: CastleConstructionItemsCraftingSublayer.onGCCArrived (bundle line 79577)

craft_construction_item

craft_construction_item(castle_id: int, recipe_id: ConstructionItemRecipeId, *, timeout: float = 5.0) -> None

Craft a construction item from a recipe, paying its costs; one craft runs at a time.

Parameters:

Name Type Description Default
castle_id int

One of your castles; the client crafts in the joined castle, else the kingdom's main castle

required
recipe_id ConstructionItemRecipeId

The recipe, a key of GameData.construction_item_recipes

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
UnknownCastleError

castle_id is not one of your castles

CommandError

The server refused

Client: CastleConstructionItemsCraftingSublayerProgress.onClick (bundle line 79926)

skip_construction_crafting_time

skip_construction_crafting_time(castle_id: int, minute_skip: Currency | str, *, timeout: float = 5.0) -> None

Shorten the running construction item craft with a minute skip.

Parameters:

Name Type Description Default
castle_id int

The castle the craft runs in

required
minute_skip Currency | str

The minute skip to use, Currency.SKIP_1_MINUTE to SKIP_24_HOURS; its key ("MS1") also works, for a skip newer than the generated enum

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

minute_skip is no minute skip, or the special currencies hold none of it

UnknownCastleError

castle_id is not one of your castles

Client: ConstructionItemCraftingMinuteSkipProperties.getMinuteSkipCommand (bundle line 79954)

finish_construction_crafting

finish_construction_crafting(castle_id: int, *, spend_rubies: bool = False, timeout: float = 5.0) -> None

Finish the running construction item craft for rubies.

The price falls with the time left (ConstructionConst.getFastCompleteCostC2) and is not checked here, so the call always needs spend_rubies.

Raises:

Type Description
ValueError

spend_rubies is False

UnknownCastleError

castle_id is not one of your castles

Client: CastleConstructionItemsCraftingSublayerProgress.onClick (bundle line 79930), craftingTimer (bundle line 79907)

get_wishing_well

get_wishing_well(*, timeout: float = 5.0) -> WishingWellResponse

Read the wishing well's level and time from the server; its reply also updates wishing_well.

Client: CastleRubyWishingWellData.requestFreshWishingWellData (split.js line 110510)

start_wishing_well

start_wishing_well(*, spend_rubies: bool = False, timeout: float = 5.0) -> WishingWellResponse

Start the wishing well: it takes its level's entry rubies and lucky pennies, and gives twice the rubies once its waiting time has passed. See "Spending rubies" in the guides.

Parameters:

Name Type Description Default
spend_rubies bool

Allow the entry rubies; without it nothing is sent

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

spend_rubies is False

CommandError

The server refused, NOT_ENOUGH_WISHINGWELLCOINS among others

Client: RubyWishingWellDialog.updateArrow and onClick (split.js lines 266174, 266334), the entry rubies and lucky pennies from CastleRubyWishingWellVO.parseXML (split.js line 328993); the dialog's dialog_rubyWishingWell_desc_general text asks to throw in that many rubies and a lucky penny

finish_wishing_well

finish_wishing_well(*, spend_rubies: bool = False, timeout: float = 5.0) -> WishingWellResponse

Finish the running wishing well now, for rubies; see "Spending rubies" in the guides. Whether the rubies still need collect_wishing_well after is the server's to say; read the reply.

Parameters:

Name Type Description Default
spend_rubies bool

Allow the rubies it costs, wishing_well_skip_rubies of the time left; without it nothing is sent

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

spend_rubies is False

CommandError

The server refused

Client: RubyWishingWellDialog.updateArrow and onClick (split.js lines 266174, 266334)

collect_wishing_well

collect_wishing_well(*, timeout: float = 5.0) -> WishingWellResponse

Collect the rubies of a finished wishing well.

Client: RubyWishingWellFixedPositionBuildingVE.onMouseClick (split.js line 444996) and RubyWishingWellDialog.onClick (split.js line 266334)

upgrade_wishing_well

upgrade_wishing_well(*, spend_rubies: bool = False, timeout: float = 5.0) -> WishingWellResponse

Upgrade the wishing well to its next level, for the wood and stone that level costs.

Parameters:

Name Type Description Default
spend_rubies bool

Pay the resources you lack with rubies, as the client's resource dialog does; see "Spending rubies" in the guides

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
CommandError

The server refused, NOT_ENOUGH_RESOURCES without spend_rubies

Client: IsoServerCommands.upgradeBuilding (split.js line 328747) sends it for wod ids 601 to 611; with rubies, CastleResourceWaitDialogProperties.getResourceSkipCommand (split.js line 183792)

castle.models.actions

Castle actions.

Commands:

  • jca: Join a castle (answered as jaa)
  • jaa: Join an area by its position
  • arc: Rename castle
  • mas: Abandon a castle
  • mac: Cancel abandoning a castle
  • rst: Relocate castle
  • laa: Leave the joined area
  • gtwara: The joined area is gone, back to the world map

Classes:

Name Description
SelectCastleRequest

Join a castle, making it the session's active castle.

JoinAreaRequest

Join an area by its position rather than by castle id.

SelectCastleResponse

The joined area's state, the jaa the server answers a join with.

RenameCastleRequest

Rename a castle.

RenameCastleResponse

Response to castle rename.

AbandonCastleRequest

Start abandoning one of your castles.

AbandonCastleResponse

The castle being abandoned and its timers.

CancelAbandonCastleRequest

Cancel abandoning one of your castles.

CancelAbandonCastleResponse

The castle kept; the client sets both its abandon timers to -1.

RelocateCastleRequest

Start a relocation to a new position.

RelocateCastleResponse

The relocation started.

LeaveAreaRequest

Leave the area you joined last.

LeftRemovedAreaResponse

The area you were in is gone, and the client goes back to the world map.

logger module-attribute

logger = logging.getLogger(__name__)

SelectCastleRequest pydantic-model

Bases: BaseRequest

Join a castle, making it the session's active castle.

Command: jca (answered as 'jaa') Payload: {"CID": castle_id, "KID": kingdom_id}

Castle-scoped reads such as gui answer for the joined castle.

Client: C2SJoinCastleVO (bundle line 5841); its MY_CASTLE is -1

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle to join, CastleInfo.castle_id from client.castle.get_all() or Castle.id from client.state.get_castles()

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

JoinAreaRequest pydantic-model

Bases: BaseRequest

Join an area by its position rather than by castle id.

Command: jaa Payload: {"PX": x, "PY": y, "KID": kingdom_id}

The client joins a map object this way only when it may visit it and it is not a castle: JoinAreaAndSavePositionCommand sends jca for a CastleMapobjectVO (main and kingdom castles) and jaa for anything else. Its callers pass either your own areas from the castle lists or, from a double click on the world map or the ring menu's visit button, an object whose canBeVisited is true: outposts, capitals and metropolises, and Berimond camps that are not destroyed. Every other object (NPC camps, dungeons, royal towers, villages, monuments and the rest) says false, and the client never joins it; a live server answered INVALID_POSITION (6) for NPC camps and a royal tower. ARCCommand also joins a kingdom castle by position after its first naming, and a live server accepted that too. Joining another player's outpost is what the client allows; whether the server accepts it is unverified.

Client: C2SJoinAreaVO (bundle line 56128), whose key order the fields follow; sent by JoinAreaAndSavePositionCommand.execute (bundle line 100892) and ARCCommand.executeCommand (bundle line 124969); CastleWorldMapScreen.onDoubleClickCastle (bundle line 39601) and ButtonVisitCastleComponent (bundle line 110159) check canBeVisited, on InteractiveMapobjectVO (bundle line 3678), OutpostMapobjectVO (bundle line 18829), CastleMapobjectVO (bundle line 18924) and FactionCampMapobjectVO (bundle line 21538)

Fields:

x pydantic-field

x: int

Wire key PX

Map x

y pydantic-field

y: int

Wire key PY

Map y

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The kingdom it lies in

accepts_reply

accepts_reply(payload: Any) -> bool

Whether a jaa reply is for this area: its KID and, when sent, the joined area's row position.

Client: JAACommand (bundle line 130190) switches to the reply's KID; AreaFactory.parseAreaInfo (bundle line 130226) reads the area from gca.A with WorldmapObjectFactory.parseWorldMapArea (bundle line 5343), whose parser for every area type takes the position from A[1] and A[2] (BasicMapobjectVO, InteractiveMapobjectVO, CapitalMapobjectVO, MetropolMapobjectVO, FactionCampMapobjectVO and the rest, bundle lines 3631-76548). A treasure camp (T 8) is the exception: its area is not read from A, so its reply is not checked for position.

SelectCastleResponse pydantic-model

Bases: BaseResponse

The joined area's state, the jaa the server answers a join with.

Command: jaa, the answer to both jca and a jaa by position; the client reads both with the same code. Payload: {"KID": kingdom, "T": area_type, "gca": {...}, "grc": {...}, "gpa": {...}, ...}

A block that cannot be read is None, so it does not cost the rest. The other blocks (spl0 to spl3, gui, uap) are kept as sent.

Client: JAACommand.executeCommand (split.js line 654202), AreaFactory.parseAreaInfo (split.js line 654365), which reads the gca block's A as a world map row and a truthy O as its owner, AreaDataUpdater.parseJAA (split.js line 658985), CastleCraftingData.parseAllQueueData (split.js line 574193) for a truthy crai

Fields:

Validators:

kingdom pydantic-field

kingdom: Kingdom | None = Kingdom.GREEN

Wire key KID

The joined area's kingdom; None for one Kingdom lacks

area_type pydantic-field

area_type: MapItemType | None = None

Wire key T

The joined area's type; None for one MapItemType lacks

buildings pydantic-field

buildings: CastleBuildings | None = None

Wire key gca

The area's buildings; None when the reply has none

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The area's resources; None when the reply has none

production_area pydantic-field

production_area: CastleProductionArea | None = None

Wire key gpa

The area's production area; None when the reply has none

slum_level pydantic-field

slum_level: SlumLevel | None = None

Wire key csl

The area's slum level; None when the reply has none

area_booster pydantic-field

area_booster: AreaBooster | None = None

Wire key gab

The area's builder discount; None when the reply has none

mines pydantic-field

mines: MineStatusList | None = None

Wire key gsm

The area's mines; None when the reply has none

resource_carts pydantic-field

resource_carts: ResourceCartInfo | None = None

Wire key rci

The area's resource carts; None when the reply has none

brewery pydantic-field

brewery: BreweryProductionResponse | None = None

Wire key abpi

The castle's brewery production; None when the reply has none

storages pydantic-field

storages: DecorationStorages

Wire key sin

The decoration storages the reply names

crafting_queues pydantic-field

crafting_queues: CraftingQueues | None = None

Wire key crai

Every castle's crafting queues; None when the reply has no crafting areas

hunter pydantic-field

hunter: HunterInfo | None = None

Wire key hin

The hunter's values; None when the reply has none

area pydantic-field

area: PlayerCastle | None = None

The joined area's map row, the gca block's A; None when the reply has none or it cannot be read

owner pydantic-field

owner: MapObject | None = None

The joined area's owner, the gca block's O, without an id when it cannot be read; None when the reply has none

RenameCastleRequest pydantic-model

Bases: BaseRequest

Rename a castle.

Command: arc Payload: {"CID": castle_id, "P": 0 or 1, "KID": kingdom_id, "AT": area_type, "N": name}

The keys follow the client's order: the constructor initialises CID, P, KID and AT before it sets N, which it encodes as it encodes any text it sends.

Client: C2SRenameCastleVO (bundle line 42424)

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle to rename, a CastleInfo.castle_id from client.castle.get_all()

is_rename pydantic-field

is_rename: int = 1

Wire key P

1 to rename, 0 to name a newly acquired castle such as a monument

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

castle_type pydantic-field

castle_type: MapItemType

Wire key AT

The castle's area type

castle_name pydantic-field

castle_name: str

Wire key N

The new name

accepts_reply

accepts_reply(payload: Any) -> bool

Whether an arc reply is about this castle: its CID, and its KID when sent, are the ones asked for.

Client: ARCCommand.executeCommand (bundle line 124966) looks the renamed castle up by the reply's CID and KID (bundle line 124968).

RenameCastleResponse pydantic-model

Bases: BaseResponse

Response to castle rename.

Command: arc Payload: {"CID": castle_id, "KID": kingdom_id, "P": 0 or 1}

Client: ARCCommand.executeCommand (bundle line 124966), which looks the castle up by CID and KID, and joins a kingdom castle's area again after a first naming (P 0)

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The renamed castle

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

is_rename pydantic-field

is_rename: int = 1

Wire key P

1 for a rename, 0 for a first naming

AbandonCastleRequest pydantic-model

Bases: BaseRequest

Start abandoning one of your castles.

Command: mas Payload: {"CID": castle_id, "KID": kingdom_id}

The castle is given up after OutpostConst.ABANDON_TIME (86400 s), and the abandon may be cancelled within ABANDON_CANCEL_TIME (10800 s).

Client: C2SAbandonOutpostStartVO (bundle line 104735), sent by CastleManagementDialog.onAbandonOutpost (bundle line 24630); OutpostConst (dll line 19530)

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle to abandon, a CastleInfo.castle_id from client.castle.get_all()

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

accepts_reply

accepts_reply(payload: Any) -> bool

Whether a mas reply is about this castle: its CID, and its KID when sent.

Client: CastleUserData.parse_MAS (split.js line 54139) looks the castle up by CID and KID.

AbandonCastleResponse pydantic-model

Bases: BaseResponse

The castle being abandoned and its timers.

Command: mas Payload: {"CID": castle_id, "KID": kingdom_id, "AOT": seconds, "CAT": seconds}

Client: MASCommand.executeCommand (split.js line 635734), CastleUserData.parse_MAS (split.js line 54139), which reads AOT and CAT through int()

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle being abandoned

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

abandon_seconds pydantic-field

abandon_seconds: int = 0

Wire key AOT

Seconds until it is abandoned

cancel_seconds pydantic-field

cancel_seconds: int = 0

Wire key CAT

Seconds left to cancel the abandon

CancelAbandonCastleRequest pydantic-model

Bases: BaseRequest

Cancel abandoning one of your castles.

Command: mac Payload: {"CID": castle_id, "KID": kingdom_id}

The client offers it only while the castle's CAT is above 0.

Client: C2SAbandonOutpostCancelVO (bundle line 104726), sent by CastleManagementDialog.onCancelAbandoning (bundle line 24629)

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle to keep, a CastleInfo.castle_id from client.castle.get_all()

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

accepts_reply

accepts_reply(payload: Any) -> bool

Whether a mac reply is about this castle: its CID, and its KID when sent.

Client: CastleUserData.parse_MAC (split.js line 54146) looks the castle up by CID and KID.

CancelAbandonCastleResponse pydantic-model

Bases: BaseResponse

The castle kept; the client sets both its abandon timers to -1.

Command: mac Payload: {"CID": castle_id, "KID": kingdom_id}

Client: MACCommand.executeCommand (split.js line 635691), CastleUserData.parse_MAC (split.js line 54146)

Fields:

castle_id pydantic-field

castle_id: int

Wire key CID

The castle kept

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

RelocateCastleRequest pydantic-model

Bases: BaseRequest

Start a relocation to a new position.

Command: rst Payload: {"PX": x, "PY": y}

The client sends only the position: no castle id and no kingdom. It relocates the main castle in the green kingdom.

Client: C2SStartRelocationVO (bundle line 109671), sent by CastleRelocateDialog.onClick (bundle line 109656)

Fields:

x pydantic-field

x: int

Wire key PX

Map x of the new position

y pydantic-field

y: int

Wire key PY

Map y of the new position

RelocateCastleResponse pydantic-model

Bases: BaseResponse

The relocation started.

Command: rst

Client: RSTCommand.executeCommand (bundle line 126855) reads nothing from the reply

Fields:

LeaveAreaRequest pydantic-model

Bases: BaseRequest

Leave the area you joined last.

Command: laa Payload: {}

The client registers no handler for an laa reply.

Client: C2SLeaveAreaVO (bundle line 108588), sent by CastleKingdomOverviewScreen.show (bundle line 108518)

LeftRemovedAreaResponse pydantic-model

Bases: BaseResponse

The area you were in is gone, and the client goes back to the world map.

Command: gtwara, pushed

Client: GTWARACommand.executeCommand (bundle line 127296) reads nothing and runs SwitchToWorldmapCommand

Fields:

castle.models.buildings

Building commands.

Every command acts on the castle joined with jca (client.castle.select) and names a building by its object id, a BuildingRow.object_id from the castle's CastleBuildings (client.castle.join).

Commands:

  • ebu: Build
  • eup: Upgrade a building
  • emo: Move a building
  • sbd: Sell a decoration
  • edo: Take a building down
  • fco: Finish a construction at once
  • msb: Shorten a construction with a minute skip
  • eud: Upgrade the wall, gate or a tower
  • rbu: Repair a building
  • ira: Repair every building
  • ebe: Buy a castle expansion
  • etc: Open an expansion's treasure chest

Classes:

Name Description
BuildRequest

Place a new building in the joined castle.

BuildResponse

The new building.

UpgradeBuildingRequest

Upgrade a building in the joined castle.

UpgradeBuildingResponse

The upgraded buildings.

MoveBuildingRequest

Move a building in the joined castle.

MoveBuildingResponse

The moved building.

SellBuildingRequest

Sell a decoration placed in the joined castle.

SellBuildingResponse

The sold decoration.

DestroyBuildingRequest

Start taking a building in the joined castle down.

DestroyBuildingResponse

The building being taken down.

FastCompleteRequest

Finish a building's running construction at once: for free with FS 1, else for rubies.

FastCompleteResponse

The finished building.

TimeSkipBuildingRequest

Shorten a building's running construction with a minute skip.

TimeSkipBuildingResponse

The construction slots after a minute skip.

UpgradeWallRequest

Upgrade the joined castle's wall, gate or one of its towers.

UpgradeWallResponse

The upgraded wall, gate or tower.

RepairBuildingRequest

Repair a damaged building in the joined castle.

RepairBuildingResponse

The building being repaired.

RepairAllRequest

Repair every damaged building in the joined castle at once.

RepairAllResponse

The repaired buildings.

BuyExtensionRequest

Buy an expansion of the joined castle's grounds.

BuyExtensionResponse

The castle after the expansion.

CollectExtensionGiftRequest

Open a treasure chest found on an expansion of the joined castle.

CollectExtensionGiftResponse

The opened chest.

BuildRequest pydantic-model

Bases: BaseRequest

Place a new building in the joined castle.

Command: ebu Payload: {"WID": wod_id, "X": x, "Y": y, "R": rotation, "PWR": 0 or 1, "PO": offer_id, "DOID": district_id}

Keys follow the client's order: the constructor initialises PWR before PO. To place a building into a district the client sends X and Y as -1 and the district's object id as DOID.

Client: C2SIsoBuyObjectVO (bundle line 31942), sent by IsoServerCommands.buyObjectFromShop (bundle line 63766)

Fields:

wod_id pydantic-field

wod_id: EnumOrInt['Building']

Wire key WID

The building type

x pydantic-field

x: int

Wire key X

Castle grid x, -1 when placing into a district

y pydantic-field

y: int

Wire key Y

Castle grid y, -1 when placing into a district

rotation pydantic-field

rotation: int = 0

Wire key R

Rotation

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

district_object_id pydantic-field

district_object_id: int = -1

Wire key DOID

Object id of the district to place into, -1 for none

BuildResponse pydantic-model

Bases: _BuildingReply

The new building.

Command: ebu Payload: {"NO": row, "grc": {..}, "scl": {..}, "gcu": {..}, "sin": [..], "fbe": ..}

fbe is kept as sent.

Client: EBUCommand.executeCommand (bundle line 122760), AreaDataUpdater.parseEBU (bundle line 131512)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key NO

The new building

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

storages pydantic-field

storages: DecorationStorages

Wire key sin

The decoration storages after

UpgradeBuildingRequest pydantic-model

Bases: BaseRequest

Upgrade a building in the joined castle.

Command: eup Payload: {"OID": object_id, "PWR": 0 or 1, "PO": offer_id}

Keys follow the client's order: the constructor initialises PWR before PO.

Client: C2SIsoUpgradeObjectVO (bundle line 31971)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

UpgradeBuildingResponse pydantic-model

Bases: _BuildingReply

The upgraded buildings.

Command: eup Payload: {"O": [row, ...], "grc": {..}, "scl": {..}, "gcu": {..}}

Client: EUPCommand.executeCommand (bundle line 122860), AreaDataUpdater.parseEUP (bundle line 131516)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

buildings pydantic-field

buildings: list[BuildingRow]

Wire key O

The changed buildings

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

MoveBuildingRequest pydantic-model

Bases: BaseRequest

Move a building in the joined castle.

Command: emo Payload: {"OID": object_id, "X": x, "Y": y, "R": rotation}

Client: C2SIsoMoveObjectVO (bundle line 63796), sent by IsoServerCommands.moveObject (bundle line 63776) for a building outside a district

Fields:

object_id pydantic-field

object_id: int

Wire key OID

x pydantic-field

x: int

Wire key X

Castle grid x

y pydantic-field

y: int

Wire key Y

Castle grid y

rotation pydantic-field

rotation: int = 0

Wire key R

Rotation

MoveBuildingResponse pydantic-model

Bases: _BuildingReply

The moved building.

Command: emo Payload: {"MO": row}

Client: EMOCommand.executeCommand (bundle line 122815), which also reads the reply to a failed move, AreaDataUpdater.parseEMO (bundle line 131518)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key MO

The building where it now stands

SellBuildingRequest pydantic-model

Bases: BaseRequest

Sell a decoration placed in the joined castle.

Command: sbd Payload: {"OID": object_id}

Client: C2SellBuildingDeco (bundle line 77740), sent from the sell dialog of a placed decoration (bundle line 28587)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

SellBuildingResponse pydantic-model

Bases: _BuildingReply

The sold decoration.

Command: sbd Payload: {"OID": object_id, "gcu": {..}}

Client: SBDCommand.executeCommand (bundle line 131722), AreaDataUpdater.parseSBD (bundle line 131522)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

object_id pydantic-field

object_id: int = -1

Wire key OID

Object id of the removed decoration

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

DestroyBuildingRequest pydantic-model

Bases: BaseRequest

Start taking a building in the joined castle down.

Command: edo Payload: {"OID": object_id}

Client: C2SIsoDisassembleObjectVO (bundle line 41065)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

DestroyBuildingResponse pydantic-model

Bases: _BuildingReply

The building being taken down.

Command: edo Payload: {"O": row, "scl": {..}}

Client: EDOCommand.executeCommand (bundle line 122781), AreaDataUpdater.parseEDO (bundle line 131513), which reads the reply itself as the row

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key O

The building

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

FastCompleteRequest pydantic-model

Bases: BaseRequest

Finish a building's running construction at once: for free with FS 1, else for rubies.

Command: fco Payload: {"OID": object_id, "FS": 0 or 1}

Client: C2SIsoFastCompleteObjectVO (bundle line 31951), sent by IsoServerCommands.fastCompleteBuilding (bundle line 63773) with FS 1 when CastleSpecialEventData.hasSkipForFree (bundle line 139853)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

free_skip pydantic-field

free_skip: bool = False

Wire key FS

Finish for free, the time left being within the free skip time

FastCompleteResponse pydantic-model

Bases: _BuildingReply

The finished building.

Command: fco Payload: {"O": row, "gcu": {..}}

Client: FCOCommand.executeCommand (bundle line 122908), AreaDataUpdater.parseFCO (bundle line 131519)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key O

The building

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

TimeSkipBuildingRequest pydantic-model

Bases: BaseRequest

Shorten a building's running construction with a minute skip.

Command: msb Payload: {"OID": object_id, "MST": minute_skip}

Keys follow the client's order: the constructor initialises OID and sets MST after it.

Client: C2SMinuteSkipBuildingVO (bundle line 81363), built by BuildingMinuteSkipProperties.getMinuteSkipCommand (bundle line 50021); CastleMinuteSkipDialog.onScrollItemClick passes the currency's jsonKey (bundle line 7722)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

minute_skip pydantic-field

minute_skip: EnumOrStr['Currency']

Wire key MST

The minute skip used, Currency.SKIP_1_MINUTE to SKIP_24_HOURS; sent as its key

TimeSkipBuildingResponse pydantic-model

Bases: _BuildingReply

The construction slots after a minute skip.

Command: msb Payload: {"scl": {..}}

Client: MSBCommand.executeCommand (bundle line 125767)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

UpgradeWallRequest pydantic-model

Bases: BaseRequest

Upgrade the joined castle's wall, gate or one of its towers.

Command: eud Payload: {"OID": object_id, "PO": offer_id, "PWR": 0 or 1}

Client: C2SIsoUpgradeDefenceVO (bundle line 41075)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

Object id of the wall, gate or tower, a BuildingRow.object_id

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

UpgradeWallResponse pydantic-model

Bases: _BuildingReply

The upgraded wall, gate or tower.

Command: eud Payload: {"N": row, "grc": {..}, "gcu": {..}}

Client: EUDCommand.executeCommand (bundle line 122845), AreaDataUpdater.parseEUD (bundle line 131515)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key N

The upgraded object

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

RepairBuildingRequest pydantic-model

Bases: BaseRequest

Repair a damaged building in the joined castle.

Command: rbu Payload: {"OID": object_id, "PO": offer_id, "PWR": 0 or 1}

Client: C2SIsoRepairBuildingVO (bundle line 31961)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

RepairBuildingResponse pydantic-model

Bases: _BuildingReply

The building being repaired.

Command: rbu Payload: {"O": row, "scl": {..}, "grc": {..}, "gcu": {..}}

Client: RBUCommand.executeCommand (bundle line 123162), AreaDataUpdater.parseRBU (bundle line 131507)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

building pydantic-field

building: BuildingRow | None = None

Wire key O

The building

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

RepairAllRequest pydantic-model

Bases: BaseRequest

Repair every damaged building in the joined castle at once.

Command: ira Payload: {}

Client: C2SIsoRepairAllVO (bundle line 37983)

RepairAllResponse pydantic-model

Bases: _BuildingReply

The repaired buildings.

Command: ira Payload: {"gpa": {..}, "B": [row, ...], "gcu": {..}}

Client: IRACommand.executeCommand (bundle line 123079), AreaDataUpdater.parseIRA (bundle line 131508)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

production_area pydantic-field

production_area: CastleProductionArea | None = None

Wire key gpa

The castle's production area after

buildings pydantic-field

buildings: list[BuildingRow]

Wire key B

The repaired buildings

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

BuyExtensionRequest pydantic-model

Bases: BaseRequest

Buy an expansion of the joined castle's grounds.

Command: ebe Payload: {"X": x, "Y": y, "R": rotation, "CT": expansion_type}

Client: C2SIsoBuyExpansionVO (bundle line 63787), sent by IsoServerCommands.buyExpansion (bundle line 63769) with the expansion's IsoExpansionEnum id

Fields:

x pydantic-field

x: int

Wire key X

Castle grid x of the expansion

y pydantic-field

y: int

Wire key Y

Castle grid y of the expansion

rotation pydantic-field

rotation: int = 0

Wire key R

Rotation

expansion_type pydantic-field

expansion_type: ExpansionType = ExpansionType.NORMAL

Wire key CT

Pay with resources (NORMAL) or rubies (PREMIUM)

BuyExtensionResponse pydantic-model

Bases: _BuildingReply

The castle after the expansion.

Command: ebe Payload: {"gca": {..}, "grc": {..}, "scl": {..}, "gcu": {..}, "sin": [..]}

Client: EBECommand.executeCommand (bundle line 122743), AreaDataUpdater.parseEBE (bundle line 131511)

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

castle_buildings pydantic-field

castle_buildings: CastleBuildings | None = None

Wire key gca

The castle's buildings after

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

storages pydantic-field

storages: DecorationStorages

Wire key sin

The decoration storages after

CollectExtensionGiftRequest pydantic-model

Bases: BaseRequest

Open a treasure chest found on an expansion of the joined castle.

Command: etc Payload: {"OID": object_id}

Client: C2SExtensionTreasureChestVO (bundle line 86720), sent by CastleTreasureChestBuildingDialog (bundle line 86704)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The treasure chest's object id

CollectExtensionGiftResponse pydantic-model

Bases: _BuildingReply

The opened chest.

Command: etc Payload: {"RID": reward_id, "OID": object_id}

Client: AreaDataUpdater.parseETC (bundle line 131517); CastleTreasureChestBuildingDialog.onEtcArrived (bundle line 86706) reads RID through int()

Fields:

Validators:

  • _resources
  • _production_area
  • _castle_buildings
  • _construction_list
  • _row
  • _rows

reward_id pydantic-field

reward_id: ClientInt = 0

Wire key RID

The reward list the chest held

object_id pydantic-field

object_id: ClientInt = -1

Wire key OID

Object id of the removed chest

castle.models.castles

The player's castle list.

Commands:

  • gcl: Get castles list

Classes:

Name Description
PlayerCastle

One row of a castle list's AI entries, read by field position as its

GetCastlesRequest

Get a player's castle list.

CastleInfo

One of the player's locations: a castle list entry and its map row.

GetCastlesResponse

The player's castle list.

logger module-attribute

logger = logging.getLogger(__name__)

PlayerCastle pydantic-model

Bases: BasePayload

One row of a castle list's AI entries, read by field position as its area type's client parser reads it.

  • Castles, outposts, kingdom castles and Berimond camps (InteractiveMapobjectVO.parseAreaInfo): object id 3, owner 4, keep, wall, gate, tower and moat 5 to 9 through int() with keep, wall and gate at least 1, name 10, attack cooldown 11, sabotage cooldown 12, seconds since the last spy 13, outpost type 14, occupier 15, kingdom 16, equipment skin 17 and temporary sabotage protection 19 (on when it is 1); 11 to 19 through int(), so one the row lacks reads as 0.
  • Capitals and metropolises: as above, but the levels as sent, 13 as sent, the occupier at 14 and the skin at 15, both as sent, and no outpost type.
  • Royal towers: object id 3, owner 4, kingdom 5, seconds since the last spy 6, name 7.
  • Monuments: object id 3, owner 4, monument type 5, level 6, kingdom 7, seconds since the last spy 8, name 9.
  • Laboratories: object id 3, owner 4, level 5, kingdom 6, seconds since the last spy 7, name 8.
  • Berimond capitals: owner 3, and no object id, name or kingdom.

The client stores the row's kingdom as sent; one that is not a Kingdom reads as the kingdom the row is listed under. An occupier the row lacks reads as -1 here, where the client's int() would read 0: a deliberate leniency, so a short row does not look occupied.

Client: WorldmapObjectFactory.parseWorldMapArea (bundle line 5343), InteractiveMapobjectVO.parseAreaInfo (bundle line 3631), CastleMapobjectVO.parseAreaInfo (bundle line 18910), FactionCampMapobjectVO.parseAreaInfo (bundle line 21526), CapitalMapobjectVO.parseAreaInfo (bundle line 18729), MetropolMapobjectVO.parseAreaInfo (bundle line 21609), KingstowerMapobjectVO.parseAreaInfo (bundle line 19055), MonumentMapobjectVO.parseAreaInfo (bundle line 21652), LaboratoryMapobjectVO.parseAreaInfo (bundle line 25900), FactionCapitalMapobjectVO.parseAreaInfo (bundle line 22764)

Fields:

kingdom pydantic-field

kingdom: Kingdom = Kingdom.GREEN

The castle's kingdom

location_id pydantic-field

location_id: int | None = None

The castle's object id; None for a type with none

x pydantic-field

x: int = 0

Map x

y pydantic-field

y: int = 0

Map y

castle_type pydantic-field

castle_type: MapItemType = MapItemType.EMPTY

The row's area type

owner_id pydantic-field

owner_id: int = 0

Player id of the owner

name pydantic-field

name: str | None = None

The castle's name; None for a type with none

occupier_id pydantic-field

occupier_id: int = -1

Player id of the occupier, -1 when there is none

keep_level pydantic-field

keep_level: int | None = None

Keep level; None for a type with none

wall_level pydantic-field

wall_level: int | None = None

Wall level; None for a type with none

gate_level pydantic-field

gate_level: int | None = None

Gate level; None for a type with none

tower_level pydantic-field

tower_level: int | None = None

Tower level; None for a type with none

moat_level pydantic-field

moat_level: int | None = None

Moat level; None for a type with none

landmark_level pydantic-field

landmark_level: int | None = None

A monument's or laboratory's level; None for any other type

monument_type pydantic-field

monument_type: int | None = None

A monument's type; None for any other type

attack_cooldown_seconds pydantic-field

attack_cooldown_seconds: int | None = None

Seconds until it can be attacked again; None for a type with none

sabotage_cooldown_seconds pydantic-field

sabotage_cooldown_seconds: int | None = None

Seconds until it can be sabotaged again; None for a type with none

seconds_since_spy pydantic-field

seconds_since_spy: int | None = None

Seconds since it was last spied on; None for a type with none

outpost_type pydantic-field

outpost_type: int | None = None

The outpost type; None for a type with none

equipment_skin_id pydantic-field

equipment_skin_id: int | None = None

Unique id of the castle skin equipped; None for a type with none

has_sabotage_protection pydantic-field

has_sabotage_protection: bool = False

Whether a temporary sabotage protection is on

is_occupied property

is_occupied: bool

Whether someone occupies this castle; the client's isOccupied is an occupier id above -1.

from_list classmethod

from_list(data: Any, kingdom: Kingdom = GREEN) -> 'PlayerCastle'

Read a gcl.C[].AI[].AI row; kingdom is the block it is listed under.

Raises:

Type Description
ValueError

The row is not a list, its area type is not one a castle list holds, or it is too short for its type's layout. ValidationError is one, for a field of the wrong type

GetCastlesRequest pydantic-model

Bases: BaseRequest

Get a player's castle list.

Command: gcl Payload: {"PID": player_id}

The client always sends the logged-in player's id. Without one the payload is {}, which the server answers with your castle list.

Client: C2SGetCastleListVO (bundle line 60768); its MY_CASTLELIST is -1, but no caller sends it

Fields:

player_id pydantic-field

player_id: int | None = None

Wire key PID

Your player id; None for none

CastleInfo pydantic-model

Bases: BasePayload

One of the player's locations: a castle list entry and its map row.

Entry: {"AI": [row], "OGT": .., "OGC": .., "AOT": .., "CAT": .., "TA": ..}

The row's values are read by its area type's layout, the field positions PlayerCastle lists. OGT, OGC, AOT, CAT and TA are the entry's keys, read through int() (OGT and OGC only when they are not 0), so one the entry lacks reads as 0. KID is the row's own kingdom when it carries one (InteractiveMapobjectVO.parseAreaInfo, bundle line 3637), else the block the entry is listed under. A Berimond capital's row carries no object id, so it has no CastleInfo.

Client: CastleListVO.parseCastleList (bundle line 13698), which reads the row with WorldmapObjectFactory.parseWorldMapArea

Fields:

castle_id pydantic-field

castle_id: int = 0

The castle's object id

castle_name pydantic-field

castle_name: str = ''

The castle's name

x pydantic-field

x: int = 0

Map x

y pydantic-field

y: int = 0

Map y

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom: the row's own, else the block it is listed under

castle_type pydantic-field

castle_type: MapItemType = MapItemType.EMPTY

The castle's area type

owner_id pydantic-field

owner_id: int = 0

Player id of the owner

occupier_id pydantic-field

occupier_id: int = -1

Player id of the occupier, -1 when there is none

keep_level pydantic-field

keep_level: int | None = None

Keep level; None for a type with none

wall_level pydantic-field

wall_level: int | None = None

Wall level; None for a type with none

gate_level pydantic-field

gate_level: int | None = None

Gate level; None for a type with none

tower_level pydantic-field

tower_level: int | None = None

Tower level; None for a type with none

moat_level pydantic-field

moat_level: int | None = None

Moat level; None for a type with none

landmark_level pydantic-field

landmark_level: int | None = None

A monument's or laboratory's level; None for any other type

monument_type pydantic-field

monument_type: int | None = None

A monument's type; None for any other type

attack_cooldown_seconds pydantic-field

attack_cooldown_seconds: int | None = None

Seconds until it can be attacked again; None for a type with none

sabotage_cooldown_seconds pydantic-field

sabotage_cooldown_seconds: int | None = None

Seconds until it can be sabotaged again; None for a type with none

seconds_since_spy pydantic-field

seconds_since_spy: int | None = None

Seconds since it was last spied on; None for a type with none

outpost_type pydantic-field

outpost_type: int | None = None

The outpost type; None for a type with none

equipment_skin_id pydantic-field

equipment_skin_id: int | None = None

Unique id of the castle skin equipped; None for a type with none

has_sabotage_protection pydantic-field

has_sabotage_protection: bool = False

Whether a temporary sabotage protection is on

open_gate_seconds pydantic-field

open_gate_seconds: int = 0

Wire key OGT

Seconds the gate stays open

open_gate_counter pydantic-field

open_gate_counter: int = 0

Wire key OGC

How often the gate has been opened

abandon_outpost_seconds pydantic-field

abandon_outpost_seconds: int = 0

Wire key AOT

Seconds until the castle is abandoned; not positive when it is not

cancel_abandon_seconds pydantic-field

cancel_abandon_seconds: int = 0

Wire key CAT

Seconds left to cancel abandoning the castle; not positive when it cannot be

no_abandon_seconds pydantic-field

no_abandon_seconds: int = 0

Wire key TA

Seconds until the castle has been held long enough to abandon

is_occupied property

is_occupied: bool

Whether someone occupies it; the client's isOccupied is an occupier id above -1.

position property

position: Position

Get castle position as Position object.

from_entry classmethod

from_entry(entry: dict[str, Any], kingdom: Kingdom = GREEN) -> CastleInfo | None

Parse a gcl.C[].AI[] entry; its AI row is read by its area type (see PlayerCastle).

None for a row the client reads but that names no castle: a faction capital, which has no object id, or a Berimond camp that is not on the map.

GetCastlesResponse pydantic-model

Bases: BaseResponse

The player's castle list.

Command: gcl Payload: {"PID": player_id, "C": [{"KID": kingdom, "AI": [{"AI": [row...], "AOT": .., "TA": ..}, ...]}, ...]}

Entries are flattened across kingdoms into castles. A row that cannot be read is skipped and counted, so one bad row costs only itself; a C that is no list counts as one such row, where the client would read it as no castles at all.

Client: CastleListVO.parseCastleList (split.js line 73142), which gdi uses for its gcl block too; it reads OGT and OGC through int() when they are truthy (split.js line 73151)

Fields:

Validators:

  • _flatten_kingdoms

player_id pydantic-field

player_id: int = 0

Wire key PID

The player whose castles these are

castles pydantic-field

castles: list[CastleInfo]

The castles of every kingdom, from C; empty when C was not sent

unreadable_rows pydantic-field

unreadable_rows: int = 0

Rows of C that could not be read and are not in castles

NameCastleInvitationResponse pydantic-model

Bases: BaseResponse

Your castle lists after taking a castle or outpost, and the castle the client invites you to name.

Each list that is sent replaces the one held, as its own section does.

Command: mir, a push, and inside the fjf reply.

Client: MIRCommand.executeCommand (bundle line 125107), which parses whatever the status; CastleUserData.parse_MIR (bundle line 9884) applies each of gcl, gkl, gml and gll that is truthy; parse_MIR_openDialog (bundle line 9885) finds the castle to name by CID and KID as sent

Fields:

Validators:

castles pydantic-field

castles: GetCastlesResponse | None = None

Wire key gcl

Your castle list

royal_towers pydantic-field

royal_towers: RoyalTowerListResponse | None = None

Wire key gkl

Your royal towers

monuments pydantic-field

monuments: MonumentListResponse | None = None

Wire key gml

Your monuments

laboratories pydantic-field

laboratories: LaboratoryListResponse | None = None

Wire key gll

Your laboratories

castle_id pydantic-field

castle_id: int | None = None

Wire key CID

The castle to name; None when no whole number was sent

kingdom_id pydantic-field

kingdom_id: EnumOrInt[Kingdom] | None = None

Wire key KID

Its kingdom; None when no whole number was sent

castle.models.collect

Mines and resource carts, and collecting from them.

Commands:

  • cmr: Collect a mine
  • gsm: The joined castle's mines (pushed)
  • rcc: Collect a resource cart
  • rci: The joined castle's resource carts (pushed)

Classes:

Name Description
CollectMineResourcesRequest

Collect what a mine in the joined castle has produced.

MineStatus

One mine's state, an entry of the gsm block's M.

MineStatusList

The joined castle's mines: the gsm push, and the block of that name in

CollectMineResourcesResponse

The mines after collecting.

CollectResourceCartRequest

Collect the joined castle's resource cart of one resource.

ResourceCart

One resource cart, an entry of the rci block's RC.

ResourceCartInfo

The joined castle's resource carts, wood, stone and food: the rci push,

CollectResourceCartResponse

The collected cart.

logger module-attribute

logger = logging.getLogger(__name__)

CollectMineResourcesRequest pydantic-model

Bases: BaseRequest

Collect what a mine in the joined castle has produced.

Command: cmr Payload: {"OID": object_id}

Client: C2SCollectMineResources (bundle line 84598), sent by AMineBuildingVE.onMouseClick (bundle line 51410)

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The mine's object id, a BuildingRow.object_id

MineStatus pydantic-model

Bases: BasePayload

One mine's state, an entry of the gsm block's M.

Client: CastleMineData.parse_GSM (bundle line 50363) and triggerInfoFlash (bundle line 50371)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

object_id pydantic-field

object_id: int = -1

Wire key OID

The mine's object id

remaining_collection_amount pydantic-field

remaining_collection_amount: int = 0

Wire key RC

What is left to collect

next_collect_seconds pydantic-field

next_collect_seconds: int = 0

Wire key NC

Seconds until the mine can be collected again, -1 when it is done

coins pydantic-field

coins: int | None = None

Wire key C1

Coins just collected; None for none

rubies pydantic-field

rubies: int | None = None

Wire key C2

Rubies just collected; None for none

MineStatusList pydantic-model

Bases: BaseResponse

The joined castle's mines: the gsm push, and the block of that name in the cmr and jaa replies.

Command: gsm Payload: {"M": [{"OID": .., "RC": .., "NC": ..}, ...]}

Client: GSMCommand.executeCommand (bundle line 125752), CastleMineData.parse_GSM (bundle line 50363)

Fields:

Validators:

mines pydantic-field

mines: list[MineStatus]

Wire key M

Each mine

CollectMineResourcesResponse pydantic-model

Bases: BaseResponse

The mines after collecting.

Command: cmr Payload: {"gsm": {"M": [{"OID": .., "RC": .., "NC": .., "C1": ..}, ...]}, "gcu": {...}}

Client: CMRCommand.executeCommand (bundle line 125737)

Fields:

Validators:

mines pydantic-field

mines: MineStatusList | None = None

Wire key gsm

The castle's mines after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

CollectResourceCartRequest pydantic-model

Bases: BaseRequest

Collect the joined castle's resource cart of one resource.

Command: rcc Payload: {"RT": cart_type}

Client: C2SIsoResourceCartCollectVO (bundle line 87566), sent by ResourceCartSurroundingsVE.onMouseClick (bundle line 87542)

Fields:

cart_type pydantic-field

cart_type: ResourceCartType

Wire key RT

The cart's resource

ResourceCart pydantic-model

Bases: BasePayload

One resource cart, an entry of the rci block's RC.

Client: ResourceCartData.parseRciItem (bundle line 81053)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

cart_type pydantic-field

cart_type: ResourceCartType | None = None

Wire key RT

The cart's resource; None for an unknown index

amount pydantic-field

amount: int = 0

Wire key A

What the cart carries

remaining_seconds pydantic-field

remaining_seconds: int | float | None = None

Wire key RS

Seconds until the cart is ready

ResourceCartInfo pydantic-model

Bases: BaseResponse

The joined castle's resource carts, wood, stone and food: the rci push, and the block of that name in the rcc and jaa replies.

Command: rci Payload: {"RC": [{"RT": .., "A": .., "RS": ..}, ...]}

The client reads the first three entries, one cart each.

Client: RCICommand.executeCommand (bundle line 123196), CastleResourceCartsData.parse_RCI (bundle line 28798)

Fields:

Validators:

carts pydantic-field

Wire key RC

Each cart

CollectResourceCartResponse pydantic-model

Bases: BaseResponse

The collected cart.

Command: rcc Payload: {"RT": cart_type, "A": amount, "grc": {...}, "rci": {"RC": [...]}}

Client: RCCCommand.executeCommand (bundle line 123181), CastleResourceCartsData.parse_RCC (bundle line 28796)

Fields:

Validators:

cart_type pydantic-field

cart_type: ResourceCartType | None = None

Wire key RT

The collected cart's resource; None for an unknown index

amount pydantic-field

amount: int = 0

Wire key A

How much was collected

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The castle's resources after

carts pydantic-field

carts: ResourceCartInfo | None = None

Wire key rci

The castle's carts after

castle.models.construction_items

Construction items in storage and the actions that place or disassemble them.

Classes:

Name Description
ConstructionItemStack

One inventory row, [construction item id, amount].

GetConstructionItemsRequest

Request the construction inventory.

ConstructionItemInventory

The construction items in storage, replaced in full by each inventory reply.

ConstructionItemPlacement

The complete item placement for the joined castle.

EquipConstructionItemRequest

Equip or replace an item on a building.

EquipConstructionItemResponse

Items on the joined castle's buildings after equipping.

RemoveConstructionItemRequest

Remove an equipped item into storage for its coin removal cost.

RemoveConstructionItemResponse

Items on the joined castle's buildings after removing an item.

DisassembleConstructionItemRequest

Disassemble items from storage or lost and found.

DisassembleConstructionItemResponse

Disassembled amount and the rewards drawn for temporary items.

ConstructionItemSpaceRequest

Request the free construction inventory capacity.

ConstructionItemSpace

Free construction inventory capacity, which may be negative.

ExpiredConstructionItem

A construction item that expired on a building.

ExpiredConstructionItemArea

The expired construction items in one castle.

GetExpiredConstructionItemsRequest

Request expired items across your castles.

ExpiredConstructionItemsResponse

The complete list of castles with expired construction items.

MarkExpiredConstructionItemsSeenRequest

Mark the expired item list for a castle as viewed.

MarkExpiredConstructionItemsSeenResponse

Acknowledgement that expired items were marked as viewed.

MoveConstructionSlotRequest

Move an occupied building queue slot, within the joined castle.

MoveConstructionSlotResponse

Queue move acknowledgement; the queue itself is delivered by scl.

BoostConstructionItemRequest

Consume one explicitly selected inventory booster on a temporary construction item.

BoostConstructionItemResponse

The complete placement after consuming the booster.

Attributes:

Name Type Description
logger
INVENTORY_SOFTCAP

How many construction items fit in storage before it counts as full.

logger module-attribute

logger = logging.getLogger(__name__)

INVENTORY_SOFTCAP module-attribute

INVENTORY_SOFTCAP = 5000

How many construction items fit in storage before it counts as full.

Client: ConstructionItemConst.INVENTORY_SOFTCAP (dll, 5e3), read by ConstructionItemData.updateInventory (split.js line 120812)

ConstructionItemStack pydantic-model

Bases: BasePayload

One inventory row, [construction item id, amount].

Client: ConstructionItemData.updateInventory (bundle lines 22947-22952), CollectableItemConstructionItemVO (bundle line 12252), ACollectableItemVO.amount (bundle line 3575).

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

The construction item

amount pydantic-field

amount: int

How many items are in storage

GetConstructionItemsRequest pydantic-model

Bases: BaseRequest

Request the construction inventory.

Client: C2SGetContructionItemsInventoryVO (bundle lines 28546-28550).

ConstructionItemInventory pydantic-model

Bases: BaseResponse

The construction items in storage, replaced in full by each inventory reply.

Client: GIICommand.executeCommand (split.js line 629668), ConstructionItemData.updateInventory (split.js line 120812), which counts the space left as INVENTORY_SOFTCAP less the amounts as sent

Fields:

Validators:

  • _space_left
  • _items → items

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

items pydantic-field

Wire key CI

The items in storage

space_left pydantic-field

space_left: int | None = None

How many more construction items fit in storage; None when an item does not read

ConstructionItemPlacement pydantic-model

Bases: BasePayload

The complete item placement for the joined castle.

Client: AreaDataConstructionItems.updateConstructionItems (bundle line 131114), ABasicBuildingVO.parseConstructionItems (bundle lines 18000-18010).

Fields:

Validators:

items pydantic-field

Wire key CI

Items on each building

EquipConstructionItemRequest pydantic-model

Bases: BaseRequest

Equip or replace an item on a building.

Client: C2SReplaceConstructionItemVO (bundle lines 79234-79236).

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The building's object id

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The item to equip

slot pydantic-field

slot: int

Wire key SID

Slot index within the item's slot type

mode pydantic-field

Wire key M

How to replace an existing item

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's id

EquipConstructionItemResponse pydantic-model

Bases: ConstructionItemPlacement, BaseResponse

Items on the joined castle's buildings after equipping.

Client: RPCCommand.executeCommand (bundle lines 123313-123314).

Fields:

Validators:

RemoveConstructionItemRequest pydantic-model

Bases: BaseRequest

Remove an equipped item into storage for its coin removal cost.

Client: C2SRemoveConstructionItemVO (bundle lines 79282-79284), CastleConstructionItemsExtractDialog (bundle lines 79267-79277).

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The building's object id

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The equipped item

slot pydantic-field

slot: int

Wire key SID

Slot index within the item's slot type

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's id

RemoveConstructionItemResponse pydantic-model

Bases: ConstructionItemPlacement, BaseResponse

Items on the joined castle's buildings after removing an item.

Client: CRICommand.executeCommand (bundle lines 123255-123256).

Fields:

Validators:

DisassembleConstructionItemRequest pydantic-model

Bases: BaseRequest

Disassemble items from storage or lost and found.

Client: C2SDisassembleConstructionItemVO (bundle lines 79223-79227), ConstructionItemsActionProperties (bundle line 35689, LFID defaults to -1).

Fields:

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The item to disassemble

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's id

lost_and_found_id pydantic-field

lost_and_found_id: int = -1

Wire key LFID

Lost and found entry id; -1 for storage

amount pydantic-field

amount: int = 1

Wire key AMT

How many items to disassemble

DisassembleConstructionItemResponse pydantic-model

Bases: BaseResponse

Disassembled amount and the rewards drawn for temporary items.

Permanent items' material yield is defined by the recipe, not this reply. Unknown reward ids remain available even if no game-data row resolves them.

Client: CastleConstructionItemsDisassembleDialog.onDCIArrived (bundle line 35729), CastleConstructionItemsDisassembledDialog.showTempCIDisassembling and selectedAmountForResources (bundle lines 48984, 49000).

Fields:

amount pydantic-field

amount: int | None = None

Wire key AMT

How many items were disassembled

reward_ids pydantic-field

reward_ids: tuple[RewardId, ...] = ()

Wire key RIDS

The rewards drawn

rewards pydantic-field

rewards: tuple[Collectable, ...] = ()

Collectables resolved from the rewards drawn

ConstructionItemSpaceRequest pydantic-model

Bases: BaseRequest

Request the free construction inventory capacity.

Client: C2SConstructionItemInventorySpaceLeftVO (bundle line 41293), sent by LostAndFoundDialog.showLoaded (bundle line 107119)

ConstructionItemSpace pydantic-model

Bases: BaseResponse

Free construction inventory capacity, which may be negative.

Client: CSPCommand.exec / ConstructionItemData.parse_CSP (bundle 123841-123843 / 22960).

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

space_left pydantic-field

space_left: int

Wire key C

How many more construction items fit in storage

ExpiredConstructionItem pydantic-model

Bases: BasePayload

A construction item that expired on a building.

Client: ConstructionItemExpiredVO.parseParams (bundle 77661).

Fields:

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The expired item

building_id pydantic-field

building_id: EnumOrInt['Building']

Wire key B

The building's game-data id

object_id pydantic-field

object_id: int

Wire key OID

The building's object id

ExpiredConstructionItemArea pydantic-model

Bases: BasePayload

The expired construction items in one castle.

Client: ConstructionItemExpiredAreaVO.parseParams (bundle 47886-47890).

Fields:

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's id

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

items pydantic-field

Wire key CIL

The expired items

GetExpiredConstructionItemsRequest pydantic-model

Bases: BaseRequest

Request expired items across your castles.

Client: C2SGetAllExpiredConstructionItemsVO (bundle 79379-79381).

ExpiredConstructionItemsResponse pydantic-model

Bases: BaseResponse

The complete list of castles with expired construction items.

Client: AECCommand.executeCommand / ConstructionItemData.parse_AEC (bundle 123264-123266 / 22985-22989). The wire body is a list.

Fields:

Validators:

  • _areas

areas pydantic-field

Castles with expired items

MarkExpiredConstructionItemsSeenRequest pydantic-model

Bases: BaseRequest

Mark the expired item list for a castle as viewed.

Client: C2SMarkExpiredConstructionItemVO / assign sublayer hide / switchCastle (bundle 79370-79372 / 77574 / 77583).

Fields:

castle_id pydantic-field

castle_id: int

Wire key AID

The castle whose expired items were viewed

MarkExpiredConstructionItemsSeenResponse pydantic-model

Bases: BaseResponse

Acknowledgement that expired items were marked as viewed.

Client: MECCommand.executeCommand (bundle 123308), which reads no fields.

Fields:

MoveConstructionSlotRequest pydantic-model

Bases: BaseRequest

Move an occupied building queue slot, within the joined castle.

Client: C2SMoveConstructionItemVO / CastleBuildingListComponent.requestMoveFromServer (bundle 108290-108292 / 108280-108281).

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The queued building's object id

new_position pydantic-field

new_position: int

Wire key NS

The occupied destination queue position

MoveConstructionSlotResponse pydantic-model

Bases: BaseResponse

Queue move acknowledgement; the queue itself is delivered by scl.

Client: MCICommand.executeCommand (bundle 123383).

Fields:

Validators:

  • _body

BoostConstructionItemRequest pydantic-model

Bases: BaseRequest

Consume one explicitly selected inventory booster on a temporary construction item.

Client: C2SUseBoosterConsumableOnConstructionItemVO (bundle 79457-79459).

Fields:

object_id pydantic-field

object_id: int

Wire key OID

The building's object id

consumable_id pydantic-field

consumable_id: CurrencyId

Wire key SUC

The inventory booster to consume

slot pydantic-field

slot: int

Wire key SID

Slot index within the item's slot type

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's id

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The equipped item

BoostConstructionItemResponse pydantic-model

Bases: ConstructionItemPlacement, BaseResponse

The complete placement after consuming the booster.

Client: UBCCommand.executeCommand (bundle 123350-123352).

Fields:

Validators:

  • _items → items
  • _placement

castle.models.details

Detailed castle info and the production area block.

Commands:

  • dcl: Get detailed castle info

Classes:

Name Description
GetDetailedCastleRequest

Get resources, units and production data for every castle the player owns.

ResourceProduction

Hourly production per resource; the client reads D<key> / 10.

StorageCapacity

Storage capacity per resource (MR<key>), a number as sent; anything else reads as 0.

ProductionBonus

Production bonus per resource in percent (<key>M); 100 means no bonus.

SafeAmount

The block's SAFE_<key> amounts per resource.

CastleProductionArea

A castle's production area, the gpa block.

DetailedCastleInfo

One castle's entry in the detailed castle list.

GetDetailedCastleResponse

Detail for every castle the player owns.

logger module-attribute

logger = logging.getLogger(__name__)

GetDetailedCastleRequest pydantic-model

Bases: BaseRequest

Get resources, units and production data for every castle the player owns.

Command: dcl Payload: {"CD": 1}

The client's constructor defaults CD to 1, and some dialogs send 0; what it selects is not traced, so this sends the default.

Client: C2SGetDetailedCastleListVO (bundle line 7922)

Fields:

cd pydantic-field

cd: int = 1

Wire key CD

The client's CD flag, 1 by default

ResourceProduction pydantic-model

Bases: _ProductionAreaSection

Hourly production per resource; the client reads D<key> / 10.

Fields:

Validators:

wood pydantic-field

wood: float = 0.0

Wire key DW

stone pydantic-field

stone: float = 0.0

Wire key DS

food pydantic-field

food: float = 0.0

Wire key DF

coal pydantic-field

coal: float = 0.0

Wire key DC

oil pydantic-field

oil: float = 0.0

Wire key DO

glass pydantic-field

glass: float = 0.0

Wire key DG

iron pydantic-field

iron: float = 0.0

Wire key DI

aquamarine pydantic-field

aquamarine: float = 0.0

Wire key DA

honey pydantic-field

honey: float = 0.0

Wire key DHONEY

mead pydantic-field

mead: float = 0.0

Wire key DMEAD

beef pydantic-field

beef: float = 0.0

Wire key DBEEF

StorageCapacity pydantic-model

Bases: _ProductionAreaSection

Storage capacity per resource (MR<key>), a number as sent; anything else reads as 0.

Fields:

Validators:

wood pydantic-field

wood: int | float = 0

Wire key MRW

stone pydantic-field

stone: int | float = 0

Wire key MRS

food pydantic-field

food: int | float = 0

Wire key MRF

coal pydantic-field

coal: int | float = 0

Wire key MRC

oil pydantic-field

oil: int | float = 0

Wire key MRO

glass pydantic-field

glass: int | float = 0

Wire key MRG

iron pydantic-field

iron: int | float = 0

Wire key MRI

aquamarine pydantic-field

aquamarine: int | float = 0

Wire key MRA

honey pydantic-field

honey: int | float = 0

Wire key MRHONEY

mead pydantic-field

mead: int | float = 0

Wire key MRMEAD

beef pydantic-field

beef: int | float = 0

Wire key MRBEEF

ProductionBonus pydantic-model

Bases: _ProductionAreaSection

Production bonus per resource in percent (<key>M); 100 means no bonus.

Fields:

Validators:

wood pydantic-field

wood: float = 0.0

Wire key WM

stone pydantic-field

stone: float = 0.0

Wire key SM

food pydantic-field

food: float = 0.0

Wire key FM

coal pydantic-field

coal: float = 0.0

Wire key CM

oil pydantic-field

oil: float = 0.0

Wire key OM

glass pydantic-field

glass: float = 0.0

Wire key GM

iron pydantic-field

iron: float = 0.0

Wire key IM

aquamarine pydantic-field

aquamarine: float = 0.0

Wire key AM

honey pydantic-field

honey: float = 0.0

Wire key HONEYM

mead pydantic-field

mead: float = 0.0

Wire key MEADM

beef pydantic-field

beef: float = 0.0

Wire key BEEFM

SafeAmount pydantic-model

Bases: _ProductionAreaSection

The block's SAFE_<key> amounts per resource.

The server sends them, but the client never reads them, so what they measure is not confirmed.

Fields:

Validators:

wood pydantic-field

wood: float = 0.0

Wire key SAFE_W

stone pydantic-field

stone: float = 0.0

Wire key SAFE_S

food pydantic-field

food: float = 0.0

Wire key SAFE_F

coal pydantic-field

coal: float = 0.0

Wire key SAFE_C

oil pydantic-field

oil: float = 0.0

Wire key SAFE_O

glass pydantic-field

glass: float = 0.0

Wire key SAFE_G

iron pydantic-field

iron: float = 0.0

Wire key SAFE_I

aquamarine pydantic-field

aquamarine: float = 0.0

Wire key SAFE_A

honey pydantic-field

honey: float = 0.0

Wire key SAFE_HONEY

mead pydantic-field

mead: float = 0.0

Wire key SAFE_MEAD

beef pydantic-field

beef: float = 0.0

Wire key SAFE_BEEF

CastleProductionArea pydantic-model

Bases: BasePayload

A castle's production area, the gpa block.

The per-resource sections are aliased key by key and validated from the same block, so each wire key appears once in this module. The whole-number fields are read through int(), as the client reads them; the other numbers read anything that is not a number as 0, as the client's arithmetic does (MP is 0 unless it is truthy).

Client: AreaDataUpdater.parseGPA (bundle line 131506), AreaDataCommonInfo.parseGPA (bundle line 130993), AreaDataStorageItem.parseGPA (bundle line 131380), AreaDataMorality.parseGPA (bundle line 131272), DetailedCastleVO.parseGpaData (bundle line 140979)

Fields:

Validators:

population pydantic-field

population: int = 0

Wire key P

Population

neutral_deco_points pydantic-field

neutral_deco_points: int = 0

Wire key NDP

Decoration points

sickness pydantic-field

sickness: int = 0

Wire key S

Sickness

riot pydantic-field

riot: int = 0

Wire key R

Riot

guards pydantic-field

guards: int = 0

Wire key GRD

Guards, before research boosts

build_speed_percent pydantic-field

build_speed_percent: int = 100

Wire key BDB

Construction speed in percent

metropolis_food_bonus pydantic-field

metropolis_food_bonus: float = 0.0

Wire key MP

A metropolis's food production bonus

unit_capacity pydantic-field

unit_capacity: int = 0

Wire key US

How many units the castle holds

auxiliary_capacity pydantic-field

auxiliary_capacity: int = 0

Wire key AUS

How many auxiliaries the castle holds

morale pydantic-field

morale: int = 0

Wire key M

Morale

faction_buff pydantic-field

faction_buff: float = 0.0

Wire key RFPPA

Faction strength balance, 0 to 1: below 0.5 boosts Gerbrandt morale, above 0.5 Ursidae

food_consumption_delta pydantic-field

food_consumption_delta: float = 0.0

Wire key DFC

Food consumption per hour, times 10

food_consumption_reduction_percent pydantic-field

food_consumption_reduction_percent: int = 100

Wire key FCR

Food consumption in percent of the base

mead_consumption_delta pydantic-field

mead_consumption_delta: float = 0.0

Wire key DMEADC

Mead consumption per hour, times 10

mead_consumption_reduction_percent pydantic-field

mead_consumption_reduction_percent: int = 100

Wire key MEADCR

Mead consumption in percent of the base

beef_consumption_delta pydantic-field

beef_consumption_delta: float = 0.0

Wire key DBEEFC

Beef consumption per hour, times 10

beef_consumption_reduction_percent pydantic-field

beef_consumption_reduction_percent: int = 100

Wire key BEEFCR

Beef consumption in percent of the base

barracks_speed pydantic-field

barracks_speed: float = 0.0

Wire key RS1

Barracks production speed

workshop_speed pydantic-field

workshop_speed: float = 0.0

Wire key RS2

Siege workshop production speed

defense_workshop_speed pydantic-field

defense_workshop_speed: float = 0.0

Wire key RS3

Defense workshop production speed

hospital_speed pydantic-field

hospital_speed: float = 0.0

Wire key RSH

Hospital healing speed

production pydantic-field

production: ResourceProduction

Production per hour

storage_capacity pydantic-field

storage_capacity: StorageCapacity

Storage capacity

production_bonus_percent pydantic-field

production_bonus_percent: ProductionBonus

Production bonus in percent, 100 for none

safe_amount pydantic-field

safe_amount: SafeAmount

The block's SAFE_ amounts

food_consumption_per_hour property

food_consumption_per_hour: float

Hourly food consumption (DFC / 10).

DetailedCastleInfo pydantic-model

Bases: BasePayload

One castle's entry in the detailed castle list.

The client reads AID, D, the 11 resources (through int() wherever it uses them), MC, AC, SHI, gpa and the flags B, WS, DW and H (through Boolean()); KID is the kingdom block the entry is listed under. The server also sends OGT, AOT, HI and TU, which the client does not read from this reply: it reads hospital and travelling units from gui (CastleMilitaryData.parse_GUI, bundle line 138833). Each unit array reads as an inventory: an id sent twice adds up (UnitInventoryDictionary, bundle lines 5533-5538).

Client: CastleUserCastleListDetailed.parseData (bundle line 140906), DetailedCastleVO.parseData (bundle line 140973)

Fields:

Validators:

castle_id pydantic-field

castle_id: int

Wire key AID

The castle's object id

kingdom_id pydantic-field

kingdom_id: int = 0

Wire key KID

The castle's kingdom

wood pydantic-field

wood: int = 0

Wire key W

Wood in stock

stone pydantic-field

stone: int = 0

Wire key S

Stone in stock

food pydantic-field

food: int = 0

Wire key F

Food in stock

coal pydantic-field

coal: int = 0

Wire key C

Coal in stock

oil pydantic-field

oil: int = 0

Wire key O

Oil in stock

glass pydantic-field

glass: int = 0

Wire key G

Glass in stock

iron pydantic-field

iron: int = 0

Wire key I

Iron in stock

aquamarine pydantic-field

aquamarine: int = 0

Wire key A

Aquamarine in stock

honey pydantic-field

honey: int = 0

Wire key HONEY

Honey in stock

mead pydantic-field

mead: int = 0

Wire key MEAD

Mead in stock

beef pydantic-field

beef: int = 0

Wire key BEEF

Beef in stock

defense_value pydantic-field

defense_value: int = 0

Wire key D

Defense value

has_barracks pydantic-field

has_barracks: bool = False

Wire key B

Whether the castle has barracks

has_siege_workshop pydantic-field

has_siege_workshop: bool = False

Wire key WS

Whether it has a siege workshop

has_defense_workshop pydantic-field

has_defense_workshop: bool = False

Wire key DW

Whether it has a defense workshop

has_hospital pydantic-field

has_hospital: bool = False

Wire key H

Whether it has a hospital

market_carriages pydantic-field

market_carriages: int = 0

Wire key MC

The castle's market carriages

open_gate_seconds pydantic-field

open_gate_seconds: int = 0

Wire key OGT

Seconds the gate stays open

abandon_outpost_seconds pydantic-field

abandon_outpost_seconds: int = -1

Wire key AOT

Seconds until the castle is abandoned, -1 when it is not

units pydantic-field

units: WodAmounts

Wire key AC

Units and tools stationed here

stronghold_units pydantic-field

stronghold_units: WodAmounts

Wire key SHI

Units in the stronghold (safe house)

hospital_units pydantic-field

hospital_units: WodAmounts

Wire key HI

Wounded units in the hospital; the client reads them from gui, not from this reply

travelling_units pydantic-field

travelling_units: WodAmounts

Wire key TU

Units on their way in (gui's in_production); the client reads them from gui, not from this reply

production_area pydantic-field

production_area: CastleProductionArea | None = None

Wire key gpa

The castle's production area; None when the entry has none

GetDetailedCastleResponse pydantic-model

Bases: BaseResponse

Detail for every castle the player owns.

Command: dcl Payload: {"PID": player_id, "C": [{"KID": kingdom, "AI": [{"AID": castle_id, "W": .., "AC": [..], "gpa": {..}}]}]}

Client: DCLCommand.executeCommand (split.js line 650927), CastleUserCastleListDetailed.parseData (split.js line 700798), which reads each C entry's AI under its KID; it does not read PID

Fields:

Validators:

  • _flatten_kingdoms

player_id pydantic-field

player_id: int = 0

Wire key PID

The player the details are for

castles pydantic-field

Every listed castle's details, each with the kingdom it is listed under

castle

castle(castle_id: int) -> DetailedCastleInfo | None

The listed castle with this id, or None.

castle.models.kingdoms

Your kingdoms: which are unlocked, unlocking one, and the units and goods on their way to one.

Commands:

  • kpi: kingdom info, a login section of gbd, a reply, and inside the transfer replies
  • ksc: Unlock a kingdom with one of its prebuilt castles

Classes:

Name Description
KingdomUnlock

One kingdom's unlock, warehouse and slum, an entry of a kpi's UL.

KingdomTransfer

Units or goods on their way to a kingdom, an entry of a kpi's UT or RT.

KingdomInfoRequest

Ask for your kingdoms and the transfers to them.

KingdomInfoResponse

Your kingdoms' unlocks, and the units and goods on their way to them.

SelectKingdomCastleRequest

Unlock a kingdom with one of its prebuilt castles.

SelectKingdomCastleResponse

The kingdom unlocked.

KingdomUnlock pydantic-model

Bases: TimedPayload

One kingdom's unlock, warehouse and slum, an entry of a kpi's UL.

Client: CastleKingdomVO.parseUnlockInfo (bundle line 134696); hasContor read at bundle line 50209

Fields:

Validators:

kingdom_id pydantic-field

kingdom_id: EnumOrInt[Kingdom] = -1

Wire key KID

The kingdom; -1 when not sent

is_unlocked pydantic-field

is_unlocked: bool = False

Wire key U

Whether the kingdom is unlocked

has_warehouse pydantic-field

has_warehouse: bool = False

Wire key C

Whether the kingdom has a warehouse, which its resource villages need

slum_level pydantic-field

slum_level: ClientInt = 0

Wire key SL

The kingdom's slum level

paid_wood pydantic-field

paid_wood: ClientNumber = 0

Wire key SPW

Wood paid towards the next slum level

paid_stone pydantic-field

paid_stone: ClientNumber = 0

Wire key SPS

Stone paid towards the next slum level

paid_food pydantic-field

paid_food: ClientNumber = 0

Wire key SPF

Food paid towards the next slum level

paid_coins pydantic-field

paid_coins: ClientNumber = 0

Wire key SPC1

Coins paid towards the next slum level

reset_seconds pydantic-field

reset_seconds: ClientNumber = 0

Wire key KRS

Seconds until the kingdom resets when the values were read; 0 for none

reward_set pydantic-field

reward_set: ClientNumber = 0

Wire key CRS

The kingdom's reward set; 0 for none

remaining_reset_seconds

remaining_reset_seconds(now: float | None = None) -> float | None

Seconds until the kingdom resets, 0 at least; None when it does not reset.

KingdomTransfer pydantic-model

Bases: TimedPayload

Units or goods on their way to a kingdom, an entry of a kpi's UT or RT.

The units come as [wod_id, amount] rows, which the client keeps as they are and names by their unit (toolTipText); here each is a UNITS collectable, its item the unit or tool.

Client: CastleKingdomUnitTransferVO.fillFromParamObject and toolTipText (bundle lines 134663, 134675), CastleKingdomGoodsTransferVO.fillFromParamObject (bundle line 134640), which reads the goods with CollectableParserS2CParamList

Fields:

Validators:

kingdom_id pydantic-field

kingdom_id: EnumOrInt[Kingdom] = Kingdom.GREEN

Wire key KID

The kingdom they go to

seconds pydantic-field

seconds: ClientInt = 0

Wire key RS

Seconds until they arrive when the values were read

units pydantic-field

units: tuple[Collectable, ...] = ()

Wire key I

The units and tools; units only

goods pydantic-field

goods: CollectableRows = ()

Wire key G

The goods; goods only

remaining_seconds

remaining_seconds(now: float | None = None) -> float

Seconds until they arrive, 0 at least.

KingdomInfoRequest pydantic-model

Bases: BaseRequest

Ask for your kingdoms and the transfers to them.

Command: kpi Payload: {}

Client: C2SKingdomPayInfoVO (bundle line 55424), sent by CastleHandleKingdomDialog.showLoaded (bundle line 55406) and after a Storm Islands reset (IKRCommand.executeCommand, bundle line 127728)

KingdomInfoResponse pydantic-model

Bases: BaseResponse

Your kingdoms' unlocks, and the units and goods on their way to them.

A kpi updates only the kingdoms it lists; the client keeps the others as they were, and client.state.get_kingdoms() does the same. The transfers are replaced whole. The Berimond faction block (fki) belongs to the Battle for Berimond and is not read here.

Command: kpi, as a login section of gbd, a reply, and inside the kgt, kst, kut, msk and fjf replies.

Client: KPICommand (bundle line 124684), CastleKingdomData.parse_KPI (bundle line 134539)

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

kingdoms pydantic-field

kingdoms: tuple[KingdomUnlock, ...] = ()

Wire key UL

The kingdoms this packet lists

unit_transfers pydantic-field

unit_transfers: tuple[KingdomTransfer, ...] = ()

Wire key UT

Units on their way to another kingdom

goods_transfers pydantic-field

goods_transfers: tuple[KingdomTransfer, ...] = ()

Wire key RT

Goods on their way to another kingdom

kingdom

kingdom(kingdom_id: Kingdom | int) -> KingdomUnlock | None

One kingdom, None when it is not listed.

SelectKingdomCastleRequest pydantic-model

Bases: BaseRequest

Unlock a kingdom with one of its prebuilt castles.

Command: ksc Payload: {"ID": prebuilt_castle_id, "D": direction, "PWR": 0 or 1, "OC2": 0 or 1, "SID": kingdom_id}

Keys follow the client's order. OC2 buys the castle at its ruby price; PWR pays the missing resources with rubies, which the client sends only from its resource wait dialog. The Storm Islands castle choice sends a direction of 0.

Client: C2SSelectKingdomCastleVO (bundle line 34224), sent by AUnlockPrebuiltCastle.buyPrebuiltCastle (bundle line 55479), CastleSpecialServerPreBuildCastleSelectionDialog.onConfirmed (bundle line 27956) and CastleResourceWaitDialogProperties.getResourceSkipCommand (bundle line 35239)

Fields:

prebuilt_castle_id pydantic-field

prebuilt_castle_id: EnumOrInt['PrebuiltCastle']

Wire key ID

The prebuilt castle

direction pydantic-field

direction: EnumOrInt[KingdomDirection] = 0

Wire key D

The side of the map the castle is placed on; 0 for none

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

Pay the missing resources with rubies

ruby_castle pydantic-field

ruby_castle: bool = False

Wire key OC2

The castle is bought at its ruby price

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key SID

The kingdom to unlock

SelectKingdomCastleResponse pydantic-model

Bases: BaseResponse

The kingdom unlocked.

Command: ksc

Client: KSCCommand.executeCommand (bundle line 124741) reads nothing from the reply

Fields:

castle.models.mercenaries

The mercenary camp's missions.

Commands:

  • mpe: the mercenary missions, a login section of gbd and a reply; also the request that lists, starts and collects them

Classes:

Name Description
MercenaryMission

One mercenary mission, an entry of an mpe's M.

MercenaryMissionsResponse

The mercenary camp's missions and when new ones come.

MercenaryPackageRequest

List the mercenary missions, or start or collect one.

RefreshMercenaryMissionRequest

Swap an open mercenary mission for another, for MercenaryConst.REFRESH_MISSION_COST (240) rubies.

RefreshMercenaryMissionResponse

The mission was swapped; the client reads nothing from the reply.

NEXT_MISSIONS_DELAY module-attribute

NEXT_MISSIONS_DELAY = 1

CastleMercenaryData.NEXT_MISSIONS_TIMER_DELAY (bundle line 28881): seconds the client waits past NM

MercenaryMission pydantic-model

Bases: TimedPayload

One mercenary mission, an entry of an mpe's M.

Client: CastleMercenaryMissionItemVO.fillFromParamObject and remainingTime (bundle lines 81134-81135)

Fields:

mission_id pydantic-field

mission_id: ClientInt = 0

Wire key ID

The mission's id

rewards pydantic-field

rewards: CollectableRows = ()

Wire key R

The rewards

duration_seconds pydantic-field

duration_seconds: ClientNumber = 0

Wire key D

How long the mission takes

price pydantic-field

price: ClientNumber = 0

Wire key P

What starting the mission costs in coins

quality pydantic-field

Wire key Q

The mission's rarity

state pydantic-field

Wire key S

Where the mission stood when the values were read

seconds pydantic-field

seconds: ClientNumber = 0

Wire key RD

Seconds the running mission still takes when the values were read

remaining_seconds

remaining_seconds(now: float | None = None) -> float

Seconds the mission still takes, 0 at least.

seconds_past_end

seconds_past_end(now: float | None = None) -> float

Seconds since the mission's time ran out, below 0 while it still runs.

Client: CastleMercenaryMissionItemVO.remainingTime (bundle line 81135), negated and not clamped

current_state

current_state(now: float | None = None) -> MercenaryMissionState | int

Where the mission stands now: a started mission whose time has run out is collectable.

Client: CastleMercenaryData.parse_MPE and onMissionFinished (bundle lines 28829-28830, 28850)

MercenaryMissionsResponse pydantic-model

Bases: TimedResponse

The mercenary camp's missions and when new ones come.

Command: mpe, as a login section of gbd and a reply.

Client: MPECommand (bundle line 125109), CastleMercenaryData.parse_MPE (bundle line 28824), which drops collected missions (state 3 and up)

Fields:

Validators:

next_missions_seconds pydantic-field

next_missions_seconds: ClientNumber = 0

Wire key NM

Seconds until new missions come when the values were read

missions pydantic-field

missions: tuple[MercenaryMission, ...] = ()

Wire key M

The missions not collected

remaining_next_missions_seconds

remaining_next_missions_seconds(now: float | None = None) -> float

Seconds until the client asks for new missions, 0 at least.

get_mission

get_mission(mission_id: int) -> MercenaryMission | None

The mission with this id; None when the reply does not list it.

current_mission_state

current_mission_state(now: float | None = None) -> MercenaryMissionState | int

The furthest any mission stands now: OPEN while none runs or waits to be collected.

Client: CastleMercenaryData.currentMissionState (bundle line 28853), the highest state parse_MPE read (bundle line 28829), collectable once onMissionFinished fired (bundle line 28850)

MercenaryPackageRequest pydantic-model

Bases: BaseRequest

List the mercenary missions, or start or collect one.

Command: mpe Payload: {"MID": mission_id}

MID -1 lists the missions. A mission's id starts an open mission, collects a collectable one, and finishes a running one at once for rubies (CastleMercenarySkipMissionDialog.confirmSkip, bundle line 87459); client.castle.start_mission and collect_mission send it only for the first two.

Client: C2SMercenaryPackageVO (bundle line 28889); -1 from CastleMercenaryData.onNewMissions and CastleMercenaryOverviewDialog.showLoaded (bundle lines 28851, 51996), a mission's id from CastleMercenaryMissionItem.startMissionCallback and collectMissionRewards (bundle lines 87379, 87382)

Fields:

mission_id pydantic-field

mission_id: int = -1

Wire key MID

The mission to start or collect, -1 to list them

RefreshMercenaryMissionRequest pydantic-model

Bases: BaseRequest

Swap an open mercenary mission for another, for MercenaryConst.REFRESH_MISSION_COST (240) rubies.

Command: rmm Payload: {"MID": mission_id}

Client: C2SRefreshMercenaryMissionVO (bundle line 87437), sent by CastleMercenaryMissionItem.refreshMissionCallback (bundle line 87416) after CastleMercenaryRefreshMissionDialog (bundle line 87464); REFRESH_MISSION_COST (dll line 19511)

Fields:

mission_id pydantic-field

mission_id: int

Wire key MID

The open mission to swap

RefreshMercenaryMissionResponse pydantic-model

Bases: BaseResponse

The mission was swapped; the client reads nothing from the reply.

Command: rmm

Client: RMMCommand.executeCommand (bundle line 125166)

Fields:

castle.models.objects

A castle's buildings and its construction queue.

Commands:

  • scl: Show the construction list

Classes:

Name Description
BuildingRow

One placed object in a castle: a building, wall, gate, tower, ground or

ConstructionList

A castle's construction slots, the scl block.

FieldEfficiency

Resource field efficiency per resource (RA<key>).

PlacedConstructionItem

A construction item on a building: one CIL entry.

BuildingConstructionItems

The construction items on one building: one CI entry.

CastleBuildings

A castle's buildings, the gca block.

ShowConstructionListRequest

Get the joined castle's construction slots.

ShowConstructionListResponse

The joined castle's construction slots.

Functions:

Name Description
building_or_none

A reply's building row, or None when it has none or it cannot be read.

building_rows

Each readable row of a list of building rows.

Attributes:

Name Type Description
FREE_SLOT
LOCKED_SLOT

logger module-attribute

logger = logging.getLogger(__name__)

FREE_SLOT module-attribute

FREE_SLOT = -1

LOCKED_SLOT module-attribute

LOCKED_SLOT = -2

BuildingRow pydantic-model

Bases: BasePayload

One placed object in a castle: a building, wall, gate, tower, ground or fixed object, read by field position.

  • 0 wod id, 1 object id, 2 x, 3 y, 4 rotation (1 for a building inside a district); each through int()
  • 5 seconds of the running construction done, 6 state, 7 hit points, 8 the construction boost at the start, times 100, 9 efficiency, 10 damage type (0 when absent)
  • 11 onwards: values the building's type reads, such as a unit-producing building's production speed
  • 14 the district the building sits in, 15 its slot there
  • 16 the upgrade target's wod id, -1 when absent

A row may come wrapped as {"O": [...]}. Where the client reads an absent 1 to 4, 14 or 15 as 0, so does this. Fields 5 to 10 are read only by the building classes (ABasicBuildingVO), which the client picks by the wod id's group and name; this reads them whenever the row reaches index 5 and leaves them None otherwise, which is not verified to match the client's class for every wod id.

Client: IsoHelperData.createIsoObjectVOByServer (bundle line 63049), AVisualVO.parseServerObject (bundle line 17801), AIsoObjectVO.parseServerObject (bundle line 11265), ABasicBuildingVO.parseServerObject (bundle lines 17866-17868, index 5 is _constructionCompletionInSec), AUnitProductionBuildingVO.parseServerObject (bundle line 36254)

Fields:

wod_id pydantic-field

wod_id: EnumOrInt['Building']

The building type

object_id pydantic-field

object_id: int = 0

The object's id in its castle, which building commands name

x pydantic-field

x: int = 0

Castle grid x

y pydantic-field

y: int = 0

Castle grid y

rotation pydantic-field

rotation: int = 0

Rotation

construction_completed_seconds pydantic-field

construction_completed_seconds: int | None = None

Seconds of the running construction done when the row was sent

state pydantic-field

state: BuildingState | None = None

What the building is doing

hit_points pydantic-field

hit_points: int | None = None

Hit points, 100 when undamaged

construction_boost_at_start pydantic-field

construction_boost_at_start: float | None = None

The construction speed boost when the construction started, as a factor

efficiency pydantic-field

efficiency: int | None = None

Efficiency in percent

damage_type pydantic-field

damage_type: int | None = None

Damage type, 0 for none

district_id pydantic-field

district_id: int = 0

Object id of the district the building sits in, 0 for none

district_slot_id pydantic-field

district_slot_id: int = 0

The building's slot in its district

upgrade_target_wod_id pydantic-field

upgrade_target_wod_id: Literal[-1, 0] | EnumOrInt['Building']

is_in_district property

is_in_district: bool

Whether the building sits in a district.

from_list classmethod

from_list(data: Any) -> BuildingRow

Read a building row, bare or wrapped as {"O": [...]}.

Raises:

Type Description
ValueError

It is not a row.

ConstructionSlot pydantic-model

Bases: BasePayload

One construction slot of a castle.

Client: ConstructionSlotVO (bundle lines 131242-131250), filled by AreaDataConstructionList.parseList (bundle line 131170)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

position pydantic-field

position: int

The slot's place in the list, from 0

object_id pydantic-field

object_id: int

Object id of the building under construction there; FREE_SLOT (-1) or LOCKED_SLOT (-2)

is_waiting pydantic-field

is_waiting: bool = False

A waiting slot: its position is at or past the castle's construction slots

is_free property

is_free: bool

Whether nothing is being built there (ConstructionConst.SLOTSTATEUNLOCKED).

is_locked property

is_locked: bool

Whether the slot is still locked (ConstructionConst.SLOTSTATELOCKED).

ConstructionList pydantic-model

Bases: BasePayload

A castle's construction slots, the scl block.

Client: AreaDataConstructionList.parseSCL / parseList (bundle lines 131173, 131166), which read each OIDL entry through int() into a ConstructionSlotVO at its position

Fields:

Validators:

  • _slots

slots pydantic-field

slots: tuple[ConstructionSlot, ...] = ()

Wire key OIDL

The slots, in order

slot_count pydantic-field

slot_count: int | float = 1

Wire key SSC

Number of construction slots

free_slots property

free_slots: int

Number of free slots.

building_object_ids property

building_object_ids: list[int]

Object ids of the buildings under construction.

FieldEfficiency pydantic-model

Bases: _ProductionAreaSection

Resource field efficiency per resource (RA<key>).

Fields:

wood pydantic-field

wood: ClientInt = 0

Wire key RAW

stone pydantic-field

stone: ClientInt = 0

Wire key RAS

food pydantic-field

food: ClientInt = 0

Wire key RAF

coal pydantic-field

coal: ClientInt = 0

Wire key RAC

oil pydantic-field

oil: ClientInt = 0

Wire key RAO

glass pydantic-field

glass: ClientInt = 0

Wire key RAG

iron pydantic-field

iron: ClientInt = 0

Wire key RAI

aquamarine pydantic-field

aquamarine: ClientInt = 0

Wire key RAA

honey pydantic-field

honey: ClientInt = 0

Wire key RAHONEY

mead pydantic-field

mead: ClientInt = 0

Wire key RAMEAD

beef pydantic-field

beef: ClientInt = 0

Wire key RABEEF

PlacedConstructionItem pydantic-model

Bases: BasePayload

A construction item on a building: one CIL entry.

Client: ABasicBuildingVO.parseConstructionItems (bundle lines 18005-18010), which puts the item at its slot type's first index plus int(S) and gives a temporary item the RS seconds left

Fields:

construction_item_id pydantic-field

construction_item_id: EnumOrInt['ConstructionItem']

Wire key CID

The construction item

slot pydantic-field

slot: ClientInt = 0

Wire key S

Its slot among the slots of its item's slot type

remaining_seconds pydantic-field

remaining_seconds: ClientNumber = 0

Wire key RS

Seconds a temporary item has left; 0 for a permanent one

BuildingConstructionItems pydantic-model

Bases: BasePayload

The construction items on one building: one CI entry.

Client: ABasicBuildingVO.parseConstructionItems (bundle lines 18000-18006), which takes the entry whose OID is the building's

Fields:

Validators:

object_id pydantic-field

object_id: ClientInt

Wire key OID

The building's object id

items pydantic-field

Wire key CIL

Its construction items

CastleBuildings pydantic-model

Bases: BasePayload

A castle's buildings, the gca block.

The block's A (the castle's map row) and O (its owner) are kept as sent.

Client: AreaDataUpdater.parseGCA (bundle line 131497), IsoDataObjectGroupInnerBuilding.parseGCA (bundle line 80810), IsoDataObjectGroupDefence.parseGCA (bundle line 80220), IsoDataObjectGroupGround.parseGCA (bundle line 80771), IsoDataObjectGroupFixedPosition.parseGCA (bundle line 80743), AreaDataStorageItem.parseGCA (bundle line 131381), AreaDataUpdater.parseConstructionItems (bundle line 131524)

Fields:

Validators:

buildings pydantic-field

buildings: list[BuildingRow]

Wire key BD

Buildings inside the walls

walls pydantic-field

walls: list[BuildingRow]

Wire key D

The wall and the moat

gates pydantic-field

gates: list[BuildingRow]

Wire key G

The gate

towers pydantic-field

towers: list[BuildingRow]

Wire key T

The towers

grounds pydantic-field

grounds: list[BuildingRow]

Wire key BG

Ground tiles and expansions

fixed_positions pydantic-field

fixed_positions: list[BuildingRow]

Wire key FP

Objects at fixed positions

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots; None when the block has none

construction_items pydantic-field

construction_items: tuple[BuildingConstructionItems, ...] = ()

Wire key CI

The construction items on each building that has any

field_efficiency pydantic-field

field_efficiency: FieldEfficiency

Resource field efficiency per resource

all_objects

all_objects() -> list[BuildingRow]

Every object in the castle, buildings first.

find

find(object_id: int) -> BuildingRow | None

The object with this id, or None.

CarriedCastleBuildings pydantic-model

Bases: BasePayload

The castle's buildings a push or reply carries under gca.

Client: AreaDataUpdater.parseGCA and parseEBE (split.js lines 658993, 659095), handed the ebe reply and, by GCACommand.executeCommand (split.js line 628685), the gca push

Fields:

Validators:

buildings pydantic-field

buildings: CastleBuildings | None = None

Wire key gca

The castle's buildings; None when not sent or unreadable

ShowConstructionListRequest pydantic-model

Bases: BaseRequest

Get the joined castle's construction slots.

Command: scl Payload: {}

Client: C2SShowConstructionListVO (bundle line 63754)

ShowConstructionListResponse pydantic-model

Bases: ConstructionList, BaseResponse

The joined castle's construction slots.

Command: scl Payload: {"OIDL": [object_id, ...], "SSC": slot_count}

Client: SCLCommand.executeCommand (bundle line 123374)

Fields:

Validators:

  • _slots

block_or_none

block_or_none(model: type[_B], value: Any) -> _B | None

A reply's block read as model, or None when it is not an object or cannot be read.

building_or_none

building_or_none(value: Any) -> BuildingRow | None

A reply's building row, or None when it has none or it cannot be read.

building_rows

building_rows(value: Any) -> list[BuildingRow]

Each readable row of a list of building rows.

The client throws on a null or malformed entry; here one costs only itself.

castle.models.permanent

What each castle has unlocked: its units and its horses.

Commands:

  • gpc: Permanent castle data, a login section and a push

Classes:

Name Description
CastleUnitUnlocks

The units and tools a castle can recruit, and those it has still locked.

PermanentCastle

One castle's unlocked units and horses.

PermanentCastleDataResponse

Every castle's unlocked units and horses.

logger module-attribute

logger = logging.getLogger(__name__)

CastleUnitUnlocks pydantic-model

Bases: EmpireModel

The units and tools a castle can recruit, and those it has still locked.

Client: CastleUnitsVO.parseParamObject (bundle lines 139200-139207) looks each id up among the units rows and keeps the soldiers, auxiliaries and tools

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(populate_by_name=True)

unlocked_units pydantic-field

unlocked_units: tuple[UnitOrTool, ...] = ()

Wire key U

The units and tools the castle can recruit

locked_units pydantic-field

locked_units: tuple[UnitOrTool, ...] = ()

Wire key L

The units and tools still locked there

PermanentCastle pydantic-model

Bases: EmpireModel

One castle's unlocked units and horses.

Client: CastlePermanentCastleVO.parseParamObject (bundle line 139158), CastleHorsesVO.parseParamObject (bundle line 139177)

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(populate_by_name=True)

castle_id pydantic-field

castle_id: ClientInt

Wire key AID

The castle's object id

kingdom_id pydantic-field

kingdom_id: Kingdom

Wire key KID

The castle's kingdom

units pydantic-field

Wire key U

Units and tools unlocked and locked there

horse_ids pydantic-field

horse_ids: list[EnumOrInt['Horse']]

Wire key UH

The horses the castle's movements can use

PermanentCastleDataResponse pydantic-model

Bases: BaseResponse

Every castle's unlocked units and horses.

Command: gpc, as a login section of gbd and as a push Payload: {"A": [{"AID": castle_id, "KID": kingdom, "U": {"U": [wod_id, ...], "L": [wod_id, ...]}, "UH": [wod_id, ...]}, ...]}

The client never asks for it: there is no C2S constant for gpc. An update names only the castles it changes; castles it leaves out keep what they had.

Client: GPCCommand.executeCommand (bundle line 123044), CastlePermanentCastleData.parseGPC (bundle line 139128), read from gbd (bundle line 129381)

Fields:

Validators:

castles pydantic-field

Wire key A

One entry per castle

castle.models.research

Your research, starting it and shortening it with a minute skip.

Commands:

  • rei: read your research; also a login section of gbd, a push, and inside the res and msr replies
  • res: start a research
  • msr: shorten the running research with a minute skip

Finishing a research at once for rubies (C2SResearchFinishInstantVO, bundle line 49093) is left out.

Classes:

Name Description
ResearchInfoRequest

Read your research.

ResearchInfoResponse

Your research: what is finished and what runs now.

StartResearchRequest

Start a research, paying what it costs: resources and coins, or rubies for a research that costs them.

StartResearchResponse

Your research, coins and rubies, and the joined castle's resources after starting a research.

SkipResearchRequest

Shorten the running research with a minute skip.

SkipResearchResponse

Your research after a minute skip.

FinishResearchRequest

Finish the running research now, for rubies.

FinishResearchResponse

The acknowledgement of an rfi; it carries nothing.

ResearchInfoRequest pydantic-model

Bases: BaseRequest

Read your research.

Command: rei Payload: {}

Client: C2SResearchInfoVO (bundle line 79687), sent by CastleResearchDialog.showLoaded (bundle line 16731)

ResearchInfoResponse pydantic-model

Bases: TimedResponse

Your research: what is finished and what runs now.

Command: rei, as a login section of gbd, a push, and inside the res and msr replies.

Client: CastleResearchData.parse_REI (bundle line 139330), remainingResearchTimeInSeconds and isSomeResearchActive (bundle lines 139337-139338)

Fields:

bought_research_ids pydantic-field

bought_research_ids: tuple[EnumOrInt['Research'], ...] = ()

Wire key BR

Finished researches

current_research_id pydantic-field

current_research_id: Literal[-1, 0] | EnumOrInt['Research']

research_seconds pydantic-field

research_seconds: ClientNumber = 0

Wire key ARRT

Seconds left on the running research when the values were read

remaining_research_seconds

remaining_research_seconds(now: float | None = None) -> int

Whole seconds left on the running research, 0 when none runs.

is_research_active

is_research_active(now: float | None = None) -> bool

Whether a research runs: an id other than -1 with time left.

StartResearchRequest pydantic-model

Bases: BaseRequest

Start a research, paying what it costs: resources and coins, or rubies for a research that costs them.

Command: res Payload: {"RID": research_id, "PO": -1, "PWR": 0}

PWR 1 would pay missing resources with rubies (CastleResourceWaitDialogProperties.getResourceSkipCommand, bundle line 35216); this request always sends 0. A research whose own costs hold rubies (ResearchDef.cost_rubies) is sent the same way and spends them; client.castle.start_research refuses it unless asked to spend rubies.

Client: C2SResearchStartVO (bundle line 47697), sent by ResearchInfo.buyResearch (bundle line 79704) with the private offer -1 and PWR 0

Fields:

research_id pydantic-field

research_id: EnumOrInt['Research']

Wire key RID

The research to start

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

The private offer the purchase uses, -1 for none

pay_with_rubies pydantic-field

pay_with_rubies: Literal[0] = 0

Wire key PWR

Always 0: missing resources are never paid with rubies

StartResearchResponse pydantic-model

Bases: BaseResponse

Your research, coins and rubies, and the joined castle's resources after starting a research.

Command: res Payload: {"rei": {..}, "gcu": {..}, "grc": {..}}

Client: RESCommand.executeCommand (bundle line 126876), which parses all three

Fields:

research pydantic-field

research: ResearchInfoResponse | None = None

Wire key rei

Your research after

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after

resources pydantic-field

resources: CastleResources | None = None

Wire key grc

The joined castle's resources after

SkipResearchRequest pydantic-model

Bases: BaseRequest

Shorten the running research with a minute skip.

Command: msr Payload: {"MST": minute_skip}

Client: C2SMinuteSkipResearchVO (bundle line 79810), built by ResearchMinuteSkipProperties.getMinuteSkipCommand (bundle line 79784); CastleMinuteSkipDialog passes the currency's jsonKey (bundle line 7722)

Fields:

minute_skip pydantic-field

minute_skip: EnumOrStr['Currency']

Wire key MST

The minute skip used, Currency.SKIP_1_MINUTE to SKIP_24_HOURS; sent as its key

SkipResearchResponse pydantic-model

Bases: BaseResponse

Your research after a minute skip.

Command: msr Payload: {"rei": {..}}

Client: MSRCommand.executeCommand (bundle line 125829)

Fields:

research pydantic-field

research: ResearchInfoResponse | None = None

Wire key rei

Your research after

FinishResearchRequest pydantic-model

Bases: BaseRequest

Finish the running research now, for rubies.

Command: rfi Payload: {}

Client: C2SResearchFinishInstantVO (bundle line 252949), sent by ResearchProgressInfo.buyResearchInstant (bundle line 413633) and the minute skip dialog's full skip, ResearchMinuteSkipProperties.getFullSkipCommand (bundle line 413731)

FinishResearchResponse pydantic-model

Bases: BaseResponse

The acknowledgement of an rfi; it carries nothing.

Command: rfi

Client: RFICommand.executeCommand (bundle line 641922), which also takes NOTHING_TO_SKIP without an error dialog

Fields:

castle.models.resources

A castle's resources and production.

Commands:

  • grc: Get a castle's resources
  • gpa: Get the joined castle's production area

Classes:

Name Description
CastleResources

A castle's resources, the grc block.

GetResourcesRequest

Get one of your castles' resources.

GetResourcesResponse

A castle's resources.

GetProductionRequest

Get the joined castle's production area.

GetProductionResponse

The joined castle's production area.

CastleResources pydantic-model

Bases: BasePayload

A castle's resources, the grc block.

Client: CastleResourcesVO.parseGRC (bundle line 131537), which reads AID and KID through int(); AreaDataStorageItem.parseGRC (bundle line 131382) reads each amount through int()

Fields:

castle_id pydantic-field

castle_id: ClientInt = 0

Wire key AID

The castle's object id

kingdom_id pydantic-field

kingdom_id: ClientInt = 0

Wire key KID

The castle's kingdom

wood pydantic-field

wood: ClientInt = 0

Wire key W

Wood in stock

stone pydantic-field

stone: ClientInt = 0

Wire key S

Stone in stock

food pydantic-field

food: ClientInt = 0

Wire key F

Food in stock

coal pydantic-field

coal: ClientInt = 0

Wire key C

Coal in stock

oil pydantic-field

oil: ClientInt = 0

Wire key O

Oil in stock

glass pydantic-field

glass: ClientInt = 0

Wire key G

Glass in stock

iron pydantic-field

iron: ClientInt = 0

Wire key I

Iron in stock

aquamarine pydantic-field

aquamarine: ClientInt = 0

Wire key A

Aquamarine in stock

honey pydantic-field

honey: ClientInt = 0

Wire key HONEY

Honey in stock

mead pydantic-field

mead: ClientInt = 0

Wire key MEAD

Mead in stock

beef pydantic-field

beef: ClientInt = 0

Wire key BEEF

Beef in stock

GetResourcesRequest pydantic-model

Bases: BaseRequest

Get one of your castles' resources.

Command: grc Payload: {"AID": castle_id, "KID": kingdom_id}

Client: C2SGetCastleResourcesVO (bundle line 19925), sent for a castle picked in the resource transfer dialog (bundle line 38076)

Fields:

castle_id pydantic-field

castle_id: int

Wire key AID

One of your castles, CastleInfo.castle_id from client.castle.get_all() or Castle.id from client.state.get_castles()

kingdom_id pydantic-field

kingdom_id: Kingdom = Kingdom.GREEN

Wire key KID

The castle's kingdom

accepts_reply

accepts_reply(payload: Any) -> bool

Whether a grc reply is about this castle: its AID, when sent, is the one asked for.

Client: GRCCommand.exec (bundle line 123063) through AreaDataUpdater.parseGRC (bundle line 131501), which applies a reply only to the area whose id is its AID.

GetResourcesResponse pydantic-model

Bases: CastleResources, BaseResponse

A castle's resources.

Command: grc Payload: {"AID": castle_id, "KID": kingdom_id, "W": .., "S": .., "F": .., ...}

Client: GRCCommand.exec (bundle line 123063), which hands the reply to AreaDataUpdater.parseGRC (bundle line 131501)

Fields:

GetProductionRequest pydantic-model

Bases: BaseRequest

Get the joined castle's production area.

Command: gpa Payload: {}

The server answers for the castle joined with jca.

Client: C2SGetCastleProductionDataVO (bundle line 25082)

castle.models.tax

Tax collection.

Commands:

  • txi: Read the tax collection status
  • txs: Start a tax collection
  • txc: Collect the tax
  • btx: Bribe the tax collector

Classes:

Name Description
TaxInfo

The tax collection status, the TX of a txi block.

GetTaxInfoRequest

Read the tax collection status.

TaxInfoResponse

The tax collection status: the txi reply, also nested in txs and txc.

StartTaxRequest

Start a tax collection of one tax type.

StartTaxResponse

The tax status after starting a collection.

CollectTaxRequest

Collect the tax, also cutting a running collection short.

CollectTaxResponse

The collected tax.

BribeTaxCollectorRequest

Bribe the tax collector: a tax booster, bought with rubies.

BribeTaxCollectorResponse

The tax status after the bribe; its booster (boi) reaches client.state.

Attributes:

Name Type Description
TAX_DURATIONS tuple[int, ...]

Seconds each tax type collects for, by tax type 0 to 6.

TAX_RUBY_COSTS tuple[int, ...]

Rubies each tax type costs to start before any waiver, by tax type.

TAX_DURATIONS module-attribute

TAX_DURATIONS: tuple[int, ...] = (600, 1800, 5400, 10800, 21600, 43200, 86400)

Seconds each tax type collects for, by tax type 0 to 6.

Client: TaxConst.COLLECTOR_DURATION (dll line 19772)

TAX_RUBY_COSTS module-attribute

TAX_RUBY_COSTS: tuple[int, ...] = (0, 0, 0, 0, 0, 125, 300)

Rubies each tax type costs to start before any waiver, by tax type.

Types 5 and 6 cost rubies unless a premium account, a VIP level or the tax research waives it; types 1 to 4 cost a tenth of their income in coins and type 0 is free.

Client: TaxConst.START_COST_C2, START_COST_C1_PERC, getCollectorC2Costs (dll lines 19773-19779)

TaxInfo pydantic-model

Bases: BasePayload

The tax collection status, the TX of a txi block.

Client: TaxInfoVO.fillFromParamObject (bundle line 29538)

Fields:

Validators:

tax_type pydantic-field

tax_type: int = 0

Wire key TT

The running or finished collection's tax type, 0 to 6; -1 for none

remaining_seconds pydantic-field

remaining_seconds: int = 0

Wire key RT

Seconds until the collection is done, as of the reply

expected_income pydantic-field

expected_income: int = 0

Wire key EM

Coins the collection brings before boosts

population pydantic-field

population: int = 0

Wire key PO

The population the income is based on

is_boosted pydantic-field

is_boosted: bool = False

Wire key IB

Whether the collector was bribed

vip_bonus pydantic-field

vip_bonus: int = 0

Wire key VB

The VIP tax bonus in percent

status property

status: TaxStatus

Whether a collection runs or waits to be collected, as of the reply.

The client keeps the end time, the reply's time plus RT, and counts down to it: a collection is collecting while the remaining time is 0 or more, so one with RT 0 is still collecting as of the reply, and ready to collect once the end time has passed.

Client: TaxInfoVO.taxState and remainingCollectionTimeInSeconds (bundle lines 29542, 29544), fillFromParamObject (bundle line 29540)

duration_seconds property

duration_seconds: int | None

How long this tax type collects for; None for no or an unknown tax type.

GetTaxInfoRequest pydantic-model

Bases: BaseRequest

Read the tax collection status.

Command: txi Payload: {}

Client: C2SGetTaxInfoVO (bundle line 37186), sent by CastleCollectTaxStartDialog.showLoaded (bundle line 52962) and CastleCollectTaxDialog.showLoaded (bundle line 91005)

TaxInfoResponse pydantic-model

Bases: BaseResponse

The tax collection status: the txi reply, also nested in txs and txc.

Command: txi Payload: {"TX": {"TT": .., "RT": .., "EM": .., "PO": .., "IB": .., "VB": ..}}

Client: TXICommand.executeCommand (bundle line 128792), CastleTaxData.parse_TXI (bundle line 112797)

Fields:

tax pydantic-field

tax: TaxInfo

Wire key TX

The tax collection status

StartTaxRequest pydantic-model

Bases: BaseRequest

Start a tax collection of one tax type.

Command: txs Payload: {"TT": tax_type, "TX": 3}

Client: C2SStartCollectTaxVO (bundle line 91088), sent by CastleCollectTaxElement.onStartTaxCollection (bundle line 91069)

Fields:

tax_type pydantic-field

tax_type: int

Wire key TT

The tax type, 0 to 6, an index into TAX_DURATIONS

tx pydantic-field

tx: int = 3

Wire key TX

The client's TX value, always 3

StartTaxResponse pydantic-model

Bases: BaseResponse

The tax status after starting a collection.

Command: txs Payload: {"gcu": {...}, "txi": {"TX": {...}}}

Client: TXSCommand.executeCommand (bundle line 128807)

Fields:

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after the start

tax_info pydantic-field

tax_info: TaxInfoResponse | None = None

Wire key txi

The tax status after the start; None when the reply has none

CollectTaxRequest pydantic-model

Bases: BaseRequest

Collect the tax, also cutting a running collection short.

Command: txc Payload: {"TR": 29}

Client: C2SCollectTaxVO (bundle line 41083), sent by IsoServerCommands.collectTax (bundle line 63777) and CastleCollectTaxDialog.collectTax (bundle line 91027)

Fields:

tr pydantic-field

tr: int = 29

Wire key TR

The client's TR value, always 29

CollectTaxResponse pydantic-model

Bases: BaseResponse

The collected tax.

Command: txc Payload: {"gcu": {...}, "txi": {"TX": {...}}, "CT": coins}

Client: TXCCommand.executeCommand (bundle line 128747)

Fields:

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after collecting

tax_info pydantic-field

tax_info: TaxInfoResponse | None = None

Wire key txi

The tax status after collecting; None when the reply has none

collected pydantic-field

collected: int = 0

Wire key CT

Coins collected

BribeTaxCollectorRequest pydantic-model

Bases: BaseRequest

Bribe the tax collector: a tax booster, bought with rubies.

Command: btx Payload: {"PO": offer_id}

Client: CastleBribeDialog.onClick (bundle line 90878) and the booster shop (bundle line 90236) send C2S_BRIBE_TAX_COLLECTOR with CastleBoosterSaleData.getOfferId (bundle line 9696)

Fields:

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key PO

The sale the bribe uses, -1 for none

BribeTaxCollectorResponse pydantic-model

Bases: BaseResponse

The tax status after the bribe; its booster (boi) reaches client.state.

Command: btx Payload: {"gcu": {...}, "boi": {...}, "txi": {"TX": {...}}}

Client: BTXCommand.executeCommand (bundle line 128770)

Fields:

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after the bribe

tax_info pydantic-field

tax_info: TaxInfoResponse | None = None

Wire key txi

The tax status after the bribe; None when the reply has none

castle.models.updates

Castle pushes: units received, building XP, changed buildings, slum level and area booster.

Commands (all pushed by the server):

  • rue: Units received in a castle
  • fbe: A building finished
  • cbx: A building gave XP
  • gdb: Damaged buildings of the joined castle
  • gcb: Buildings of the joined castle whose efficiency changed
  • csl: The joined castle's slum level
  • gab: The joined castle's area booster
  • kik: The server's new day
  • ghw: The joined castle moved on the map
  • gca: The joined castle's buildings, whole
  • ego: A building of the joined castle changed

Classes:

Name Description
UnitsReceived

Units that finished and arrived in one of your castles: the castle's new count of that unit.

BuildingXP

XP a building in the joined castle gave.

BuildingFinished

A building in the joined castle finished, and the XP it gave.

DamagedBuildings

Buildings of the joined castle that were damaged, as their rows are now.

BuildingEfficiencyChanged

Buildings of the joined castle whose efficiency changed, as their rows are now.

SlumLevel

The joined castle's slum level.

AreaBooster

The joined castle's builder discount.

NewDay

A new day began on the server. On a Monday the client sets every castle's open-gate counter to 0.

JoinedAreaMoved

The castle you have joined now stands at a new position on the map.

CastleBuildingsPushed

The joined castle's buildings, sent whole, and its owner.

BuildingChanged

A building of the joined castle changed: the building, and the castle's construction slots and builder

UnitsReceived pydantic-model

Bases: BaseResponse

Units that finished and arrived in one of your castles: the castle's new count of that unit.

Command: rue Payload: {"AID": castle_id, "SID": kingdom_id, "WID": wod_id, "NUA": amount}

Client: RUECommand.executeCommand (bundle line 125646), CastleUserCastleListDetailed.parse_rue (bundle line 140918), CastleMilitaryData.parse_rue (bundle line 138834)

Fields:

castle_id pydantic-field

castle_id: ClientInt = 0

Wire key AID

The castle's object id

kingdom_id pydantic-field

kingdom_id: ClientInt = 0

Wire key SID

The castle's kingdom

wod_id pydantic-field

wod_id: UnitOrTool = 0

Wire key WID

The unit or tool

amount pydantic-field

amount: ClientInt = 0

Wire key NUA

How many of the unit the castle now holds

BuildingXP pydantic-model

Bases: BaseResponse

XP a building in the joined castle gave.

Command: cbx Payload: {"OID": object_id, "XP": xp}

Client: CBXCommand.executeCommand (bundle line 123345), AreaDataUpdater.parseCBX (bundle line 131521), IsoUpdaterData.onGainedBuildingPoints (bundle line 130308)

Fields:

object_id pydantic-field

object_id: int = -1

Wire key OID

The building's object id

xp pydantic-field

xp: int | float = 0

Wire key XP

The XP gained

BuildingFinished pydantic-model

Bases: BuildingXP

A building in the joined castle finished, and the XP it gave.

Command: fbe Payload: {"OID": object_id, "XP": xp}

Client: FBECommand.exec (bundle line 122879), which reads it as cbx

Fields:

DamagedBuildings pydantic-model

Bases: BaseResponse

Buildings of the joined castle that were damaged, as their rows are now.

Command: gdb Payload: {"B": [row, ...]}

Client: GDBCommand.executeCommand (bundle line 122998), AreaDataUpdater.parseGDB (bundle line 131510), IsoUpdaterData.updateMultipleObjectInfos (bundle line 130259)

Fields:

Validators:

buildings pydantic-field

buildings: list[BuildingRow]

Wire key B

The changed buildings

BuildingEfficiencyChanged pydantic-model

Bases: DamagedBuildings

Buildings of the joined castle whose efficiency changed, as their rows are now.

Command: gcb Payload: {"B": [row, ...]}

Client: GCBCommand.executeCommand (bundle line 122968), AreaDataUpdater.parseGCB (bundle line 131509)

Fields:

Validators:

SlumLevel pydantic-model

Bases: BaseResponse

The joined castle's slum level.

Command: csl Payload: {"SL": level}

Client: CSLCommand.executeCommand (bundle line 122715), AreaDataSlum.parseCSL (bundle line 131305)

Fields:

level pydantic-field

level: int = -1

Wire key SL

The slum level, -1 for none

AreaBooster pydantic-model

Bases: BaseResponse

The joined castle's builder discount.

Command: gab Payload: {"B": discount}

Client: GABCommand.executeCommand (bundle line 122923), AreaDataCommonInfo.parseGAB (bundle line 130992)

Fields:

builder_discount pydantic-field

builder_discount: int | float = 0

Wire key B

The builder discount

NewDay pydantic-model

Bases: BaseResponse

A new day began on the server. On a Monday the client sets every castle's open-gate counter to 0.

Command: kik Payload: {"DOW": day_of_week}

Client: KIKCommand.executeCommand (bundle line 123151)

Fields:

Validators:

day_of_week pydantic-field

day_of_week: EnumOrInt[Weekday] | None = None

Wire key DOW

The day that began; None when the push names no whole day

JoinedAreaMoved pydantic-model

Bases: BaseResponse

The castle you have joined now stands at a new position on the map.

Command: ghw Payload: {"X": x, "Y": y}

Client: GHWCommand.executeCommand (bundle line 129574), AreaDataModel.changePosOfOwnArea (bundle line 131929)

Fields:

x pydantic-field

Wire key X

The castle's new x position

y pydantic-field

Wire key Y

The castle's new y position

CastleBuildingsPushed pydantic-model

Bases: BaseResponse

The joined castle's buildings, sent whole, and its owner.

The client never sends gca (C2S_GET_CASTLE is declared but unused), so it arrives only from the server.

Command: gca Payload: {"O": owner, "gca": {"BD": [..], "D": [..], ...}}

Client: GCACommand.executeCommand (bundle line 122991), CastleOtherPlayerData.parseOwnerInfo (bundle line 139045), AreaDataUpdater.parseGCA (bundle line 131546)

Fields:

Validators:

owner pydantic-field

owner: MapObject | None = None

Wire key O

The castle's owner

buildings pydantic-field

buildings: CastleBuildings | None = None

Wire key gca

The castle's buildings; None when unreadable

BuildingChanged pydantic-model

Bases: BaseResponse

A building of the joined castle changed: the building, and the castle's construction slots and builder discount after.

The skill list the same push may carry is read by ObjectUpdateEvent, the registered ego model.

Command: ego Payload: {"O": row, "scl": {..}, "gab": {..}, "skl": {..}}

Client: EGOCommand.executeCommand (split.js line 628214), AreaDataUpdater.parseEGO (split.js line 659116), which hands the payload to IsoUpdaterData.updateObjectInfo (split.js line 654563), whose IsoCommandPackageObjectUpdateInfo.getRealServerObject reads the row from O; AreaDataCommonInfo.parseGAB (split.js line 656983)

Fields:

Validators:

building pydantic-field

building: BuildingRow | None = None

Wire key O

The building

construction_list pydantic-field

construction_list: ConstructionList | None = None

Wire key scl

The construction slots after; None when the push has none

area_booster pydantic-field

area_booster: AreaBooster | None = None

Wire key gab

The builder discount after; None when the push has none

castle.models.upkeep

Pushes that keep the castle screen current: construction item expiry and the resource citizen.

Commands:

  • nec: when the next construction item expires, a login section of gbd, a push and a reply
  • irc: the resource the citizen in your castle carries, a push and the reply to collecting it

Classes:

Name Description
GetConstructionItemExpiryRequest

Ask when the next of your construction items expires.

ConstructionItemExpiryResponse

When the next of your construction items expires and when one last expired, and the construction

CollectResourceCitizenRequest

Collect what the citizen walking in the joined castle carries.

ResourcePoolResponse

The resource the citizen walking in your castle carries, to collect by clicking it.

logger module-attribute

logger = logging.getLogger(__name__)

GetConstructionItemExpiryRequest pydantic-model

Bases: BaseRequest

Ask when the next of your construction items expires.

Command: nec Payload: {}

Client: C2SGetNextExpiringConstructionItemVO (bundle line 77698), sent by ConstructionItemData.onCIExpiration (bundle line 22993)

ConstructionItemExpiryResponse pydantic-model

Bases: TimedResponse

When the next of your construction items expires and when one last expired, and the construction items on the joined castle's buildings when a push lists them.

Command: nec, as a login section of gbd and a push.

Client: NECCommand.executeCommand (split.js line 629754), which hands a truthy CI to the joined area's parseConstructionItems; ConstructionItemData.parse_NEC (split.js line 120941) and hasNewExpiredItems (split.js line 121010)

Fields:

Validators:

next_expiry_seconds pydantic-field

next_expiry_seconds: ClientNumber = -1

Wire key NCRS

Seconds until the next construction item expires when the values were read, -1 for none

last_expired_at pydantic-field

last_expired_at: ClientNumber = -1

Wire key LECT

When a construction item last expired, the server's timestamp; -1 none

placed_items pydantic-field

placed_items: tuple[BuildingConstructionItems, ...] | None = None

Wire key CI

The construction items on each of the joined castle's buildings; None when not sent

remaining_seconds

remaining_seconds(now: float | None = None) -> float | None

Seconds until the next construction item expires, 0 at least; None when none will.

CollectResourceCitizenRequest pydantic-model

Bases: BaseRequest

Collect what the citizen walking in the joined castle carries.

Command: irc Payload: {}

Client: C2SIsoResourceCitizenVO (bundle line 63836), sent by IsoServerCommands.collectResourcePool (bundle line 63801)

ResourcePoolResponse pydantic-model

Bases: BaseResponse

The resource the citizen walking in your castle carries, to collect by clicking it.

Command: irc, a push and the reply to collecting the goods.

Client: IRCCommand (bundle line 123090), CastleResourcePoolData.parseIRC (bundle line 139623), which keeps the first collectable of G and sets its amount to 1000 when EG is set. The client drops it when you join a castle (JAACommand, bundle line 130194), as client.state does, and also when the citizen carrying it is collected or leaves (registerNewMovementAsOwner, bundle line 139626), which the state does not follow, so it can outlast the citizen until the next irc.

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

goods pydantic-field

goods: CollectableRows = ()

Wire key G

The goods the citizen carries

has_extra_goods pydantic-field

has_extra_goods: bool = False

Wire key EG

Whether the client counts the goods as 1000, whatever G says

castle.models.wishing_well

The ruby wishing well.

Commands:

  • rww: start, finish, collect, upgrade or read the wishing well; its level and time, a login section of gbd and the reply

Classes:

Name Description
WishingWellRequest

Act on the ruby wishing well in your main castle.

WishingWellResponse

The ruby wishing well: its level and whether it can be started, runs, or waits to be collected.

Functions:

Name Description
wishing_well_skip_rubies

The rubies finishing the running wishing well costs with seconds left: half a ruby a whole minute,

WishingWellRequest pydantic-model

Bases: BaseRequest

Act on the ruby wishing well in your main castle.

Command: rww Payload: {"PWR": 0 or 1, "_PO": -1, "WOP": option}

Keys follow the client's order: the constructor sets PWR and _PO before WOP.

Client: C2SWishingWellCommandVO (split.js line 110368)

Fields:

pay_with_rubies pydantic-field

pay_with_rubies: bool = False

Wire key PWR

Whether the resources an upgrade lacks are paid in rubies

private_offer_id pydantic-field

private_offer_id: int = -1

Wire key _PO

The private offer the payment uses, -1 for none

option pydantic-field

Wire key WOP

What to do

WishingWellResponse pydantic-model

Bases: TimedResponse

The ruby wishing well: its level and whether it can be started, runs, or waits to be collected.

Command: rww, as a login section of gbd and a successful reply; a reply refused for lack of resources is not read.

Client: RWWCommand (split.js line 641960), CastleRubyWishingWellData.parse_RWW (split.js line 110466), isReadyToStart, isReadyToCollect, isRunning and getRemainingSecondsCalculated (split.js lines 110440-110504)

Fields:

level pydantic-field

level: ClientInt = -1

Wire key L

The wishing well's level, -1 for none

seconds pydantic-field

seconds: ClientNumber = -1

Wire key RT

Seconds left when the values were read: -1 ready to start, 0 ready to collect

is_ready_to_start property

is_ready_to_start: bool

Whether the wishing well can be started, as last read.

is_ready_to_collect property

is_ready_to_collect: bool

Whether the wishing well waits to be collected, as last read.

is_running property

is_running: bool

Whether the wishing well runs, as last read.

remaining_seconds

remaining_seconds(now: float | None = None) -> int

Whole seconds until it is done, 0 at least.

wishing_well_skip_rubies

wishing_well_skip_rubies(seconds: int) -> int

The rubies finishing the running wishing well costs with seconds left: half a ruby a whole minute, 1999 at most.

Client: WishingWellConst.calculateWishingWellSkipCost (ggs.dll.js line 237), shown by RubyWishingWellDialog.updateArrow (split.js line 266252)