Skip to content

Quests

Your active quests, the quest book and your daily quests behind client.quests.

quests.service

Your active quests, the quest book's main quests and your daily quests; donating for a quest, and the quest conditions and starters only the client sees done.

Classes:

Name Description
QuestsService

Your quests as the login data and the quest pushes left them, which send nothing,

QuestsService

QuestsService(client: 'EmpireClient')

Bases: BaseService

Your quests as the login data and the quest pushes left them, which send nothing, and the requests that donate for a quest, finish a condition or a quest starter.

Reached as client.quests.

Methods:

Name Description
quest

An active quest, or None when it is not active.

starter_quest

The starter quest an event's icon opens before its dialog, or None when it opens none.

donate

Donate what the quest's donate condition asks for, the whole amount at once, without rubies.

finish_condition

Report a quest condition done that only the client sees done. The client has no handler for an

finish_starter

Report a quest's starter seen through, as the client does when the dialog that introduces

Attributes:

Name Type Description
active dict[int, Quest]

Your active quests by id, in id order, as the last qli and the quest pushes since left them; a copy.

book QuestBook | None

The quest book's main quests, from the last qli that had them; None until one did.

daily DailyQuests

Your daily quests, from the last dql (the login data has one).

active property

active: dict[int, Quest]

Your active quests by id, in id order, as the last qli and the quest pushes since left them; a copy.

book property

book: QuestBook | None

The quest book's main quests, from the last qli that had them; None until one did.

daily property

daily: DailyQuests

Your daily quests, from the last dql (the login data has one).

Raises:

Type Description
StateNotLoadedError

No login has brought it

quest

quest(quest_id: QuestId | int) -> Quest | None

An active quest, or None when it is not active.

starter_quest

starter_quest(event: Event) -> Quest | None

The starter quest an event's icon opens before its dialog, or None when it opens none.

The first active quest, in id order, whose game data row belongs to the event and has a starter condition; None as well when that quest needs another quest first.

Raises:

Type Description
GameDataNotLoadedError

The game data cannot be loaded

Client: StatusIconTemporaryServerEvent.onClick (bundle line 106330) and StatusIconAllianceBattleGroundEvent.onClick (bundle line 105359) over CastleQuestData.getActiveStarterQuestByEventID (bundle line 20344) and CastleQuestVO.isStarterQuest (bundle line 52499); the rows are read by CastleQuestVO.fillFromParamXML (bundle line 52475) and the active quests sorted by id in CastleQuestData.updateActiveQuests (bundle line 20244)

donate

donate(quest_id: QuestId | int, *, timeout: float = 5.0) -> None

Donate what the quest's donate condition asks for, the whole amount at once, without rubies.

The quest's first donate condition in the game data picks the request: a resource is sent with qdr in its field, khan medals and samurai tokens with qdc. A quest the donation finishes is reported as any other, through client.state.on_quest_finished.

Raises:

Type Description
ValueError

The game data has no such quest, or the quest has no donate condition

GameDataNotLoadedError

The game data cannot be loaded

CommandError / EmpireTimeoutError / ConnectionClosedError

see EmpireClient.send

Client: DonateForQuestCommand.performAction (bundle line 101001), which sends the condition's conditionMaxCounter (ABasicQuestConditionVO.loadFromParamArray, bundle line 52833)

finish_condition

finish_condition(condition_type: QuestConditionType, target_id: int = -1) -> None

Report a quest condition done that only the client sees done. The client has no handler for an answer, so none is waited for.

The client sends it only for the two visit conditions of the generals introduction: VISIT_GENERALS_OVERVIEW when the generals overview opens while the active introduction quest's first condition is that type, and VISIT_GENERALS_INN with the current condition's target id after the inn's introduction cinematic. What the server checks is unverified.

Parameters:

Name Type Description Default
condition_type QuestConditionType

The condition done

required
target_id int

The condition's target, -1 for none as the client defaults it

-1

Client: C2SFinishQuestConditionVO (bundle line 41691), sent by GeneralsOverviewDialog.showLoaded (bundle line 15812) and GeneralHubIntroductionHandler (bundle lines 74775, 74778)

finish_starter

finish_starter(quest_id: QuestId | int) -> None

Report a quest's starter seen through, as the client does when the dialog that introduces the quest is closed or the tutorial step that triggered it is done. The client has no handler for an answer, so none is waited for; what the server does with it is unverified.

Parameters:

Name Type Description Default
quest_id QuestId | int

The quest the starter introduces

required

Client: C2SQuestStarterClickVO (bundle line 37187), sent by CastleStartQuestDialog.finishQuestStarter (bundle line 17052) and TutorialBasicActionCommand.finishTriggerQuest (bundle line 9024)

quests.models

Your quests as client.state keeps them: the active quests (qli), the quest book's main quests, and the daily quests (dql); and the requests that donate for a quest (qdr, qdc) and finish a condition the client counts itself (fcq) or a quest starter (qsc); and the ruby purchases of a time-limited campaign's quest (bcq) and end reward (bcr).

The state has no game data, so a quest is its id (a QuestId or DailyQuestId) and the progress the server sent; its conditions, rewards and texts are in the items' quests and dailyactivities rows (GameData.record).

Classes:

Name Description
Quest

One of your active quests, or a time-limited campaign's quest.

QuestBook

The quest book's main quests, its chapters: those announced, running and finished.

QuestListResponse

Your active quests, replacing the ones held, and the quest book's main quests when all three lists are sent.

QuestsStartedResponse

Quests that started: each becomes active, without progress.

QuestProgressResponse

A quest made progress: only the quest is named; its counters come with the next qli.

QuestFinishedResponse

A quest is finished: it is no longer active, and its random equipment rewards are shown.

CampaignQuestStatusResponse

The time-limited campaign's quests and end reward, read over the running campaign event.

Popup

One popup of an msp: which, and the value its dialog reads.

PopupsResponse

Popups the server asks the client to show.

DailyQuest

One of today's daily quests.

DailyQuests

Your daily quests: your daily quest level, today's quests and the reward thresholds.

QuestDonateResourcesRequest

Donate resources for a quest's donate condition.

QuestDonateResourcesResponse

The answer to a resource donation; the client reads nothing from it.

QuestDonateCurrencyRequest

Donate a currency, khan medals or samurai tokens, for a quest's donate condition.

QuestDonateCurrencyResponse

The answer to a currency donation; the client reads nothing from it.

FinishQuestConditionRequest

Report a quest condition done that only the client sees done, such as visiting a screen.

QuestStarterClickRequest

Report a quest starter seen through: the dialog or tutorial step that introduces a quest is done.

BuyCampaignQuestRequest

Buy a time-limited campaign's quest done, with rubies.

BuyCampaignQuestResponse

The acknowledgement of a bcq; it carries nothing.

BuyCampaignRewardRequest

Buy a time-limited campaign's end reward, with rubies.

BuyCampaignRewardResponse

Your coins and rubies after buying a campaign's end reward.

Quest pydantic-model

Bases: EmpireModel

One of your active quests, or a time-limited campaign's quest.

progress holds one counter per condition, in the order of the quest's conditions in the items; the client keeps the counters as sent, the library reads them through int(). The client also counts a quest whose time has run out, and is not done, as failed.

Client: CastleQuestVO.fillFromParams (bundle line 52463), remainingSeconds and isFailed (bundle lines 52592, 52583)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True, populate_by_name=True)

quest_id pydantic-field

quest_id: EnumOrInt['QuestId']

Wire key QID

The quest

progress pydantic-field

progress: tuple[int, ...] = ()

Wire key P

Each condition's counter

end_time pydantic-field

end_time: float | None = None

Wire key RS

When the quest runs out, in time.monotonic() seconds; None without RS or for a negative one

completed pydantic-field

completed: bool = False

Whether the quest is done, from S or QCS

failed pydantic-field

failed: bool = False

Whether the quest has failed, from S or QCS

locked pydantic-field

locked: bool = False

Whether the quest is not open yet, from QCS

campaign_quest_id pydantic-field

campaign_quest_id: int = 0

Wire key CQID

The quest's place in a campaign

campaign_timestamp pydantic-field

campaign_timestamp: int | None = None

Wire key ST

When a campaign quest opens, as sent; None without one

from_entry classmethod

from_entry(entry: dict[str, Any], now: float | None = None) -> Quest

A quest read from its entry.

S decides done or failed (1 or 0) and wins over QCS ("C" done, "F" failed, "N" locked); without either the quest is neither.

remaining_seconds

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

Seconds until the quest runs out, 0 once it has; None for a quest without a time limit.

QuestBook pydantic-model

Bases: EmpireModel

The quest book's main quests, its chapters: those announced, running and finished.

Client: CastleQuestBookMainQuestListVO.parseListsFromParamObject (bundle line 52419). An id is a main quest's mainQuestID: the book and the main quest dialog load the same Quest_<id><status> picture (bundle lines 52435, 93389)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True, populate_by_name=True)

announced_quest_ids pydantic-field

announced_quest_ids: tuple[EnumOrInt['MainQuest'], ...] = ()

Wire key ANN

The main quests announced

running_quest_ids pydantic-field

running_quest_ids: tuple[EnumOrInt['MainQuest'], ...] = ()

Wire key R

The main quests running

finished_quest_ids pydantic-field

finished_quest_ids: tuple[EnumOrInt['MainQuest'], ...] = ()

Wire key D

The main quests finished

from_section classmethod

from_section(section: dict[str, Any]) -> QuestBook | None

The book a qli carries, or None when one of ANN, R and D is missing or no list.

The client then keeps its own.

QuestListResponse pydantic-model

Bases: BaseResponse

Your active quests, replacing the ones held, and the quest book's main quests when all three lists are sent.

Command: qli, a push and the reply to a quest list request.

Client: QLICommand.exec (bundle line 126625), CastleQuestData.parseActiveQuestList (bundle line 20256), which empties the list first, and CastleQuestBookMainQuestListVO.parseListsFromParamObject (bundle line 52442), which reads ANN, R and D only when all three are truthy

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

quests pydantic-field

quests: tuple[Quest, ...] = ()

Wire key QL

The active quests, as sent

book pydantic-field

book: QuestBook | None = None

The quest book's main quests; None when one of its three lists is missing

QuestsStartedResponse pydantic-model

Bases: BaseResponse

Quests that started: each becomes active, without progress.

Command: qst, a push.

Client: QSTCommand.exec (bundle line 126657) calls CastleQuestData.startQuest (bundle line 20241) for each truthy id of QIDS

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

quest_ids pydantic-field

quest_ids: tuple[EnumOrInt['QuestId'], ...] = ()

Wire key QIDS

The quests started, in the order sent

QuestProgressResponse pydantic-model

Bases: BaseResponse

A quest made progress: only the quest is named; its counters come with the next qli.

Command: qpg, a push.

Client: QPGCommand.exec (bundle line 126641), CastleQuestData.parseQuestProgress (bundle line 20251), which reads int(P[0]) and nothing else of P

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

quest_id pydantic-field

quest_id: EnumOrInt['QuestId'] | None = None

Wire key P

The quest; None when P is no list with a first entry

QuestFinishedResponse pydantic-model

Bases: BaseResponse

A quest is finished: it is no longer active, and its random equipment rewards are shown.

Command: qfi, a push.

Client: QFICommand.exec (bundle line 126604) reads int(QID) for the quest's prototype and CastleQuestData.finishQuest (bundle line 20254) drops the active quest; GEQ goes to CastleQuestCompletedDialogProperties (bundle line 54013) as a collectable list

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

quest_id pydantic-field

quest_id: EnumOrInt['QuestId'] = 0

Wire key QID

The quest finished

random_equipment_rewards pydantic-field

random_equipment_rewards: CollectableRows = ()

Wire key GEQ

The random equipment the quest gave, if any

CampaignQuestStatusResponse pydantic-model

Bases: BaseResponse

The time-limited campaign's quests and end reward, read over the running campaign event.

Command: cqs, a push.

Client: CQSCommand.exec (bundle line 126533) does nothing without the campaign running; TimeLimitedCampaignEventEventVO.parseCQS (bundle line 118593) and parseParamObject (bundle line 118574), which sort the quests by ST and then CQID; CommKeys.END_REWARD_VALUE is ERV (dll)

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

reward_ids pydantic-field

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

Wire key RIDS

The campaign's rewards; GameData.reward_list gives what they hold

reward_collected pydantic-field

reward_collected: bool = False

Wire key COL

You collected the end reward (1 == COL)

end_reward_value pydantic-field

end_reward_value: int = 0

Wire key ERV

The end reward's value, int(ERV)

quests pydantic-field

quests: tuple[Quest, ...] = ()

Wire key CQS

The campaign's quests, in campaign order

Popup pydantic-model

Bases: EmpireModel

One popup of an msp: which, and the value its dialog reads.

Client: CastlePopUpHelper.displayPopUps (bundle line 12922) reads int(POP) and hands VAL to displayPopUp (bundle line 12928), whose dialog reads what it needs of it

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

popup_id pydantic-field

popup_id: EnumOrInt[PopupType] = 0

Wire key POP

The popup

value pydantic-field

value: Any = None

Wire key VAL

What the popup's dialog reads, as sent

finished_quest_id pydantic-field

finished_quest_id: EnumOrInt['QuestId'] | None = None

The quest a quest-finished popup names (its VAL's QID); None for any other popup

PopupsResponse pydantic-model

Bases: BaseResponse

Popups the server asks the client to show.

Command: msp, a push.

Client: MSPCommand.exec (bundle line 125476), CastlePopUpHelper.displayPopUps (bundle line 12922), which reads every entry of P

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

popups pydantic-field

popups: tuple[Popup, ...] = ()

Wire key P

The popups, in the order sent

DailyQuest pydantic-model

Bases: EmpireModel

One of today's daily quests.

Client: DailyQuestVO.setProgress and setFinished (bundle lines 134132, 134135)

Fields:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True, populate_by_name=True)

quest_id pydantic-field

quest_id: EnumOrInt['DailyQuestId']

Wire key QID

The daily quest

progress pydantic-field

progress: tuple[int, ...] = ()

Wire key P

Each condition's counter, read through int(); empty for a finished quest, whose counters are full

finished pydantic-field

finished: bool = False

Whether you finished it today (listed in FDQ)

DailyQuests pydantic-model

Bases: BaseResponse

Your daily quests: your daily quest level, today's quests and the reward thresholds.

Command: dql, as a login section of gbd and a push; the client has no request for it. Payload: {"PQL": level, "FDQ": [finished quest id, ...], "RDQ": [{"QID": id, "P": [counter, ...]}, ...], "RS": [threshold rewards, ...]}

The client drops the ids its items lack; the library keeps every one. A falsy RS leaves the thresholds unset, so over keeps the earlier ones.

Client: DQLCommand.exec (split.js line 640563), CastleDailyQuestData.parse_DQL (split.js line 669180), parse_RDQ, parse_FDQ and parseThresholdRewardList (split.js lines 669195, 669205, 669215)

Fields:

Validators:

model_config class-attribute

model_config: ConfigDict = ConfigDict(frozen=True)

level pydantic-field

level: int = 0

Wire key PQL

Your daily quest level

quests pydantic-field

quests: tuple[DailyQuest, ...] = ()

The finished (FDQ) and running (RDQ) quests, by quest id

threshold_rewards pydantic-field

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

Wire key RS

Each reward threshold's rewards, in threshold order; empty when none were sent

over

over(previous: DailyQuests | None) -> DailyQuests

These daily quests applied over previous: without thresholds of their own, they keep its.

QuestDonateResourcesRequest pydantic-model

Bases: BaseRequest

Donate resources for a quest's donate condition.

Command: qdr Payload: {"QID": quest_id, "F": food, "W": wood, "S": stone, "C1": coins, "O": oil, "C": coal, "I": iron, "G": glass, "PWR": 0, "PO": -1}

DonateForQuestCommand.performAction puts the condition's amount in the one field of its resource and leaves the rest 0. PWR 1 with a merchant in PO buys missing resources with rubies, which only the resource wait dialog sends (bundle line 35225).

Client: C2SQuestDonateRessourcesVO (bundle line 47687), sent by DonateForQuestCommand.performAction (bundle lines 101001-101021)

Fields:

quest_id pydantic-field

quest_id: EnumOrInt['QuestId']

Wire key QID

The quest

food pydantic-field

food: int = 0

Wire key F

Food to donate

wood pydantic-field

wood: int = 0

Wire key W

Wood to donate

stone pydantic-field

stone: int = 0

Wire key S

Stone to donate

coins pydantic-field

coins: int = 0

Wire key C1

Coins to donate

oil pydantic-field

oil: int = 0

Wire key O

Oil to donate

coal pydantic-field

coal: int = 0

Wire key C

Coal to donate

iron pydantic-field

iron: int = 0

Wire key I

Iron to donate

glass pydantic-field

glass: int = 0

Wire key G

Glass to donate

pay_with_rubies pydantic-field

pay_with_rubies: int = 0

Wire key PWR

0: donate what you hold

private_offer pydantic-field

private_offer: int = -1

Wire key PO

The ruby merchant; -1 for none

QuestDonateResourcesResponse pydantic-model

Bases: BaseResponse

The answer to a resource donation; the client reads nothing from it.

Command: qdr

Client: QDRCommand.executeCommand (bundle line 126553)

Fields:

QuestDonateCurrencyRequest pydantic-model

Bases: BaseRequest

Donate a currency, khan medals or samurai tokens, for a quest's donate condition.

Command: qdc Payload: {"QID": quest_id, "CID": currency_id, "A": amount}

Client: C2SQuestDonateCurrencyVO (bundle line 101033), sent by DonateForQuestCommand.performAction (bundle lines 101019-101021)

Fields:

quest_id pydantic-field

quest_id: EnumOrInt['QuestId']

Wire key QID

The quest

currency_id pydantic-field

currency_id: CurrencyId

Wire key CID

The currency donated

amount pydantic-field

amount: int

Wire key A

How much to donate

QuestDonateCurrencyResponse pydantic-model

Bases: BaseResponse

The answer to a currency donation; the client reads nothing from it.

Command: qdc

Client: QDCCommand.executeCommand (bundle line 126540)

Fields:

FinishQuestConditionRequest pydantic-model

Bases: BaseRequest

Report a quest condition done that only the client sees done, such as visiting a screen.

Command: fcq Payload: {"QC": condition_type, "QTID": target_id}

The client has no handler for an answer.

Client: C2SFinishQuestConditionVO (bundle line 41691)

Fields:

condition_type pydantic-field

condition_type: QuestConditionType

Wire key QC

The condition done

target_id pydantic-field

target_id: int = -1

Wire key QTID

The condition's target; -1 for none

QuestStarterClickRequest pydantic-model

Bases: BaseRequest

Report a quest starter seen through: the dialog or tutorial step that introduces a quest is done.

Command: qsc Payload: {"QID": quest_id}

The client has no handler for an answer.

Client: C2SQuestStarterClickVO (bundle line 37187), sent by CastleStartQuestDialog.finishQuestStarter (bundle line 17052), TutorialBasicActionCommand.finishTriggerQuest (bundle line 9024) and TutorialAttackRobberBaronCommand.onPlayernameSelected (bundle line 143104)

Fields:

quest_id pydantic-field

quest_id: EnumOrInt['QuestId']

Wire key QID

The quest the starter introduces

BuyCampaignQuestRequest pydantic-model

Bases: BaseRequest

Buy a time-limited campaign's quest done, with rubies.

Command: bcq Payload: {"CQID": campaign_quest_id}

Client: C2SBuyCampaignQuestVO (bundle line 458364), sent by CastleQuestBuyRewardDialog.onClick (bundle line 270612) with the quest's campaignQuestID

Fields:

campaign_quest_id pydantic-field

campaign_quest_id: int

Wire key CQID

The quest's place in the campaign

BuyCampaignQuestResponse pydantic-model

Bases: BaseResponse

The acknowledgement of a bcq; it carries nothing.

Command: bcq

Client: BCQCommand.exec (bundle line 640412)

Fields:

BuyCampaignRewardRequest pydantic-model

Bases: BaseRequest

Buy a time-limited campaign's end reward, with rubies.

Command: bcr Payload: {}

Client: C2SBuyCampaignRewardVO (bundle line 458390), sent by CastleQuestBuyRewardDialog.onClick (bundle line 270612) when it shows no quest

BuyCampaignRewardResponse pydantic-model

Bases: BaseResponse

Your coins and rubies after buying a campaign's end reward.

Command: bcr

Client: BCRCommand.exec (bundle line 640456) hands gcu to parseGCU

Fields:

currencies pydantic-field

currencies: CurrencyBlock = None

Wire key gcu

Coins and rubies after