Skip to content

Commanders

Commanders, castellans, equipment and generals behind client.commanders and client.equipment.

commanders.service

Commanders and castellans, their generals, and their equipment.

  • CommandersService reads and renames the player's commanders and castellans, says whether the premium commander leads for free, and changes generals: assigning one to a commander, choosing its abilities, unlocking and resetting its skills, feeding it xp items, unlocking it and raising its stars with shards, and spinning the generals hub for them. A general's skills widen the flanks whatever the target is.
  • EquipmentService reads the equipment inventory, moves items on and off commanders and castellans, sells items and gems, sets gems in worn items and takes them out, crafts and enchants items, relics and gems, and reads and sets the auto-sell rules.

Modules:

Name Description
equipment

Equipment, gems and relics: the inventory, crafting, enchanting and selling.

generals

Generals: assigning them, their abilities, skills and stars, and the generals hub.

Classes:

Name Description
EquipmentService

The equipment inventory: putting items on and off commanders and castellans, selling items and gems,

CommandersService

Your commanders and castellans, renaming them, and their generals.

EquipmentService

EquipmentService(client: 'EmpireClient')

Bases: BaseService

The equipment inventory: putting items on and off commanders and castellans, selling items and gems, setting gems and taking them out, crafting and enchanting, and the auto-sell rules.

Reached as client.equipment. What a leader wears comes with client.commanders (gli EQ).

Methods:

Name Description
get_inventory

The items in the player's inventory, the ones no leader wears.

equip

Put an item on a commander or castellan.

unequip

Take an item off a commander or castellan.

sell_equipment

Sell an item for coins.

sell_gem

Sell a gem, or a relic gem, for coins.

bind_gem

Set a gem in an item a commander or castellan wears.

get_auto_sell

The auto-sell rules: which new equipment and gems the server sells as they drop.

set_auto_sell

Replace the auto-sell rules, the equipment ones and then the gem ones, as the client saves them.

get_gems

The gems and relic gems in your inventory; the reply also reaches gems.

get_inventory_space

The equipment and gem inventory space; the reply also reaches inventory_space.

get_new_relics

The relic items and relic gems you have not seen yet.

craft_equipment

Craft a new item from inventory items. The items are used up, and so are their gems unless

enchant_equipment

Enchant an item one level, for coins or, with pay_with_rubies, rubies.

enchant_relic

Enchant a relic item or relic gem one level, for relic fragments and coins or, with

craft_gem

Craft a gem a level up from a gem and gems around it. The gems around it are used up.

extract_gem

Take the gem out of an item, back into the inventory.

Attributes:

Name Type Description
gems GemInventoryResponse | None

The gems and relic gems in your inventory; None until a ggm or gec arrived.

inventory_space InventorySpace | None

The equipment and gem inventory space, from the last esl; None until one arrived.

new_relics NewRelicsResponse

Whether new relics wait to be seen, from the last nrf.

gems property

gems: GemInventoryResponse | None

The gems and relic gems in your inventory; None until a ggm or gec arrived.

inventory_space property

inventory_space: InventorySpace | None

The equipment and gem inventory space, from the last esl; None until one arrived.

new_relics property

new_relics: NewRelicsResponse

Whether new relics wait to be seen, from the last nrf.

Raises:

Type Description
StateNotLoadedError

No login has brought it

get_inventory

get_inventory(*, timeout: float = 5.0) -> list[Equipment]

The items in the player's inventory, the ones no leader wears.

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

equip

equip(equipment_id: int, commander_id: int, *, timeout: float = 5.0) -> None

Put an item on a commander or castellan.

The client moves an item between leaders by taking it off the first and then putting it on the second. The reply carries no data; re-read client.commanders.get_all() to see the change.

Parameters:

Name Type Description Default
equipment_id int

An item in the inventory, its Equipment.equipment_id from get_inventory

required
commander_id int

The leader's commander_id, a Commander or Castellan from client.commanders.get_all()

required
timeout float

Timeout in seconds

5.0

unequip

unequip(equipment_id: int, commander_id: int, *, timeout: float = 5.0) -> None

Take an item off a commander or castellan.

Parameters:

Name Type Description Default
equipment_id int

An item the leader wears, the Equipment.equipment_id of an entry in its equipment list from client.commanders.get_all()

required
commander_id int

The leader's commander_id, a Commander or Castellan from client.commanders.get_all()

required
timeout float

Timeout in seconds

5.0

sell_equipment

sell_equipment(equipment_id: int, *, commander_id: int | None = None, timeout: float = 5.0) -> None

Sell an item for coins.

The reply's commanders, coins and inventory space reach client.state.

Parameters:

Name Type Description Default
equipment_id int

An item in the inventory, its Equipment.equipment_id from get_inventory

required
commander_id int | None

The commander wearing a relic sold straight off it, as the relic enchanter sells one (RelicUpgradeDialogStatus.confirmSellCallback, bundle line 36757); None for an inventory item

None
timeout float

Timeout in seconds

5.0

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

sell_gem

sell_gem(gem: Gem | GemStack | RelicGem, *, timeout: float = 5.0) -> None

Sell a gem, or a relic gem, for coins.

Parameters:

Name Type Description Default
gem Gem | GemStack | RelicGem

A gem, a GemStack or RelicGem of gems

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

bind_gem

bind_gem(gem: Gem | GemStack | RelicGem, equipment_id: int, commander_id: int, *, timeout: float = 5.0) -> None

Set a gem in an item a commander or castellan wears.

A gem already set in the item is not taken back: the client shows it broken (CastleReplaceSocketDialog.renderIcons, bundle line 42224). Taking it back costs rubies or relic fragments and is not offered here. Setting a gem costs coins: the gem level's insertCostC1, or RelicItemConst.INSERT_RELIC_GEM_C1_COST (95000, dll line 19669) for a relic gem (ACastleSocketDialog.getCosts, bundle line 32488).

Parameters:

Name Type Description Default
gem Gem | GemStack | RelicGem

A gem, a GemStack or RelicGem of gems

required
equipment_id int

The worn item's Equipment.equipment_id, from client.commanders.get_all()

required
commander_id int

The commander_id of the commander or castellan wearing it; the client sets gems only in a worn item (EquipmentGemClickHandler.addGemToEquipment, bundle line 73572)

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

get_auto_sell

get_auto_sell(*, timeout: float = 5.0) -> AutoSellRules

The auto-sell rules: which new equipment and gems the server sells as they drop.

The client asks for them only while the auto-sell subscription effect runs.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
AutoSellRules

The rules, from the asg reply

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

set_auto_sell

set_auto_sell(rules: AutoSellRules, *, timeout: float = 5.0) -> None

Replace the auto-sell rules, the equipment ones and then the gem ones, as the client saves them.

Every gem colour is sent, 0 for one rules.gems leaves out.

Client: AutoSellVO.sendConfigToServer (bundle line 120132)

Parameters:

Name Type Description Default
rules AutoSellRules

The rules; the equipment from AUTO_SELL_SLOTS and AUTO_SELL_RARENESSES, gem levels 0 to MAX_GEM_LEVEL

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

A rule the auto-sell dialog cannot set, or a gem colour the game data lacks

GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

get_gems

get_gems(*, timeout: float = 5.0) -> GemInventoryResponse

The gems and relic gems in your inventory; the reply also reaches gems.

Client: CastleEquipmentSublayer.updateEquipmentData (bundle line 25717)

get_inventory_space

get_inventory_space(*, timeout: float = 5.0) -> InventorySpace

The equipment and gem inventory space; the reply also reaches inventory_space.

Raises:

Type Description
PacketError

The reply could not be read

Client: AMerchantBuyDialog.onInventorySpaceData (bundle line 41333), ESLCommand (bundle line 123933)

get_new_relics

get_new_relics(*, timeout: float = 5.0) -> NewRelicItemsResponse

The relic items and relic gems you have not seen yet.

Client: the equipment dialog's showLoaded (bundle line 8801)

craft_equipment

craft_equipment(equipment_ids: Sequence[int], *, extract_gems: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> Equipment

Craft a new item from inventory items. The items are used up, and so are their gems unless extract_gems takes them back first.

Taking a gem back costs its level's rubies, a relic gem relic fragments, so extract_gems needs spend_rubies. The reply's inventory space reaches inventory_space.

Parameters:

Name Type Description Default
equipment_ids Sequence[int]

The inventory items used up, their Equipment.equipment_id

required
extract_gems bool

Take the items' gems back into the inventory first

False
spend_rubies bool

Allow the rubies extract_gems costs

False
timeout float

Timeout in seconds

5.0

Returns:

Type Description
Equipment

The crafted item

Raises:

Type Description
ValueError

extract_gems without spend_rubies

CommandError

The server refused

Client: CraftingEquipmentClickHandler.onClick and extractGems (bundle lines 74125, 74129), CastleExtractGemsDialog.calculateRemovalCostsForGems (bundle line 74260)

enchant_equipment

enchant_equipment(equipment_id: int, *, pay_with_rubies: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> Equipment

Enchant an item one level, for coins or, with pay_with_rubies, rubies.

Returns:

Type Description
Equipment

The item after

Raises:

Type Description
ValueError

pay_with_rubies without spend_rubies

CommandError

The server refused; ENCHANTING_FAILED when the enchantment's chance failed

Client: the enchant dialog's pay buttons (bundle lines 59446-59448), EQECommand (bundle line 123900)

enchant_relic

enchant_relic(relic: Equipment | RelicGem, *, pay_with_rubies: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> Equipment | RelicGem

Enchant a relic item or relic gem one level, for relic fragments and coins or, with pay_with_rubies, rubies.

Parameters:

Name Type Description Default
relic Equipment | RelicGem

A relic item (Equipment.is_relic), or a relic gem, one set in an item too

required
pay_with_rubies bool

Pay in rubies instead of coins

False
spend_rubies bool

Allow those rubies

False
timeout float

Timeout in seconds

5.0

Returns:

Type Description
Equipment | RelicGem

The relic item or relic gem after

Raises:

Type Description
ValueError

relic is an item that is no relic, or pay_with_rubies without spend_rubies

CommandError

The server refused; ENCHANTING_FAILED when the enchantment's chance failed

PacketError

The reply carries no relic

Client: RelicUpgradeDialog.onBuyButtonClicked (bundle line 29490), RelicUpgradeDialogPayment.getCosts (bundle line 86002)

craft_gem

craft_gem(gem: Gem | GemStack, used_gems: Sequence[Gem | GemStack], *, pay_with_rubies: bool = False, spend_rubies: bool = False, timeout: float = 5.0) -> CraftGemResponse

Craft a gem a level up from a gem and gems around it. The gems around it are used up.

The craft can fail; its reply says whether it worked (CraftGemResponse.crafted). The ruby craft, pay_with_rubies, needs spend_rubies. The reply's inventory space reaches inventory_space.

Parameters:

Name Type Description Default
gem Gem | GemStack

The centre gem, crafted a level up

required
used_gems Sequence[Gem | GemStack]

The gems in the outer slots, used up

required
pay_with_rubies bool

The ruby craft

False
spend_rubies bool

Allow its rubies

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

pay_with_rubies without spend_rubies

CommandError

The server refused

Client: CastleGemData.craftGem (bundle line 144476), CraftingGemClickHandler.handleDialogClick (bundle lines 73941-73943)

extract_gem

extract_gem(equipment: Equipment, *, commander_id: int | None = None, spend_rubies: bool = False, timeout: float = 5.0) -> None

Take the gem out of an item, back into the inventory.

A gem costs its level's rubies, so it needs spend_rubies; a relic gem costs relic fragments.

Parameters:

Name Type Description Default
equipment Equipment

An inventory item, or one a commander wears, with a gem

required
commander_id int | None

The commander or castellan wearing it; None for an inventory item

None
spend_rubies bool

Allow the rubies a gem costs

False
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The item has no gem, or a gem without spend_rubies

CommandError

The server refused

Client: CastleGemData.extractGem (bundle line 144483), CastleExtractSocketDialog.getCosts (bundle line 65738)

CommandersService

CommandersService(client: EmpireClient)

Bases: GeneralsMixin, BaseService

Your commanders and castellans, renaming them, and their generals.

Reached as client.commanders.

Methods:

Name Description
get_all

Get commanders and castellans in one request.

get_commanders

Get every commander, whether or not it leads an army now.

get_castellans

Get all available castellans.

rename

Rename a commander or castellan.

free_premium_commanders

How many more times today the premium commander (PREMIUM_COMMANDER_ID) can lead for free.

premium_commander_is_free

Whether leading with the premium commander now costs no rubies: a premium account

premium_send

Run send and return what it returns, refusing it first when the premium commander leads and may cost

get_generals

Every general the player owns, with the skills each has unlocked.

assign_general

Assign a general to a commander; general=None takes its general away (the client sends -1,

set_general_abilities

Choose a general's abilities.

unlock_general_skill

Unlock a general skill; the skill id names the general.

reset_general_skills

Reset a general's skill tree.

add_general_xp

Feed a general xp items.

unlock_general

Unlock a general with its shards.

upgrade_general_stars

Raise a general's star level with one of its shards.

clear_general_flags

Clear a general's new and level-up flags; the next gie lists it without them.

get_generals_hub

The generals hub's characters: their free spins, and when the next free spin comes.

spin_generals_hub

Spin a hub character's tombola with an offering, free or paid.

Attributes:

Name Type Description
roster CommanderRoster

Your commanders and castellans as the last gli listed them.

travelling_commanders list[Commander]

The commanders leading one of your movements in state, returning ones included; nothing is sent.

idle_commanders list[Commander]

The commanders free to lead an army: those not in travelling_commanders; nothing is sent.

roster property

Your commanders and castellans as the last gli listed them.

Raises:

Type Description
StateNotLoadedError

No login has brought it

travelling_commanders property

travelling_commanders: list[Commander]

The commanders leading one of your movements in state, returning ones included; nothing is sent.

Availability follows the locally tracked movements, including any server-provided waiting duration. After a return expires, the commander remains listed for one second to mitigate the server still considering it busy. Outbound attacks also get one second to bridge the return packet; other outbound movements add no hold.

Raises:

Type Description
StateNotLoadedError

No login has brought the roster

Client: LordVO.isAvailableForMovement (bundle line 26656), false while any map movement that isMyMovement (BasicMapmovementVO, bundle line 19436) has the lord as its lordVO, whichever way it travels. CastleArmyData.updateMapmovements removes an expired movement without an additional commander hold. The one-second margin is library policy beyond the client.

idle_commanders property

idle_commanders: list[Commander]

The commanders free to lead an army: those not in travelling_commanders; nothing is sent.

Returning commanders become idle one second after their estimated return end. This remains a local estimate. The server may still reject a send with GGEError.LORD_IS_USED; the send surfaces that error to the caller.

Raises:

Type Description
StateNotLoadedError

No login has brought the roster

get_all

get_all(*, timeout: float = 5.0) -> GetCommandersResponse

Get commanders and castellans in one request.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
GetCommandersResponse

The full gli response

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

get_commanders

get_commanders(*, timeout: float = 5.0) -> list[Commander]

Get every commander, whether or not it leads an army now.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
list[Commander]

List of Commander objects

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

get_castellans

get_castellans(*, timeout: float = 5.0) -> list[Castellan]

Get all available castellans.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
list[Castellan]

List of Castellan objects

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

rename

rename(commander_id: int, name: str, *, timeout: float = 5.0) -> CommanderRoster

Rename a commander or castellan.

Parameters:

Name Type Description Default
commander_id int

The leader's commander_id, a Commander or Castellan from client.commanders.get_all()

required
name str

The new name; the game's dialog allows 3 to 15 characters

required
timeout float

Timeout in seconds

5.0

Returns:

Type Description
CommanderRoster

Your commanders and castellans after the rename, from the arl reply

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

free_premium_commanders

free_premium_commanders(now: float | None = None) -> int | None

How many more times today the premium commander (PREMIUM_COMMANDER_ID) can lead for free.

Your VIP level's free_premium_commanders_per_day less those used today, and 0 while no VIP time runs. It comes from state, kept current by the login data's vip and every vip the server pushes. A premium send this client made (premium_send) counts as used until the next vip arrives. A premium account makes the premium commander free on top of this: premium_commander_is_free counts both.

Example
if client.commanders.premium_commander_is_free():
    client.movements.send_support(..., commander_id=PREMIUM_COMMANDER_ID, use_premium_commander=True)

Parameters:

Name Type Description Default
now float | None

Wall-clock time to measure the VIP time left at, time.time() when not given

None

Returns:

Type Description
int | None

The count, 0 at least, or None before the login data brought your VIP

Raises:

Type Description
GameDataNotLoadedError

VIP time runs and the game data cannot be loaded

Client: CastleVIPData.remainingPremiumCommanders (bundle line 47554), the freePremiumCommandersPerDay of currentActiveVIPLevel (bundle line 47546), which is a level with none unless vipModeActive (bundle line 47550); parse_VIP (bundle line 47527) reads UPG, from GBDCommand (bundle line 129381), VIPCommand (bundle line 129941) and SBPCommand (bundle line 128320)

premium_commander_is_free

premium_commander_is_free() -> bool

Whether leading with the premium commander now costs no rubies: a premium account runs, or free_premium_commanders is 1 or more.

False when neither is known yet.

Raises:

Type Description
GameDataNotLoadedError

No premium account runs, VIP time does, and the game data cannot be loaded

Client: CastlePostAttackDialog.startAttack (bundle line 38360), which sends with a free premium commander left and otherwise asks for getFinalCostsC2(TravelConst.TRAVEL_PREMIUM_COMMANDER_COSTS_C2) rubies, 0 while premiumAccountVO.isActive; TRAVEL_PREMIUM_COMMANDER_COSTS_C2 is 125 (dll line 19872)

premium_send

premium_send(commander_id: int, use_premium_commander: bool, send: Callable[[], _Sent], *, spend_rubies: bool = False) -> _Sent

Run send and return what it returns, refusing it first when the premium commander leads and may cost rubies, unless spend_rubies.

The army sends go through this: client.movements.send_support, client.movements.send_troops, client.attack.send_attack and client.attack.send_treasure_hunt_attack. The premium commander leads when use_premium_commander is set or commander_id is PREMIUM_COMMANDER_ID; the client always sends the two together.

Library policy, not client behaviour: the server sends no vip with the send's reply (CRACommand, bundle line 125954; CDSCommand, bundle line 125939; CATCommand, bundle line 125924), so a premium send that the server accepts while no premium account runs counts as one used in free_premium_commanders until the next vip arrives. The check and the send hold one lock, so two premium sends at once cannot both take the last free one.

Parameters:

Name Type Description Default
commander_id int

The leader's commander_id

required
use_premium_commander bool

The send's BPC flag

required
send Callable[[], _Sent]

Sends the request and raises when the server refuses it

required
spend_rubies bool

Send even when the premium commander may cost rubies

False

Raises:

Type Description
PremiumCommanderCostError

The premium commander leads, premium_commander_is_free is False and spend_rubies is False

GameDataNotLoadedError

See premium_commander_is_free

Client: CastlePostAttackDialog.startAttack (bundle line 38360) sends BPC 1 exactly when the selected commander is TravelConst.COMMANDER_PREMIUM

get_generals

get_generals(*, timeout: float = 5.0) -> list[OwnedGeneral]

Every general the player owns, with the skills each has unlocked.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
list[OwnedGeneral]

Your generals, from the gie reply

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

assign_general

assign_general(commander_id: int, general: AnyGeneral | None, *, timeout: float = 5.0) -> CommanderRoster

Assign a general to a commander; general=None takes its general away (the client sends -1, CastleLordData.assignGeneral, bundle line 38679).

Parameters:

Name Type Description Default
commander_id int

A Commander.commander_id from client.commanders.get_commanders()

required
general AnyGeneral | None

The general: one of get_generals, its row from GameData.require().general(name), or a General

required
timeout float

Timeout in seconds

5.0

Returns:

Type Description
CommanderRoster

Your commanders and castellans after the change, from the gla reply

Raises:

Type Description
CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

set_general_abilities

set_general_abilities(general: AnyGeneral, abilities: Iterable[tuple[int, GeneralAbility | None]], *, timeout: float = 5.0) -> None

Choose a general's abilities.

Parameters:

Name Type Description Default
general AnyGeneral

The general: one of get_generals, its row from GameData.require().general(name), or a General

required
abilities Iterable[tuple[int, GeneralAbility | None]]

(slot_id, ability) pairs, None to clear a slot. The client sends every slot it shows. An ability id comes from GameData.require().general_ability(name, level)

required
timeout float

Timeout in seconds

5.0

unlock_general_skill

unlock_general_skill(skill_id: GeneralSkill, *, timeout: float = 5.0) -> None

Unlock a general skill; the skill id names the general.

The general's new skills arrive with the next gie.

Parameters:

Name Type Description Default
skill_id GeneralSkill

The skill level's skillID, from GameData.require().general_skill(general_id, name, level) (GeneralVO.unlockSkill, bundle line 26773)

required
timeout float

Timeout in seconds

5.0

reset_general_skills

reset_general_skills(general: AnyGeneral, *, timeout: float = 5.0) -> None

Reset a general's skill tree.

Parameters:

Name Type Description Default
general AnyGeneral

The general: one of get_generals, its row from GameData.require().general(name), or a General

required
timeout float

Timeout in seconds

5.0

add_general_xp

add_general_xp(general: AnyGeneral, currency_id: CurrencyId, amount: int, *, timeout: float = 5.0) -> None

Feed a general xp items.

Parameters:

Name Type Description Default
general AnyGeneral

The general: one of get_generals, its row from GameData.require().general(name), or a General

required
currency_id CurrencyId

The xp item's currencyID, e.g. GameData.require().currency("GXP1").currency_id (GeneralsLevelUpDialogListItem.sendXPSelected, bundle line 74485)

required
amount int

How many of the item to use

required
timeout float

Timeout in seconds

5.0

unlock_general

unlock_general(general: General, *, timeout: float = 5.0) -> None

Unlock a general with its shards.

The general must be out (not a preview) and you must hold the unlock_cost of its rarity in its unlock_currency_id shards (PlayerService.currencies). Whether it is already unlocked is not checked here, as only a gie lists the unlocked generals; the server refuses that.

Client: GeneralsOverviewDialog.updateUnlockButton (bundle line 15833) shows the button, which sends gue (bundle line 15851), while GeneralVO.canBeUnlocked (bundle line 26751)

Parameters:

Name Type Description Default
general General

The general, from GameData.require().generals

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The game data lacks the general or its rarity, it is a preview, or too few shards are held

GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

upgrade_general_stars

upgrade_general_stars(general: OwnedGeneral, currency: Currency, *, timeout: float = 5.0) -> None

Raise a general's star level with one of its shards.

A star comes at every tenth level: the general's level must be a multiple of 10, above 0, with fewer stars than its tenths and fewer than its max_star_level. The level is the general's fixed_level when it has one, else the level its rarity gives its xp. currency must be one of its upgrade_currency_ids, held (PlayerService.currencies). The client lists any held shard and does not compare the amount with the cost, GeneralRarityDef.star_upgrade_cost(star_level); neither does this.

Client: GeneralsLevelUpDialogListItem.onClick (bundle line 74481) sends gsue for an unlocked general; GeneralVO.isStarLevelUpgradeable (bundle line 26777), whose trailing || !isUnlocked only switches the dialog to unlocking, and GeneralsLevelUPDialog.updateItems (bundle line 46889) lists the held upgradeCurrencyIDs

Parameters:

Name Type Description Default
general OwnedGeneral

The general, an OwnedGeneral from get_generals

required
currency Currency

The shard to spend

required
timeout float

Timeout in seconds

5.0

Raises:

Type Description
ValueError

The game data lacks the general or its rarity, it has no star to earn, the shard is not one of its own, or none is held

GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

clear_general_flags

clear_general_flags(general: General, *, timeout: float = 5.0) -> None

Clear a general's new and level-up flags; the next gie lists it without them.

Client: GeneralVO.resetFlags (bundle line 26789), which also clears them on its own copy

Parameters:

Name Type Description Default
general General

The general, an OwnedGeneral.general_id from get_generals

required
timeout float

Timeout in seconds

5.0

get_generals_hub

get_generals_hub(*, timeout: float = 5.0) -> list[GeneralsHubCharacterStatus]

The generals hub's characters: their free spins, and when the next free spin comes.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds

5.0

Returns:

Type Description
list[GeneralsHubCharacterStatus]

Each character, from the gcs reply

Raises:

Type Description
GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

spin_generals_hub

spin_generals_hub(character: GeneralsHubCharacter, offering: Currency, *, free: bool = False, amount: int = 1, timeout: float = 5.0) -> SpinGeneralsHubResponse

Spin a hub character's tombola with an offering, free or paid.

offering must be one the character takes (GeneralsHubCharacterDef.offering_currency_ids). A free spin is one spin; a paid one spends amount offerings, which must be held (PlayerService.currencies). Whether a free spin waits is not checked here (get_generals_hub says); the server refuses one that does not. Reward ids in the reply are resolved through the game data.

Client: GeneralsHubQuestComponent.onFreeQuest and onPaidQuest (bundle lines 75148-75149), GeneralsHubRewardsComponent.onClick (bundle line 74904) and onCurrenciesUpdated (bundle line 74903), which caps the amount at the offerings held

Parameters:

Name Type Description Default
character GeneralsHubCharacter

The character

required
offering Currency

The offering to spin with

required
free bool

Take a free spin

False
amount int

Offerings to spend on a paid spin

1
timeout float

Timeout in seconds

5.0

Returns:

Type Description
SpinGeneralsHubResponse

The draws, and the character's spins after it

Raises:

Type Description
ValueError

The game data lacks the character, it takes no such offering, a free spin is asked for more than one, or fewer offerings are held than spent

GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

The request failed

commanders.models.auto_sell

The auto-sell rules: which new equipment and gems the server sells as they drop.

Commands:

  • asg: the rules
  • aes: set the equipment rules
  • ags: set the gem rules

Classes:

Name Description
AutoSellEquipment

One kind of equipment the server sells as it drops: a slot and a rarity.

AutoSellRules

Which new equipment and gems the server sells as they drop.

GetAutoSellRequest

Request the auto-sell rules.

GetAutoSellResponse

The auto-sell rules.

SetAutoSellEquipmentRequest

Set the equipment the server sells as it drops.

SetAutoSellGemsRequest

Set, per gem colour, the level up to which the server sells gems as they drop.

Attributes:

Name Type Description
AUTO_SELL_SLOTS

The slots the auto-sell dialog offers: AutoSellEquipmentsVO.SLOT_ORDER (bundle line 46722).

AUTO_SELL_RARENESSES

The rarities it offers in each, the hero's too: AutoSellEquipmentsVO.RARITY_ORDER (bundle line 46722).

MAX_GEM_LEVEL

The highest gem level a gem rule takes: GemConst.MAX_GEM_LEVEL (dll line 19382).

AUTO_SELL_SLOTS module-attribute

AUTO_SELL_SLOTS = (EquipmentSlot.HERO, EquipmentSlot.HELMET, EquipmentSlot.ARMOR, EquipmentSlot.WEAPON, EquipmentSlot.ARTIFACT)

The slots the auto-sell dialog offers: AutoSellEquipmentsVO.SLOT_ORDER (bundle line 46722).

AUTO_SELL_RARENESSES module-attribute

AUTO_SELL_RARENESSES = (Rareness.COMMON, Rareness.RARE, Rareness.EPIC, Rareness.LEGENDARY)

The rarities it offers in each, the hero's too: AutoSellEquipmentsVO.RARITY_ORDER (bundle line 46722).

MAX_GEM_LEVEL module-attribute

MAX_GEM_LEVEL = 13

The highest gem level a gem rule takes: GemConst.MAX_GEM_LEVEL (dll line 19382).

AutoSellEquipment pydantic-model

Bases: BasePayload

One kind of equipment the server sells as it drops: a slot and a rarity.

The rarity is the base one for every slot; on the wire a hero item's is in the hero range, Rareness.HERO_COMMON - 1 above it.

Client: C2SSetAutoSellEquipmentConditionsEventVO (bundle line 73734) and AutoSellEquipmentsVO.parseASG (bundle line 46681)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

slot pydantic-field

The slot, one of AUTO_SELL_SLOTS

rareness pydantic-field

rareness: EnumOrInt[Rareness]

The rarity, one of AUTO_SELL_RARENESSES

from_wire classmethod

from_wire(row: Any) -> AutoSellEquipment | None

An ECS row [slot, rarity]; None for one the dialog has no box for, which the client ignores.

to_wire

to_wire() -> list[int]

The ECS row [slot, rarity].

AutoSellRules pydantic-model

Bases: BasePayload

Which new equipment and gems the server sells as they drop.

gems holds, per gem colour, the level up to which its gems are sold; 0 sells none.

Client: AutoSellVO (bundle line 120130), AutoSellGemsVO (bundle line 120147), whose slider runs from 0 to GemConst.MAX_GEM_LEVEL (AutoSellDialogGemsItem.init, bundle line 73837)

Fields:

Validators:

equipment pydantic-field

equipment: tuple[AutoSellEquipment, ...] = ()

Wire key ECS

The kinds of equipment sold

gems pydantic-field

gems: dict[EnumOrInt['GemColor'], int]

Wire key GCS

Per gem colour, the highest level sold; 0 for none

GetAutoSellRequest pydantic-model

Bases: BaseRequest

Request the auto-sell rules.

Command: asg Payload: {}

The client asks only while the auto-sell subscription effect runs.

Client: C2SGetAutoSellConditionsEventVO (bundle line 120114), SubscriptionData.parseSIE (bundle lines 119994, 120002)

GetAutoSellResponse pydantic-model

Bases: BaseResponse, AutoSellRules

The auto-sell rules.

Command: asg Payload: {"ECS": [[slot, rarity], ..], "GCS": [[level, gem colour], ..]}

Client: ASGCommand (bundle line 128666), AutoSellVO.parseASG (bundle line 120131)

Fields:

Validators:

SetAutoSellEquipmentRequest pydantic-model

Bases: BaseRequest

Set the equipment the server sells as it drops.

Command: aes Payload: {"ECS": [[slot, rarity], ..]}

The server replies with no body.

Client: C2SSetAutoSellEquipmentConditionsEventVO (bundle line 73725), AESCommand (bundle line 128625)

Fields:

equipment pydantic-field

equipment: tuple[AutoSellEquipment, ...]

Wire key ECS

The kinds of equipment sold; sent as [slot, rarity] rows

SetAutoSellGemsRequest pydantic-model

Bases: BaseRequest

Set, per gem colour, the level up to which the server sells gems as they drop.

Command: ags Payload: {"GCS": [[level, gem colour], ..]}

The client sends every gem colour. The server replies with no body.

Client: C2SSetAutoSellGemConditionsEventVO (bundle line 120180), AGSCommand (bundle line 128638)

Fields:

gems pydantic-field

gems: dict[EnumOrInt['GemColor'], int]

Wire key GCS

Per gem colour, the highest level sold; sent as [level, colour] rows

commanders.models.equipment

Equipment models and equipment inventory commands.

Commands:

  • gei: Get Equipment Inventory - the items no commander or castellan wears
  • eeq: Equip Equipment - put an item on a commander or castellan, or take it off
  • seq: sell an item
  • sge: sell a gem or relic gem
  • bge: set a gem in a worn item

Classes:

Name Description
EquipmentBonus

One bonus of an item that is not a relic: [effect_id, values].

RelicBonus

One bonus of a relic item: [relic_effect_id, power, values].

RelicGem

The gem set in a relic item: [gem_id, relic_type_id, relic_category_id, might, bonuses, enchantment_level].

RelicInfo

What a relic item carries at index 12: [relic_type_id, relic_category_id, might, gem].

Equipment

An equipment item worn by a commander or castellan.

GetEquipmentInventoryRequest

Request the player's equipment inventory.

GetEquipmentInventoryResponse

The player's equipment inventory.

EquipEquipmentRequest

Put an item on a commander or castellan (equip=1), or take it off (equip=0).

SellEquipmentRequest

Sell an item for coins.

SellGemRequest

Sell a gem or relic gem for coins.

BindGemRequest

Set a gem or relic gem in an item a commander or castellan wears.

Attributes:

Name Type Description
logger
NO_GEM_ID

logger module-attribute

logger = logging.getLogger(__name__)

NO_GEM_ID module-attribute

NO_GEM_ID = -1

EquipmentBonus pydantic-model

Bases: BasePayload

One bonus of an item that is not a relic: [effect_id, values].

Client: BasicEquipmentVO.parseBonuses (bundle line 7135), which wraps a value that is not an array into one; EquipmentXml.getEquippableEffectByEquipmentEffect (bundle line 144242) reads the id as an equipment effect, and as a plain effect when no equipment effect has it.

Fields:

Validators:

  • _from_row

effect_id pydantic-field

effect_id: EnumOrInt['EquipmentEffect', 'Effect']

The equipment effect, or the plain effect of an id no equipment effect has

values pydantic-field

values: list[Any]

Value array; its layout depends on the effect type

RelicBonus pydantic-model

Bases: BasePayload

One bonus of a relic item: [relic_effect_id, power, values].

Client: RelicItemInfoVO.parseRelicBoni (bundle line 33743), RelicBonusVO.parseRelicFromValueArray (bundle line 45132), which looks the id up in the relic effect table and parses row[2].toString(), so a value and a one-value array read the same.

Fields:

Validators:

  • _from_row

relic_effect_id pydantic-field

relic_effect_id: int

Relic effect id

power pydantic-field

power: float = 0

Power

values pydantic-field

values: list[Any]

Value array

RelicGem pydantic-model

Bases: BasePayload

The gem set in a relic item: [gem_id, relic_type_id, relic_category_id, might, bonuses, enchantment_level].

Client: RelicGemVO.parseServerObject (bundle line 22222)

Fields:

Validators:

  • _from_row

gem_id pydantic-field

gem_id: int

Gem id

relic_type_id pydantic-field

relic_type_id: int = 0

Relic type id

relic_category_id pydantic-field

relic_category_id: int = 0

Relic category id

might pydantic-field

might: int | float = 0

Might

bonuses pydantic-field

bonuses: list[RelicBonus]

The gem's relic bonuses

enchantment_level pydantic-field

enchantment_level: ClientInt = 0

Enchantment level

RelicInfo pydantic-model

Bases: BasePayload

What a relic item carries at index 12: [relic_type_id, relic_category_id, might, gem].

Client: RelicEquipmentVO.parseEquipFromArray (bundle line 25039)

Fields:

Validators:

  • _from_row
  • _gem_or_none → gem

relic_type_id pydantic-field

relic_type_id: int = 0

Relic type id

relic_category_id pydantic-field

relic_category_id: int = 0

Relic category id

might pydantic-field

might: int | float = 0

Might

gem pydantic-field

gem: RelicGem | None = None

The gem set in the relic; None when there is none

Equipment pydantic-model

Bases: BasePayload

An equipment item worn by a commander or castellan.

Parsed from a positional EQ entry: [id, slot, wearer, rarity, graphic, bonuses, unique_id, set_id, enchantment_level, duration_seconds, gem_id, equipment_type] Entries are truncated by the server when trailing fields do not apply.

Index 5 holds the bonuses: a relic item (index 11 is 3) lists them as relic_bonuses ([relic_effect_id, power, values]), any other item as bonuses ([effect_id, values]). A hero item (slot 6, not a relic) also keeps index 11 as alien_string, which the client matches against the unique heroes (CastleEquipmentData.getUniqueHerosByAlienString, bundle line 143843); the type is still read from it through int().

Client: BasicEquipmentVO.parseEquipFromArray (bundle line 7115), CastleEquipmentFactory.createEquipmentVO (bundle line 18134), RelicEquipmentVO.parseEquipFromArray (bundle line 25039), CastleHeroVO.parseEquipFromArray (bundle line 40585), BasicEquipmentVO.hasSetbonus (bundle line 7213).

Fields:

Validators:

equipment_id pydantic-field

equipment_id: int = 0

Item id

slot pydantic-field

slot: int = 0

Slot type id

wearer_type pydantic-field

wearer_type: int = WearerType.UNDEFINED

Who can wear it (WearerType)

rarity_id pydantic-field

rarity_id: ClientInt = 0

Rarity id

graphic pydantic-field

graphic: int | str = 0

The item's graphic

bonuses pydantic-field

bonuses: list[EquipmentBonus]

Bonuses of an item that is not a relic

relic_bonuses pydantic-field

relic_bonuses: list[RelicBonus]

Bonuses of a relic item

unique_id pydantic-field

unique_id: ClientInt = 0

Unique item id

set_id pydantic-field

set_id: ClientInt = 0

Equipment set id, -1 for none; 0, which no set uses, when the row has none

enchantment_level pydantic-field

enchantment_level: ClientInt = 0

Enchantment level

duration_seconds pydantic-field

duration_seconds: int | float = 0

Seconds until the item expires; below 1 it is permanent

gem_id pydantic-field

gem_id: EnumOrInt['Gem'] | None = None

The slotted gem; None for none

equipment_type pydantic-field

equipment_type: ClientInt = EquipmentType.GENERATED

EquipmentType value

relic_info pydantic-field

relic_info: RelicInfo | None = None

A relic item's type, category, might and gem; None for other items

alien_string pydantic-field

alien_string: str | None = None

A hero item's alien string, "effect_id&value" pairs joined by ","; None for other items. A number the server sends there is kept as its text

is_permanent property

is_permanent: bool

True when the item does not expire (the server sends -1).

has_gem property

has_gem: bool

True when a gem is slotted.

has_set property

has_set: bool

True unless set_id is -1, as the client's hasSetbonus reads it.

is_relic property

is_relic: bool

True for a relic item, whose bonuses index the relic effect table.

rarity_enum property

rarity_enum: Rareness | None

rarity_id as a Rareness, None for a value the client does not define.

from_list classmethod

from_list(data: list[Any]) -> 'Equipment'

Parse from an EQ array entry, tolerating short entries.

GetEquipmentInventoryRequest pydantic-model

Bases: BaseRequest

Request the player's equipment inventory.

Command: gei Payload: {} Client: C2SGetEquipmentInventory (bundle line 19854)

GetEquipmentInventoryResponse pydantic-model

Bases: BaseResponse

The player's equipment inventory.

Command: gei Payload: {"I": [EQ entry, ...]}, each entry laid out as a gli EQ entry.

Client: CastleEquipmentData.parse_GEI (bundle line 143731), which builds every entry with CastleEquipmentFactory.createEquipmentVO (bundle line 18134).

Fields:

Validators:

  • _readable_items → items

items pydantic-field

items: list[Equipment]

Wire key I

Inventory items

EquipEquipmentRequest pydantic-model

Bases: BaseRequest

Put an item on a commander or castellan (equip=1), or take it off (equip=0).

Moving an item between two leaders takes two requests: the client takes it off the first, then puts it on the second. The reply has no body.

Command: eeq Payload: {"EID": equipment_id, "LID": commander_id, "E": 0 or 1} Client: C2SEquipEquipmentVO (bundle line 143914) sends E as int(n?1:0); CastleEquipmentData.startDrag (bundle line 143801) sends 0 when an item is lifted off a leader's slot, stopDrag (bundle line 143807) sends 1 when it is dropped on one, and EquipmentEquipmentClickHandler.init (bundle line 65626) handles the 0 reply as an unequip.

Fields:

Validators:

equipment_id pydantic-field

equipment_id: int

Wire key EID

Equipment.equipment_id: of an inventory item from client.equipment.get_inventory() to equip, of a worn one from client.commanders.get_all() to take off

commander_id pydantic-field

commander_id: int

Wire key LID

The commander_id of a Commander or Castellan from client.commanders.get_all()

equip pydantic-field

equip: int

Wire key E

1 puts the item on the leader, 0 takes it off

SellEquipmentRequest pydantic-model

Bases: BaseRequest

Sell an item for coins.

Command: seq Payload: {"EID": equipment_id, "LID": commander_id, "EX": 0, "LFID": lost_and_found_id}

LID is -1 but for a relic sold straight off the commander who wears it, LFID -1 but for an item in the lost and found; EX is 0, the client never sets it. The reply's gli, gcu and esl update the commanders, coins and inventory space in client.state.

Client: C2SSellEquipmentVO (bundle line 143923), CastleEquipmentData.sell (bundle line 143798); RelicUpgradeDialogStatus.confirmSellCallback (bundle line 36757) passes the commander, LostAndFoundListItem (bundle line 107164) the lost and found id; SEQCommand (bundle line 124024)

Fields:

equipment_id pydantic-field

equipment_id: int

Wire key EID

The item, an Equipment.equipment_id

commander_id pydantic-field

commander_id: int = -1

Wire key LID

The commander wearing a relic sold off it; -1 for none

extract pydantic-field

extract: int = 0

Wire key EX

Always 0

lost_and_found_id pydantic-field

lost_and_found_id: int = -1

Wire key LFID

The lost and found entry sold; -1 for none

SellGemRequest pydantic-model

Bases: BaseRequest

Sell a gem or relic gem for coins.

Command: sge Payload: {"GID": gem_id, "RGEM": 1 or 0, "LFID": lost_and_found_id}

The server replies with no body.

Client: C2SSellGemVO (bundle line 144479), CastleGemData.sell (bundle line 144376), which sends RGEM 1 for a RelicGemVO; SGECommand (bundle line 124034)

Fields:

gem_id pydantic-field

gem_id: int

Wire key GID

The gem, or the relic gem's gem_id

relic_gem pydantic-field

relic_gem: bool = False

Wire key RGEM

A relic gem; sent as 1 or 0

lost_and_found_id pydantic-field

lost_and_found_id: int = -1

Wire key LFID

The lost and found entry sold; -1 for none

BindGemRequest pydantic-model

Bases: BaseRequest

Set a gem or relic gem in an item a commander or castellan wears.

Command: bge Payload: {"GID": gem_id, "EID": equipment_id, "LID": commander_id, "M": 0, "RGEM": 1 or 0}

M 1 takes the gem already set back into the inventory, for rubies or relic fragments (CastleReplaceSocketDialog.getRemovalCosts, bundle line 42226), and is not sent here. The server replies with no body.

Client: C2SBindGem (bundle line 144452), CastleGemData.bindGem (bundle line 144353); BGECommand (bundle line 123713)

Fields:

gem_id pydantic-field

gem_id: int

Wire key GID

The gem, or the relic gem's gem_id

equipment_id pydantic-field

equipment_id: int

Wire key EID

The worn item, an Equipment.equipment_id

commander_id pydantic-field

commander_id: int

Wire key LID

The commander or castellan wearing it

keep_old_gem pydantic-field

keep_old_gem: int = 0

Wire key M

Always 0: the gem already set is not taken back

relic_gem pydantic-field

relic_gem: bool = False

Wire key RGEM

A relic gem; sent as 1 or 0

commanders.models.generals

Generals progression: unlocking a general, raising its stars, and the generals hub's spins.

Commands:

  • gue: unlock a general with its shards
  • gsue: raise a general's star level with shards
  • grf: clear a general's new and level-up flags
  • gcs: the generals hub's characters, their free spins and cooldowns
  • sct: spin a hub character's tombola with an offering

Classes:

Name Description
UnlockGeneralRequest

Unlock a general with its shards.

UpgradeGeneralStarsRequest

Raise a general's star level with one of its shards.

ClearGeneralFlagsRequest

Clear a general's new and level-up flags.

GetGeneralsHubRequest

Request the generals hub's characters.

GeneralsHubCharacterStatus

One character of the generals hub: its free spins and when the last was taken.

GetGeneralsHubResponse

The generals hub's characters.

SpinGeneralsHubRequest

Spin a hub character's tombola with an offering.

GeneralsHubReward

One draw of a spin: rows of collectables (RR) or reward ids (RW), given count times.

SpinGeneralsHubResponse

What a spin gave, and the character's spins after it.

UnlockGeneralRequest pydantic-model

Bases: BaseRequest

Unlock a general with its shards.

Command: gue Payload: {"GID": general_id}

The server replies with no body.

Client: C2SGeneralUnlockVO (bundle line 41682), GUECommand (bundle line 124266)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general to unlock

UpgradeGeneralStarsRequest pydantic-model

Bases: BaseRequest

Raise a general's star level with one of its shards.

Command: gsue Payload: {"GID": general_id, "CID": currency_id}

The server replies with no body.

Client: C2SGeneralStarUpgradeVO (bundle line 74516), GSUECommand (bundle line 124253)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general to raise

currency_id pydantic-field

currency_id: EnumOrInt['CurrencyId']

Wire key CID

The shard to spend

ClearGeneralFlagsRequest pydantic-model

Bases: BaseRequest

Clear a general's new and level-up flags.

Command: grf Payload: {"GID": general_id}

The server replies with no body.

Client: C2SGeneralResetFlagsVO (bundle line 67451), GRFCommand (bundle line 124229)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general

GetGeneralsHubRequest pydantic-model

Bases: BaseRequest

Request the generals hub's characters.

Command: gcs Payload: {}

Client: C2SGeneralsHUBStatusVO (bundle line 113160, no fields)

GeneralsHubCharacterStatus pydantic-model

Bases: BasePayload

One character of the generals hub: its free spins and when the last was taken.

Client: GeneralsHubQuestVO.parseServerObject (bundle line 47009)

Fields:

character_id pydantic-field

character_id: EnumOrInt['GeneralsHubCharacter']

Wire key CID

The character

free_spins pydantic-field

free_spins: ClientInt = 0

Wire key FOA

Free spins waiting

last_free_spin pydantic-field

last_free_spin: ClientNumber = 0

Wire key LFO

When the last free spin was taken, in epoch seconds

cooldown_ends_at pydantic-field

cooldown_ends_at: int | float | None = None

When the next free spin comes, in epoch seconds: last_free_spin plus the character's cooldown_seconds; set by client.commanders, None when the game data lacks the character

GetGeneralsHubResponse pydantic-model

Bases: BaseResponse

The generals hub's characters.

Command: gcs Payload: {"CHR": [{"CID": character, "FOA": free spins, "LFO": last free spin}, ..]}

Client: GCSCommand (bundle line 124187), GeneralsData.parse_GCS (bundle line 113080)

Fields:

Validators:

characters pydantic-field

Wire key CHR

Each character's spins

SpinGeneralsHubRequest pydantic-model

Bases: BaseRequest

Spin a hub character's tombola with an offering.

Command: sct Payload: {"CID": character, "OID": offering, "IF": 1 or 0, "AMT": amount}

A free spin is one, sent with IF 1; a paid one spends AMT of the offering.

Client: C2SSpinCharacterTombolaVO (bundle line 46994), GeneralsHubQuestComponent.onFreeQuest and onPaidQuest (bundle lines 75148-75149), GeneralsHubRewardsComponent.onClick (bundle line 74904)

Fields:

character_id pydantic-field

character_id: EnumOrInt['GeneralsHubCharacter']

Wire key CID

The character

offering_id pydantic-field

offering_id: EnumOrInt['CurrencyId']

Wire key OID

The offering, one of the character's offering_currency_ids

free pydantic-field

free: bool = False

Wire key IF

A free spin; sent as 1 or 0

amount pydantic-field

amount: int = 1

Wire key AMT

Offerings to spend; 1 for a free spin

GeneralsHubReward pydantic-model

Bases: BasePayload

One draw of a spin: rows of collectables (RR) or reward ids (RW), given count times.

client.commanders.spin_generals_hub resolves reward ids into rewards through the game data.

Client: GeneralsHubRewardsComponent.onRewardsGained (bundle line 74934) reads RR over RW and adds the list A times, once when A is unset

Fields:

Validators:

rarity pydantic-field

rarity: ClientInt = 0

Wire key R

The draw's rarity

rewards pydantic-field

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

Wire key RR

What one draw gave

reward_ids pydantic-field

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

Wire key RW

The rewards drawn

count pydantic-field

count: int = 1

Wire key A

How many times the draw was given

SpinGeneralsHubResponse pydantic-model

Bases: BaseResponse

What a spin gave, and the character's spins after it.

Command: sct Payload: {"CH": {"CID": .., "FOA": .., "LFO": ..}, "LTR": [{"R": rarity, "RR": rows | "RW": ids, "A": count}, ..]}

Client: SCTCommand (bundle line 124303), GeneralsData.parse_SCT (bundle line 113073)

Fields:

Validators:

character pydantic-field

Wire key CH

The character after the spin

rewards pydantic-field

Wire key LTR

The draws

commanders.models.inventory

The equipment and gem inventory, as the login data and its pushes send it.

Commands:

  • ggm: the gems and relic gems you hold (gec: a change to the gems)
  • esl: the equipment and gem inventory space
  • nrf: whether new relics wait to be seen

Classes:

Name Description
GemStack

How many of one gem you hold.

GetGemsRequest

Ask for the gems and relic gems in your inventory.

GemInventoryResponse

The gems and relic gems in your inventory, not set in any equipment.

GetInventorySpaceRequest

Ask for the equipment and gem inventory space.

InventorySpace

Free and total space in the equipment and gem inventory.

NewRelicsResponse

Whether new relic equipment waits to be seen.

GemStack pydantic-model

Bases: BasePayload

How many of one gem you hold.

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

gem_id pydantic-field

gem_id: EnumOrInt['Gem']

The gem

amount pydantic-field

amount: int

How many you hold

GemChange pydantic-model

Bases: BasePayload

One [gem_id, amount] row of a gec: gems added, or taken away for a negative amount.

Fields:

Validators:

  • _from_row

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

gem_id pydantic-field

gem_id: EnumOrInt['Gem']

The gem

amount pydantic-field

amount: ClientInt

How many are added; negative for taken away

GemsChangedResponse pydantic-model

Bases: BaseResponse

Gems added to or taken from your inventory.

Command: gec, a push.

Client: GECCommand.executeCommand (bundle line 123969), CastleGemData.parse_GEC (bundle line 144432) and updateInventory (bundle line 144440), which read each row's id and amount through int(); a row that is no pair is skipped here

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

changes pydantic-field

changes: tuple[GemChange, ...] = ()

Wire key GEM

The gems added or taken away, in the order sent

GetGemsRequest pydantic-model

Bases: BaseRequest

Ask for the gems and relic gems in your inventory.

Command: ggm Payload: {}

Client: C2SGetGemInventory (bundle line 22746), sent when the equipment screen updates (CastleEquipmentSublayer.updateEquipmentData, bundle line 25717)

GemInventoryResponse pydantic-model

Bases: BaseResponse

The gems and relic gems in your inventory, not set in any equipment.

Command: ggm, as a login section of gbd and a reply. A gec push changes the gems; client.state.get_gems() applies it with changed.

Client: GGMCommand (bundle line 123957), CastleGemData.parseGGM, updateInventory and updateRelicInventory (bundle lines 144327, 144334, 144427); GECCommand (bundle line 123969) and parse_GEC (bundle line 144432). The client keeps one entry per gem and takes a negative amount off from the first entry of that gem on; here the gems are counted per id.

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

gems pydantic-field

gems: tuple[GemStack, ...] = ()

Wire key GEM

The gems you hold, per gem id

relic_gems pydantic-field

relic_gems: tuple[RelicGem, ...] = ()

Wire key RGEM

The relic gems you hold

amount

amount(gem_id: int) -> int

How many of a gem you hold.

changed

This inventory after a gec: each change adds its amount, a negative one takes away.

GetInventorySpaceRequest pydantic-model

Bases: BaseRequest

Ask for the equipment and gem inventory space.

Command: esl Payload: {}

The reply is read into client.state: its E is the equipment space, not an error code.

Client: C2SEquipmentSpaceLeftVO (bundle line 41423), sent by AMerchantBuyDialog.onInventorySpaceData (bundle line 41333)

InventorySpace pydantic-model

Bases: BasePayload

Free and total space in the equipment and gem inventory.

Not a response model: its E is the equipment space, not an error code.

Command: esl, as a login section of gbd, a push and a reply, and inside the bgm, ceq, cge, frc and seq replies.

Client: ESLCommand (bundle line 123895), CastleEquipmentData.parse_ESL (bundle line 143746) and CastleGemData.parse_ESL (bundle line 144410). The client recounts the free gem space from the total and the gems it holds whenever they change (updateInventorySpace, bundle line 144417); gem_space is the value the server sent. The equipment inventory counts as full at equipment_space 0 or less, and holds equipment_total_space - equipment_space items (isInventoryFull and filledInventorySpace, bundle lines 143839, 143841).

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

equipment_space pydantic-field

equipment_space: ParseInt = 0

Wire key E

Free equipment inventory space; negative when you hold more than fits, full at 0 or less

equipment_total_space pydantic-field

equipment_total_space: ParseInt = 0

Wire key TE

Total equipment inventory space

gem_space pydantic-field

gem_space: ClientInt = 0

Wire key G

Free gem inventory space, as sent

gem_total_space pydantic-field

gem_total_space: ClientInt = 0

Wire key TG

Total gem inventory space

NewRelicsResponse pydantic-model

Bases: BaseResponse

Whether new relic equipment waits to be seen.

Command: nrf, as a login section of gbd and a push.

Client: NRFCommand (bundle line 124002), CastleEquipmentData.parseNRF (bundle line 143756)

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

has_new_relics pydantic-field

has_new_relics: bool = False

Wire key NR

Whether new relics wait to be seen

commanders.models.roster

Commander protocol models.

Commands:

  • gli: Get Lords Info - the server name for the commander/castellan list
  • arl: rename a commander or castellan

Classes:

Name Description
CommanderEffect

One entry of a commander's E or AE: [effect_id, values, source].

SelectedAbility

One ability slot of a general: a [slot_id, ability_id] pair, as GASAIDS sends it and SAIDS takes it.

AlienEquipment

Alien (AIE) or temporary (TAE) equipment: [effect_id, values] rows, or

LeaderBase

Fields shared by every gli entry.

Commander

A commander - the leader assigned to an attack or support movement.

Castellan

A castellan - the defensive counterpart of a commander (BaronVO).

GetCommandersRequest

Request the commander and castellan list.

CommanderRoster

A player's commanders and castellans, the gli block.

GetCommandersResponse

Response containing commanders (C) and castellans (B).

RenameCommanderRequest

Rename a commander or castellan.

RenameCommanderResponse

Reply to a rename: the full commander and castellan list.

Attributes:

Name Type Description
logger
CommanderEffects

[effect_id, values, source] rows; unreadable entries are skipped, as the client skips

PICTURE_BERIMOND_CASTELLAN

EquipmentConst.PICK_BARON_FACTION (dll line 19249)

PICTURE_STORM_ISLANDS_CASTELLAN

EquipmentConst.PICK_BARON_ISLAND (dll line 19249)

BERIMOND_BARON_ID

FactionConst.BARON_ID (dll line 19333)

PREMIUM_COMMANDER_ID

TravelConst.COMMANDER_PREMIUM (dll line 19872): the premium commander's commander_id;

CASTELLAN_PICTURE_ORDER

BaronVO.PIC_ID_ORDER (bundle line 43551): castellans are listed in this portrait order

logger module-attribute

logger = logging.getLogger(__name__)

CommanderEffects module-attribute

[effect_id, values, source] rows; unreadable entries are skipped, as the client skips effects it cannot resolve (LordVO.parseRawEffects, bundle line 26483).

PICTURE_BERIMOND_CASTELLAN module-attribute

PICTURE_BERIMOND_CASTELLAN = 5

EquipmentConst.PICK_BARON_FACTION (dll line 19249)

PICTURE_STORM_ISLANDS_CASTELLAN module-attribute

PICTURE_STORM_ISLANDS_CASTELLAN = 13

EquipmentConst.PICK_BARON_ISLAND (dll line 19249)

BERIMOND_BARON_ID module-attribute

BERIMOND_BARON_ID = -16

FactionConst.BARON_ID (dll line 19333)

PREMIUM_COMMANDER_ID module-attribute

PREMIUM_COMMANDER_ID = -14

TravelConst.COMMANDER_PREMIUM (dll line 19872): the premium commander's commander_id; the client offers it from ClientConstLevelRestrictions.MIN_LEVEL_SELECT_PREMIUM_COMMANDER, level 10 (bundle line 2139)

CASTELLAN_PICTURE_ORDER module-attribute

CASTELLAN_PICTURE_ORDER = (0, 6, 7, 8, 1, 13, 2, 3, 4, 10, 11, 12, 9, 5)

BaronVO.PIC_ID_ORDER (bundle line 43551): castellans are listed in this portrait order

CommanderEffect pydantic-model

Bases: BasePayload

One entry of a commander's E or AE: [effect_id, values, source].

Client: LordVO.parseRawEffects (bundle line 26483), BonusVO.parseFromValueArray (bundle line 5707).

Fields:

Validators:

  • _source_key → source
  • _from_row

effect_id pydantic-field

effect_id: EnumOrInt['Effect']

The effect

values pydantic-field

values: list[Any]

Value array; its layout depends on the effect type

source pydantic-field

source: str = ''

The key of the effect's source

SelectedAbility pydantic-model

Bases: BasePayload

One ability slot of a general: a [slot_id, ability_id] pair, as GASAIDS sends it and SAIDS takes it.

It serializes back to the pair, with -1 for an empty slot.

Client: GeneralVO.parseData (bundle line 26666) keeps the pairs, and GeneralVO.getSelectedAbilities (bundle lines 26769-26771) reads [0] as the slot and [1] as the ability, counting it only above 0; GeneralsAbilityDialog.onSave (bundle line 27850) sends -1 for a cleared slot.

Fields:

Validators:

slot_id pydantic-field

slot_id: int

The slot, matched against the general's attack and defense slots

ability_id pydantic-field

ability_id: EnumOrInt['GeneralAbility'] | None = None

The ability; None for an empty slot

AlienEquipment pydantic-model

Bases: BasePayload

Alien (AIE) or temporary (TAE) equipment: [effect_id, values] rows, or [hero_rows, equipment_rows] when it carries a hero.

The block is split in two when it has two entries that are each empty or start with an array; otherwise every row is an equipment bonus.

Client: LordVO.parseLord (bundle lines 26471-26477), AlienLordHeroVO.parseAlienBoniData (bundle line 67502), AlienLordEquipmentVO.parseAlienBoniData (bundle line 67479)

Fields:

Validators:

hero_bonuses pydantic-field

hero_bonuses: tuple[EquipmentBonus, ...] = ()

The hero's bonuses

bonuses pydantic-field

bonuses: tuple[EquipmentBonus, ...] = ()

The equipment's bonuses

LeaderBase pydantic-model

Bases: BasePayload

Fields shared by every gli entry.

The wire protocol calls both kinds "lords" (command gli, field LID on movement commands); the game UI says commander and castellan.

AIE (alien) or TAE (temporary) equipment stands in for EQ: the client reads the first of them that is present, and only when EQ is empty. See alien_bonuses.

A spied castellan is built without any of it: LordFactory.createLord(e, true, true) (bundle line 26448) makes LordVO.parseLord (bundle line 26500) skip EQ, AIE and TAE, and takes a default commander from the lords table copy that has no effects (CastleLordData.getDefaultLordWithoutEquipmentByID, bundle line 38629). The attack pre-calculation, the treasure node pre-calculation, the spy report and the support defense info build theirs that way, so E and AE carry all they grant; see without_equipment.

Client: LordFactory.createLord (bundle line 26448), LordVO.parseLord (bundle line 26500), LordVO.parseGeneral (bundle line 26529) and GeneralVO.parseData (bundle line 26715) for ST, L and the general's XP, OXP, IN, LU, SIDS and GASAIDS. The client reads those six only when the entry names a general above 0 and is a default commander or was created with LordFactory.createLord(e, true), as a battle log's are. An entry cannot tell the second case, so they are None unless sent, or filled with the client's defaults for a default commander with a general; elsewhere the client ignores them.

Fields:

Validators:

commander_id pydantic-field

commander_id: int

Wire key ID

Commander id; for a default commander, its default-commander id

wearer_id pydantic-field

wearer_id: ClientInt | None = None

Wire key WID

2 for a commander, 1 for a castellan

picture_id pydantic-field

picture_id: ClientInt = 0

Wire key VIS

Portrait id

name pydantic-field

name: str = ''

Wire key N

Name

wins pydantic-field

wins: ClientInt = 0

Wire key W

Battles won

defeats pydantic-field

defeats: ClientInt = 0

Wire key D

Battles lost

win_spree pydantic-field

win_spree: ClientInt = 0

Wire key SPR

Current winning streak

effects pydantic-field

Wire key E

The commander's own effects

area_effects pydantic-field

area_effects: CommanderEffects

Wire key AE

Area effects

equipment pydantic-field

equipment: list[Equipment]

Wire key EQ

Equipped items

alien_equipment pydantic-field

alien_equipment: AlienEquipment | None = None

Wire key AIE

Alien equipment; applies when equipment is empty

temporary_equipment pydantic-field

temporary_equipment: AlienEquipment | None = None

Wire key TAE

Temporary equipment; applies when equipment is empty and alien_equipment absent

alien_gem_ids pydantic-field

alien_gem_ids: tuple[EnumOrInt['Gem'], ...] = ()

Wire key GEM

The gems added to the alien or temporary equipment

without_equipment pydantic-field

without_equipment: bool = False

Built as the client builds a spied castellan, with no item, alien equipment, gem, set or lords-table effect counted; the payload that carries the entry sets it

general_id pydantic-field

general_id: Annotated[Literal[-1, 0] | EnumOrInt['General'], Field(union_mode='left_to_right'), BeforeValidator(js_int)] | None = None

Wire key GID

The assigned general; -1, 0 or None for none

star_level pydantic-field

star_level: ClientInt = 0

Wire key ST

The general's star level when the entry doubles as its general: a default commander with a general_id above 0

level pydantic-field

level: ClientInt = 0

Wire key L

The general's level when the entry doubles as its general: a default commander with a general_id above 0

general_xp pydantic-field

general_xp: ClientInt | None = None

Wire key XP

The general's experience; None when the entry does not carry it

general_old_xp pydantic-field

general_old_xp: ClientInt | None = None

Wire key OXP

The general's experience before the battle; None when the entry does not carry it

general_is_new pydantic-field

general_is_new: bool | None = None

Wire key IN

The general is newly unlocked; None when the entry does not say

general_has_level_up pydantic-field

general_has_level_up: bool | None = None

Wire key LU

The general gained a level; None when the entry does not say

general_skill_ids pydantic-field

general_skill_ids: tuple[EnumOrInt['GeneralSkill'], ...] | None = None

Wire key SIDS

The general's unlocked skills; None when the entry has none

general_selected_abilities pydantic-field

general_selected_abilities: tuple[SelectedAbility, ...] | None = None

Wire key GASAIDS

The general's ability slots, filled or empty; None when the entry has none

uses_alien_equipment property

uses_alien_equipment: bool

Whether AIE/TAE stand in for an empty EQ, as LordVO.parseLord decides.

active_alien_equipment property

active_alien_equipment: AlienEquipment | None

The alien or temporary equipment standing in for an empty EQ, None when none does.

alien_hero_bonuses property

alien_hero_bonuses: list[EquipmentBonus]

The hero bonuses of the active alien or temporary equipment.

alien_bonuses property

alien_bonuses: list[EquipmentBonus]

The equipment bonuses of the active alien or temporary equipment, empty when EQ has items.

worn_items

worn_items() -> list[Equipment]

The items the client puts in the commander's slots, in slot order.

LordVO.parseLord (bundle line 26451) creates the helmet, armor, weapon, artifact, skin and hero slots in that order and puts each EQ item in its slot by row[1], so a later item replaces an earlier one and an item for any other slot is not worn.

Commander pydantic-model

Bases: LeaderBase

A commander - the leader assigned to an attack or support movement.

Client: CommanderVO, built by LordFactory.createLord (bundle line 26399)

Fields:

Validators:

Castellan pydantic-model

Bases: LeaderBase

A castellan - the defensive counterpart of a commander (BaronVO).

Client: BaronVO.parseLord (bundle line 43534)

Fields:

Validators:

locked_in_castle_id pydantic-field

locked_in_castle_id: ClientInt = 0

Wire key LICID

Castle the castellan is locked in, -1 for none; 0 when the entry has none

is_locked_in_castle property

is_locked_in_castle: bool

True when locked_in_castle_id is 0 or more.

is_available_for_movement

is_available_for_movement(kingdom_id: int) -> bool

Whether the client offers this castellan for a movement in kingdom_id.

Not when it is locked in a castle. A faction-portrait castellan (VIS 5) is compared with FactionConst.BARON_ID (-16), not a kingdom id, so it is never available in a real kingdom; an island-portrait one (VIS 13) only in the storm islands (4). The client also refuses a castellan that already leads one of the player's movements, which this model cannot see.

Client: BaronVO.isAvailableForMovement (bundle line 43535), LordVO.isAvailableForMovement (bundle line 26607)

GetCommandersRequest pydantic-model

Bases: BaseRequest

Request the commander and castellan list.

Command: gli Payload: {}

Client: C2SGetLordsInfoVO (bundle line 32779, no fields)

CommanderRoster pydantic-model

Bases: BasePayload

A player's commanders and castellans, the gli block.

The lists are in the client's order: commanders by commander_id, castellans by their portrait's place in CASTELLAN_PICTURE_ORDER, an unlisted portrait first.

Client: CastleLordData.parse_GLI (bundle line 38553), onSortLord and onSortBaron (bundle lines 38572-38573), BaronVO.parseLord (bundle line 43534)

Fields:

Validators:

commanders pydantic-field

commanders: list[Commander]

Wire key C

Commanders

castellans pydantic-field

castellans: list[Castellan]

Wire key B

Castellans

GetCommandersResponse pydantic-model

Bases: BaseResponse, CommanderRoster

Response containing commanders (C) and castellans (B).

Command: gli

Client: GLICommand.executeCommand (bundle line 123976) hands it to CastleLordData.parse_GLI

Fields:

Validators:

RenameCommanderRequest pydantic-model

Bases: BaseRequest

Rename a commander or castellan.

Command: arl Payload: {"LID": commander_id, "N": name}

The game's dialog allows 3 to 15 characters (EquipmentConst.LORD_NAME_MIN_LENGTH and LORD_NAME_MAX_LENGTH, dll line 19249); the server's own rules were not traced.

Client: C2SRenameLordVO (bundle line 65748), sent by CastleRenameLordDialog.sendCommand (bundle line 65738)

Fields:

commander_id pydantic-field

commander_id: int

Wire key LID

The commander_id of a Commander or Castellan from client.commanders.get_all()

name pydantic-field

name: str

Wire key N

The new name; the game allows 3 to 15 characters

RenameCommanderResponse pydantic-model

Bases: BaseResponse

Reply to a rename: the full commander and castellan list.

Command: arl

Client: ARLCommand.executeCommand (bundle line 123657), which passes gli to CastleLordData.parse_GLI

Fields:

commander_roster pydantic-field

commander_roster: CommanderRoster

Wire key gli

Commanders and castellans after the rename

commanders.models.skills

Generals and Legendary skills: the two attacker-side inputs that size a wave.

A general's unlocked skills widen the flanks; the player's Legendary skills widen them further and add waves, but only in a legendary fight. Both are read with their own command and neither arrives with the commander list.

Classes:

Name Description
SelectedAbility

One ability slot of a general: a [slot_id, ability_id] pair, as GASAIDS sends it and SAIDS takes it.

GetGeneralsRequest

Request every general the player owns.

OwnedGeneral

One general, as GeneralVO.parseData reads it.

AssignGeneralRequest

Assign a general to a commander, or take the commander's general away.

AssignGeneralResponse

Reply to a general assignment: the full commander list.

SetGeneralAbilitiesRequest

Choose a general's abilities, one per slot.

UnlockGeneralSkillRequest

Unlock a general skill. The skill id names the general, so none is sent.

ResetGeneralSkillsRequest

Reset a general's skill tree.

AddGeneralXpRequest

Feed a general xp items.

GetGeneralsResponse

Response listing the player's generals.

GetSkillsRequest

Request the player's own skill lists.

ActivatingSceatSkill

A Hall of Legends sceat skill still being activated, an entry of SSA.

SkillList

The player's Legendary and sceat skills, the skl block.

GetSkillsResponse

Response listing the player's Legendary and sceat skills.

AddSkillPointRequest

Buy a Legendary skill level with skill points.

AddSkillPointResponse

The Legendary skill levels bought.

BuySceatSkillRequest

Buy a sceat skill level with sceat tokens or imperial ducats.

BuySceatSkillResponse

The acknowledgement of a bss; it carries nothing.

SkipSceatSkillActivationRequest

Finish the activation of the sceat skill being activated in one Hall of Legends tab, for rubies.

SkipSceatSkillActivationResponse

The acknowledgement of an ssa; it carries nothing.

ResetSkillsRequest

Take back every Legendary skill point.

ResetSkillsResponse

The acknowledgement of an skr; it carries nothing.

ObjectUpdateEvent

An object update pushed by the server.

logger module-attribute

logger = logging.getLogger(__name__)

SelectedAbility pydantic-model

Bases: BasePayload

One ability slot of a general: a [slot_id, ability_id] pair, as GASAIDS sends it and SAIDS takes it.

It serializes back to the pair, with -1 for an empty slot.

Client: GeneralVO.parseData (bundle line 26666) keeps the pairs, and GeneralVO.getSelectedAbilities (bundle lines 26769-26771) reads [0] as the slot and [1] as the ability, counting it only above 0; GeneralsAbilityDialog.onSave (bundle line 27850) sends -1 for a cleared slot.

Fields:

Validators:

slot_id pydantic-field

slot_id: int

The slot, matched against the general's attack and defense slots

ability_id pydantic-field

ability_id: EnumOrInt['GeneralAbility'] | None = None

The ability; None for an empty slot

GetGeneralsRequest pydantic-model

Bases: BaseRequest

Request every general the player owns.

Command: gie Payload: {}

Client: C2SGetGeneralsInfoVO (bundle line 56405, no fields)

OwnedGeneral pydantic-model

Bases: BasePayload

One general, as GeneralVO.parseData reads it.

skill_ids is the useful part: the skills it has unlocked, which is what the attack dialog accumulates for the flank and front unit bonuses.

Client: GeneralVO.parseData (bundle line 26666)

Fields:

Validators:

general_id pydantic-field

general_id: Literal[-1] | EnumOrInt['General']

experience pydantic-field

experience: int = 0

Wire key XP

Experience, 0 when missing

star_level pydantic-field

star_level: int = 0

Wire key ST

Star level; when none is set, derived from fixed_level if that is a multiple of 10

is_new pydantic-field

is_new: bool = False

Wire key IN

The general is new

has_level_up pydantic-field

has_level_up: bool = False

Wire key LU

The general has levelled up

skill_ids pydantic-field

skill_ids: tuple[EnumOrInt['GeneralSkill'], ...] = ()

Wire key SIDS

Unlocked skills

selected_abilities pydantic-field

selected_abilities: list[SelectedAbility]

Wire key GASAIDS

The general's ability slots, filled or empty

fixed_level pydantic-field

fixed_level: int = -1

Wire key L

Fixed level; -1 when there is none

old_experience pydantic-field

old_experience: int = 0

Wire key OXP

The xp before the last change

wins pydantic-field

wins: int = 0

Wire key W

Battles won, 0 when missing

defeats pydantic-field

defeats: int = 0

Wire key D

Battles lost, 0 when missing

ability_ids property

ability_ids: list[int]

The abilities this general has selected, one id per filled slot, from either side.

Client: GeneralVO.getSelectedAbilities (bundle line 26769) skips a slot whose ability id is not above 0.

attack_ability_ids

attack_ability_ids(general_def: GeneralDef) -> list[int]

The abilities selected in this general's attack slots.

Client: GeneralVO.getSelectedAbilities(true) (bundle line 26769)

defense_ability_ids

defense_ability_ids(general_def: GeneralDef) -> list[int]

The abilities selected in this general's defense slots.

Client: GeneralVO.getSelectedAbilities(false) (bundle line 26769)

AssignGeneralRequest pydantic-model

Bases: BaseRequest

Assign a general to a commander, or take the commander's general away.

Command: gla Payload: {"LID": commander_id, "GID": general_id}

Client: C2SGeneralAssignLord (bundle line 101985)

Fields:

commander_id pydantic-field

commander_id: int

Wire key LID

The commander to give the general to, from client.commanders.get_commanders()

general_id pydantic-field

general_id: Literal[-1] | EnumOrInt['General']

AssignGeneralResponse pydantic-model

Bases: BaseResponse

Reply to a general assignment: the full commander list.

Command: gla Payload: {"gli": {"C": [..], "B": [..]}}

Client: GLACommand.executeCommand (bundle line 124218) passes gli to parse_GLI.

Fields:

commander_roster pydantic-field

commander_roster: CommanderRoster

Wire key gli

The commanders and castellans after the change

SetGeneralAbilitiesRequest pydantic-model

Bases: BaseRequest

Choose a general's abilities, one per slot.

Command: gaae Payload: {"GID": general_id, "SAIDS": [[slot_id, ability_id], ..]}

The ability dialog sends every slot it shows, with -1 for a cleared one. The server replies with no body.

Client: C2SGeneralSelectAbilities (bundle line 70767), GeneralsAbilityDialog.onSave (bundle line 27846)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general whose abilities are chosen, an OwnedGeneral.general_id from client.commanders.get_generals()

abilities pydantic-field

abilities: list[SelectedAbility]

Wire key SAIDS

Every slot the dialog shows, each sent as [slot_id, ability_id], -1 for none

UnlockGeneralSkillRequest pydantic-model

Bases: BaseRequest

Unlock a general skill. The skill id names the general, so none is sent.

Command: guse Payload: {"ID": skill_id}

The server replies with no body.

Client: C2SGeneralUnlockSkillVO (bundle line 67469), GUSECommand (bundle line 124280)

Fields:

skill_id pydantic-field

skill_id: EnumOrInt['GeneralSkill']

Wire key ID

The skill to unlock

ResetGeneralSkillsRequest pydantic-model

Bases: BaseRequest

Reset a general's skill tree.

Command: grs Payload: {"GID": general_id}

The server replies with no body.

Client: C2SGeneralResetSkills (bundle line 67460), GRSCommand (bundle line 124242)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general whose skills are reset, an OwnedGeneral.general_id from client.commanders.get_generals()

AddGeneralXpRequest pydantic-model

Bases: BaseRequest

Feed a general xp items.

Command: gaxp Payload: {"GID": general_id, "CID": currency_id, "AMT": amount}

The server replies with no body.

Client: C2SGeneralAddXpVO (bundle line 74507), GAXPCommand (bundle line 124176)

Fields:

general_id pydantic-field

general_id: EnumOrInt['General']

Wire key GID

The general to give xp to, an OwnedGeneral.general_id from client.commanders.get_generals()

currency_id pydantic-field

currency_id: EnumOrInt['CurrencyId']

Wire key CID

The xp item

amount pydantic-field

amount: int

Wire key AMT

How many of the xp item to use

GetGeneralsResponse pydantic-model

Bases: BaseResponse

Response listing the player's generals.

Command: gie Payload: {"G": [{"GID": .., "SIDS": [skill ids], ..}, ..]}

Client: GIECommand.executeCommand (bundle line 124204) hands it to GeneralsData.parse_GIE (bundle line 113069), which updates each general by GID.

Fields:

Validators:

generals pydantic-field

generals: list[OwnedGeneral]

Wire key G

The player's generals

skill_ids

skill_ids(general_id: General) -> tuple[EnumOrInt['GeneralSkill'], ...]

The skills one general has unlocked, empty when it is not listed.

GetSkillsRequest pydantic-model

Bases: BaseRequest

Request the player's own skill lists.

Command: skl Payload: {}

Client: C2SGetSkillListVO (bundle line 112219, no fields)

ActivatingSceatSkill pydantic-model

Bases: BasePayload

A Hall of Legends sceat skill still being activated, an entry of SSA.

Client: CastleLegendSkillData.parse_SKL (bundle line 112051)

Fields:

skill_id pydantic-field

skill_id: EnumOrInt['SceatSkill'] | None = None

Wire key ID

The sceat skill being activated; None when the entry names none

remaining_seconds pydantic-field

remaining_seconds: ClientInt = 0

Wire key RS

Seconds until the skill is active

SkillList pydantic-model

Bases: BasePayload

The player's Legendary and sceat skills, the skl block.

SID are the Legendary skills, which apply only in a legendary fight, and SIDS the Hall of Legends sceat skills, which always apply.

Client: CastleLegendSkillData.parse_SKL (bundle line 112051)

Fields:

Validators:

legendary_skill_ids pydantic-field

legendary_skill_ids: tuple[EnumOrInt['LegendarySkill'], ...] = ()

Wire key SID

Legendary skills, which apply only in a legendary fight

sceat_skill_ids pydantic-field

sceat_skill_ids: tuple[EnumOrInt['SceatSkill'], ...] = ()

Wire key SIDS

Hall of Legends sceat skills, which always apply

total_points pydantic-field

total_points: ClientInt = 0

Wire key SP

Skill points

seconds_until_reset pydantic-field

seconds_until_reset: int | float = 0

Wire key RS

Seconds until the skills can be reset, fractions included

reset_count pydantic-field

reset_count: ClientInt = 0

Wire key RC

How many times the skills have been reset

activating pydantic-field

Wire key SSA

Sceat skills still being activated

spent_points

spent_points(*, game_data: GameData | None = None) -> int

The skill points the held Legendary skills cost, each level counted with those below it.

Client: CastleLegendSkillData.getSpentPoints (bundle line 112097)

available_points

available_points(*, game_data: GameData | None = None) -> int

The skill points left to spend.

Client: CastleLegendSkillData.parse_SKL (bundle line 112063)

GetSkillsResponse pydantic-model

Bases: BaseResponse, SkillList

Response listing the player's Legendary and sceat skills.

Command: skl Payload: {"SID": [Legendary skill ids], "SIDS": [sceat skill ids], "SP": total_points, "RS": seconds_until_reset, "RC": reset_count, "SSA": [{"ID": .., "RS": ..}, ..]}

Client: SKLCommand.executeCommand (bundle line 129742)

Fields:

Validators:

AddSkillPointRequest pydantic-model

Bases: BaseRequest

Buy a Legendary skill level with skill points.

Command: skp Payload: {"ID": skill_id}

The client sends the next level of a skill held, or the first of one not held, once CastleLegendSkillItem.canBuy passes: the skill is not at its last level, its tier and node are unlocked, the points are there, and no sceat skill is being activated.

Client: C2SAddSkillPointVO (bundle line 78767), CastleLegendSkillItem.onClick and canBuy (bundle lines 35643, 35652)

Fields:

skill pydantic-field

skill: EnumOrInt['LegendarySkill']

Wire key ID

The Legendary skill level to buy

AddSkillPointResponse pydantic-model

Bases: BaseResponse

The Legendary skill levels bought.

Command: skp Payload: {"IDS": [skill_id, ..]}

Client: SKPCommand.executeCommand (bundle line 129756) hands it to CastleLegendSkillData.parse_SKP (bundle line 112073), which reads IDS only when it is set

Fields:

Validators:

skill_ids pydantic-field

skill_ids: tuple[EnumOrInt['LegendarySkill'], ...] = ()

Wire key IDS

The levels bought

BuySceatSkillRequest pydantic-model

Bases: BaseRequest

Buy a sceat skill level with sceat tokens or imperial ducats.

Command: bss Payload: {"ID": skill_id}

The client sends the next level of a skill held, or the first of one not held, from its buy dialog once CastleLegendSkillItem.canBuy passes.

Client: C2SBuySceatSkillVO (split.js line 408751), sent by CastleSceatSkillVO.buySkill (split.js line 121683) from CastleSceatSkillBuyDialog.onClick (split.js line 409120); CastleLegendSkillItem.onClick and canBuy (split.js lines 186511, 186593)

Fields:

skill pydantic-field

skill: EnumOrInt['SceatSkill']

Wire key ID

The sceat skill level to buy

BuySceatSkillResponse pydantic-model

Bases: BaseResponse

The acknowledgement of a bss; it carries nothing.

Command: bss

Client: BSSCommand.executeCommand (split.js line 642034)

Fields:

SkipSceatSkillActivationRequest pydantic-model

Bases: BaseRequest

Finish the activation of the sceat skill being activated in one Hall of Legends tab, for rubies.

Command: ssa Payload: {"TID": tab}

Client: C2SSkipSceatSkillActivationVO (split.js line 409893) sends the sublayer id less 1, the tab's tabID; sent by CastleLegendSkillSceatBottomMenu.onClick (split.js line 409833), priced by CastleSceatSkillVO.getSkipCosts (split.js line 121688)

Fields:

tab pydantic-field

Wire key TID

The tab whose activating skill to finish

SkipSceatSkillActivationResponse pydantic-model

Bases: BaseResponse

The acknowledgement of an ssa; it carries nothing.

Command: ssa

Client: SSACommand.executeCommand (split.js line 642076)

Fields:

ResetSkillsRequest pydantic-model

Bases: BaseRequest

Take back every Legendary skill point.

Command: skr Payload: {}

Free once the reset cooldown has run out; inside it the same request spends rubies. The server replies with no body, and the client then asks for the skill list again.

Client: C2SSkillsResetVO (bundle line 112227), CastleLegendSkillData.requestSkillReset and resetSkills (bundle lines 112137, 112104), SKRCommand (bundle line 129767)

ResetSkillsResponse pydantic-model

Bases: BaseResponse

The acknowledgement of an skr; it carries nothing.

Command: skr

Client: SKRCommand.executeCommand (split.js line 652567), which then calls CastleLegendSkillData.resetSkills (split.js line 576751)

Fields:

ObjectUpdateEvent pydantic-model

Bases: BaseResponse

An object update pushed by the server.

Only the skill list is read here; the joined castle's part of the same payload is BuildingChanged.

Command: ego Client: EGOCommand.executeCommand (split.js line 628214)

Fields:

Validators:

skills pydantic-field

skills: SkillList | None = None

Wire key skl

A new skill list, when one was sent