2026-10-28 16:57:43 +00:00
|
|
|
|
// Payloads exchanged with the server. Every number in here is computed server-side;
|
|
|
|
|
|
// the client only projects resources and countdowns forward from the timestamps.
|
|
|
|
|
|
|
|
|
|
|
|
export type Resource = 'wood' | 'clay' | 'iron' | 'food'
|
|
|
|
|
|
export type Resources = Record<Resource, number>
|
|
|
|
|
|
export type Cost = Record<Exclude<Resource, 'food'>, number>
|
|
|
|
|
|
|
|
|
|
|
|
export type BuildingType =
|
|
|
|
|
|
| 'headquarters'
|
|
|
|
|
|
| 'storage'
|
|
|
|
|
|
| 'farm'
|
|
|
|
|
|
| 'timber_camp'
|
|
|
|
|
|
| 'clay_pit'
|
|
|
|
|
|
| 'iron_mine'
|
|
|
|
|
|
| 'hiding_place'
|
|
|
|
|
|
| 'wall'
|
|
|
|
|
|
| 'rally_point'
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
| 'watchtower'
|
2026-10-28 20:44:41 +00:00
|
|
|
|
| 'barracks'
|
|
|
|
|
|
| 'stable'
|
|
|
|
|
|
| 'workshop'
|
|
|
|
|
|
| 'academy'
|
2026-10-30 12:54:57 +00:00
|
|
|
|
| 'hospital'
|
2026-10-31 10:07:33 +00:00
|
|
|
|
| 'market'
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
2026-10-28 20:51:43 +00:00
|
|
|
|
export type UnitType =
|
|
|
|
|
|
| 'spear'
|
|
|
|
|
|
| 'sword'
|
|
|
|
|
|
| 'archer'
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
| 'scout'
|
2026-10-28 20:51:43 +00:00
|
|
|
|
| 'light_cavalry'
|
|
|
|
|
|
| 'heavy_cavalry'
|
|
|
|
|
|
| 'ram'
|
|
|
|
|
|
| 'catapult'
|
|
|
|
|
|
| 'nobleman'
|
|
|
|
|
|
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
/** Units by type; missing types mean none. */
|
|
|
|
|
|
export type Units = Partial<Record<UnitType, number>>
|
|
|
|
|
|
|
|
|
|
|
|
export type MovementType = 'attack' | 'support' | 'return'
|
|
|
|
|
|
export type TravelMode = 'sneaky' | 'cautious' | 'normal' | 'fast' | 'forced'
|
|
|
|
|
|
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Why the server refuses an offer. The client shows `village.blocked.<reason>`; no_space means
|
|
|
|
|
|
* not enough free building space, villagers not enough idle villagers for the workers it adds.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type BlockedReason = 'max_per_village' | 'no_space' | 'max_level' | 'requires' | 'villagers'
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
|
|
|
|
|
export interface AuthUser {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
email: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `POST auth/login` and `POST auth/register`. */
|
|
|
|
|
|
export interface AuthResult {
|
|
|
|
|
|
token: string
|
|
|
|
|
|
user: AuthUser
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-29 00:57:00 +00:00
|
|
|
|
/** Where a new village starts: anywhere on the frontier, or in one quarter of the map. */
|
|
|
|
|
|
export type StartDirection = 'random' | 'nw' | 'ne' | 'sw' | 'se'
|
|
|
|
|
|
|
2026-10-28 16:57:43 +00:00
|
|
|
|
/** One row of `world.index`. */
|
|
|
|
|
|
export interface WorldSummary {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
slug: string
|
|
|
|
|
|
speed: number
|
|
|
|
|
|
village_id: number | null
|
2026-10-30 10:30:34 +00:00
|
|
|
|
/** Joined once and lost every village: a fresh start is open. */
|
|
|
|
|
|
fallen: boolean
|
|
|
|
|
|
started_at: string
|
|
|
|
|
|
players: number
|
|
|
|
|
|
villages: number
|
|
|
|
|
|
tribes: number
|
|
|
|
|
|
/** When the crown forts appear, or appeared. */
|
|
|
|
|
|
crowns_at: string
|
|
|
|
|
|
holder: { id: number; name: string } | null
|
|
|
|
|
|
/** When the holder wins if they keep the crowns. */
|
|
|
|
|
|
ends_at: string | null
|
2026-10-29 15:34:42 +00:00
|
|
|
|
/** Set once someone won the world; it stays readable. */
|
|
|
|
|
|
ended_at: string | null
|
|
|
|
|
|
winner: { id: number; name: string } | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-31 09:57:28 +00:00
|
|
|
|
/** `world.settings`: the rules in plain units; durations in seconds at the world's speed, but raids run on real time. */
|
2026-10-30 10:30:34 +00:00
|
|
|
|
export interface WorldSettings {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
settings: {
|
|
|
|
|
|
pace: { speed: number; unit_speed: number; protection: number; inactive: number }
|
|
|
|
|
|
village: { space: number; space_per_hq_level: number; builders: number; map_size: number }
|
|
|
|
|
|
combat: { morale: boolean; luck: number; night: { start: number; end: number; factor: number } | null; noble_distance: number; loyalty_drop: [number, number]; loyalty_regen: number }
|
2026-10-31 09:57:28 +00:00
|
|
|
|
/** Real seconds at every world speed: between two raids on a village, and the gathering before a band marches. */
|
2026-10-30 10:30:34 +00:00
|
|
|
|
raids: { every: [number, number]; warning: number; range: number } | null
|
|
|
|
|
|
tribes: { max_members: number; notice: number }
|
|
|
|
|
|
season: { crowns: number; needed: number; crowns_after: number; hold: number } | null
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `account.show`. */
|
|
|
|
|
|
export interface AccountState {
|
|
|
|
|
|
name: string
|
|
|
|
|
|
email: string
|
|
|
|
|
|
since: string
|
|
|
|
|
|
worlds: { world: { id: number; name: string }; villages: number; points: number; tribe: TribeRef | null }[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Push `village:lost` to the old owner of a village that was taken. */
|
|
|
|
|
|
export interface VillageLost {
|
|
|
|
|
|
world_id: number
|
|
|
|
|
|
village_id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
x: number
|
|
|
|
|
|
y: number
|
|
|
|
|
|
by: string | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-29 15:34:42 +00:00
|
|
|
|
/** A world as a season: crown forts appear round 0|0, holding most of them long enough wins. */
|
|
|
|
|
|
export interface SeasonState {
|
|
|
|
|
|
/** When the crowns appear, or appeared. */
|
|
|
|
|
|
crowns_at: string
|
|
|
|
|
|
count: number
|
|
|
|
|
|
/** Crowns a player must hold to start the clock. */
|
|
|
|
|
|
needed: number
|
|
|
|
|
|
/** How long the holder must keep them. */
|
|
|
|
|
|
hold_seconds: number
|
|
|
|
|
|
crowns: { id: number; name: string; x: number; y: number; player: { id: number; name: string } | null }[]
|
|
|
|
|
|
holder: { id: number; name: string } | null
|
|
|
|
|
|
/** When the holder wins if they keep the crowns. */
|
|
|
|
|
|
ends_at: string | null
|
|
|
|
|
|
ended_at: string | null
|
|
|
|
|
|
winner: { id: number; name: string } | null
|
2026-10-28 16:57:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `village.show`, and the reply to every `village.*` mutation. */
|
2026-10-29 15:22:52 +00:00
|
|
|
|
export type VillageRole = 'resources' | 'military'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* What fills the space gives a village its role: one kind of building taking at least
|
|
|
|
|
|
* `share` of the space both kinds take, and at least `min_space`.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface Specialisation {
|
|
|
|
|
|
role: VillageRole | null
|
|
|
|
|
|
/** Space the standing buildings of each role take. */
|
|
|
|
|
|
space: Record<VillageRole, number>
|
|
|
|
|
|
share: number
|
|
|
|
|
|
min_space: number
|
|
|
|
|
|
/** Bonuses as shares: production (camps' output), recruit_speed, defense. */
|
|
|
|
|
|
roles: { role: VillageRole; buildings: BuildingType[]; bonuses: Partial<Record<'production' | 'recruit_speed' | 'defense', number>> }[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-30 12:54:57 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* The Lazarett: beds as far as the hospitals are staffed (0 without one), beds taken, the
|
|
|
|
|
|
* share of the own fallen that comes back, and the wounded of each battle. The wounded eat
|
|
|
|
|
|
* like soldiers and stand at home again at `heals_at`.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface Hospital {
|
|
|
|
|
|
beds: number
|
|
|
|
|
|
occupied: number
|
|
|
|
|
|
share: number
|
|
|
|
|
|
heal_seconds: number
|
|
|
|
|
|
wounded: { id: number; units: Units; heals_at: string }[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-28 16:57:43 +00:00
|
|
|
|
export interface VillageState {
|
|
|
|
|
|
id: number
|
2026-10-28 18:58:42 +00:00
|
|
|
|
world_id: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
name: string
|
|
|
|
|
|
x: number
|
|
|
|
|
|
y: number
|
2026-10-29 00:57:00 +00:00
|
|
|
|
/** Map continent, e.g. K55 for 0|0 to 99|99. */
|
2026-10-28 18:58:42 +00:00
|
|
|
|
continent: string
|
|
|
|
|
|
/** Sum of the buildings' level points, as shown on the map. */
|
|
|
|
|
|
points: number
|
2026-10-28 18:54:19 +00:00
|
|
|
|
/** Building space: what buildings and queued new buildings take, out of the village maximum. */
|
|
|
|
|
|
space: { used: number; max: number }
|
2026-10-29 15:22:52 +00:00
|
|
|
|
specialisation: Specialisation
|
2026-10-29 15:34:42 +00:00
|
|
|
|
season: SeasonState
|
2026-10-30 09:54:16 +00:00
|
|
|
|
/** The player's tribe and their role in it, and tribe invites waiting. */
|
|
|
|
|
|
tribe: { tribe: (TribeRef & { role: TribeRole }) | null; invites: number }
|
2026-10-28 16:57:43 +00:00
|
|
|
|
/** Amounts stored at `resources_at`. */
|
|
|
|
|
|
resources: Resources
|
|
|
|
|
|
resources_at: string
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Net change per hour at world speed. Food is farm output minus upkeep, so it can be negative. */
|
2026-10-28 16:57:43 +00:00
|
|
|
|
rates: Resources
|
|
|
|
|
|
storage_cap: number
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** In heads, the same on every world speed; `rates.food` is the food per hour. */
|
2026-10-28 16:57:43 +00:00
|
|
|
|
population: Population
|
2026-10-28 20:58:09 +00:00
|
|
|
|
/** Villagers drafted as militia: they eat but don't work until `until`. */
|
|
|
|
|
|
levy: Levy
|
2026-10-28 21:05:45 +00:00
|
|
|
|
starvation: Starvation
|
2026-10-28 20:51:43 +00:00
|
|
|
|
/** Own units standing in the village. */
|
|
|
|
|
|
troops: Partial<Record<UnitType, number>>
|
2026-10-30 12:54:57 +00:00
|
|
|
|
hospital: Hospital
|
2026-10-31 10:07:33 +00:00
|
|
|
|
/** The market's merchants; null without a market. */
|
|
|
|
|
|
market: VillageMarket | null
|
2026-10-28 20:51:43 +00:00
|
|
|
|
/** One entry per building that trains units, in building order. */
|
|
|
|
|
|
military: MilitaryBuilding[]
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
/** Own groups leaving from or coming home to this village, and spotted groups coming here; by arrival. */
|
|
|
|
|
|
movements: Movement[]
|
|
|
|
|
|
support: {
|
|
|
|
|
|
/** Support from other villages standing here, by home village. */
|
|
|
|
|
|
here: SupportGroup[]
|
|
|
|
|
|
/** This village's troops standing in other villages, by host. */
|
|
|
|
|
|
away: SupportGroup[]
|
|
|
|
|
|
}
|
|
|
|
|
|
rally: RallyInfo
|
|
|
|
|
|
/** The player's unread reports on this world. */
|
|
|
|
|
|
unread_reports: number
|
2026-10-31 09:55:45 +00:00
|
|
|
|
/** 0..100; noblemen lower it, at 0 the village changes hands if the attacker's coins pay for another village. */
|
2026-10-29 09:33:26 +00:00
|
|
|
|
loyalty: number
|
|
|
|
|
|
conquest: Conquest
|
|
|
|
|
|
/** The player's villages in this world, by id: the switcher. */
|
|
|
|
|
|
villages: { id: number; name: string; x: number; y: number; points: number }[]
|
2026-10-29 09:15:36 +00:00
|
|
|
|
/** Quest book badge: lines with a completed quest to claim, level rewards to collect. */
|
|
|
|
|
|
quests: { claimable: number; rewards: number }
|
2026-10-28 16:57:43 +00:00
|
|
|
|
builders: number
|
|
|
|
|
|
buildings: Building[]
|
|
|
|
|
|
queue: BuildOrder[]
|
|
|
|
|
|
buildable: BuildOption[]
|
|
|
|
|
|
/** Lets the client correct for its own clock being off. */
|
|
|
|
|
|
server_time: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
/** A village as movements and reports refer to it; player null for barbarians. */
|
|
|
|
|
|
export interface VillageRef {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
x: number
|
|
|
|
|
|
y: number
|
|
|
|
|
|
player: { id: number; name: string } | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** A group under way. Groups of other players show no units, mode or send time. */
|
|
|
|
|
|
export interface Movement {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
type: MovementType
|
|
|
|
|
|
/** out: an own command leaving here; home: own troops coming back here; in: coming here. */
|
|
|
|
|
|
direction: 'out' | 'in' | 'home'
|
|
|
|
|
|
mode: TravelMode | null
|
|
|
|
|
|
from: VillageRef
|
|
|
|
|
|
to: VillageRef
|
|
|
|
|
|
units: Units | null
|
|
|
|
|
|
/** Loot on a return trip. */
|
|
|
|
|
|
cargo: Cost | null
|
|
|
|
|
|
sent_at: string | null
|
|
|
|
|
|
arrives_at: string
|
|
|
|
|
|
/** Until when the command can still be called back; null when it can't. */
|
|
|
|
|
|
cancel_until: string | null
|
2026-10-29 15:17:00 +00:00
|
|
|
|
/** Raiders from a barbarian camp: no player sent them. */
|
|
|
|
|
|
raid: boolean
|
|
|
|
|
|
/** While raiders still gather at their camp: when they march. */
|
|
|
|
|
|
marches_at: string | null
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface SupportGroup {
|
|
|
|
|
|
village: VillageRef
|
|
|
|
|
|
units: Units
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface RallyInfo {
|
|
|
|
|
|
/** Nothing can be sent without a rally point. */
|
|
|
|
|
|
has_rally_point: boolean
|
|
|
|
|
|
/** speed multiplies the pace; visibility is the radius in fields the group is seen in (0: only on arrival). */
|
|
|
|
|
|
modes: { mode: TravelMode; speed: number; visibility: number }[]
|
|
|
|
|
|
default_mode: TravelMode
|
|
|
|
|
|
/** Fields around the village within which incoming groups are spotted. */
|
|
|
|
|
|
detection: number
|
|
|
|
|
|
/** Seconds after sending during which a command can be called back. */
|
|
|
|
|
|
cancel_window: number
|
|
|
|
|
|
/** While set, players can't attack this player, and this player can only attack barbarians. */
|
|
|
|
|
|
protected_until: string | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `rally.preview`: what the send form shows before sending. */
|
|
|
|
|
|
export interface MarchPlan {
|
|
|
|
|
|
x: number
|
|
|
|
|
|
y: number
|
|
|
|
|
|
/** The village on that field, or null for an empty one. */
|
|
|
|
|
|
target: VillageRef | null
|
|
|
|
|
|
mode: TravelMode
|
|
|
|
|
|
distance: number
|
|
|
|
|
|
/** Travel time; null without units or for the own field. */
|
|
|
|
|
|
seconds: number | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-31 10:07:33 +00:00
|
|
|
|
export type ReportType = 'attack' | 'defense' | 'support' | 'trade'
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
|
|
|
|
|
|
export interface BattleSide {
|
|
|
|
|
|
village: VillageRef
|
|
|
|
|
|
/** By unit; defenders may include `militia`. null where an attacker without survivors learned nothing. */
|
|
|
|
|
|
units: Record<string, number> | null
|
|
|
|
|
|
lost: Record<string, number> | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface BattleReport {
|
|
|
|
|
|
/** Whether the attacker won. */
|
|
|
|
|
|
won: boolean
|
|
|
|
|
|
/** Percent, between −25 and 25 by default. */
|
|
|
|
|
|
luck: number
|
|
|
|
|
|
/** Percent. */
|
|
|
|
|
|
morale: number
|
|
|
|
|
|
night: boolean
|
|
|
|
|
|
attacker: BattleSide
|
|
|
|
|
|
defender: BattleSide
|
|
|
|
|
|
wall: { before: number; after: number } | null
|
|
|
|
|
|
building: { type: BuildingType; before: number; after: number } | null
|
|
|
|
|
|
loot: Cost
|
|
|
|
|
|
capacity: number
|
2026-10-31 09:57:07 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Noblemen survived a won attack: loyalty before and after, and whether the village changed
|
|
|
|
|
|
* hands. no_coins: loyalty reached 0 but the attacker's coins pay for no further village.
|
|
|
|
|
|
*/
|
|
|
|
|
|
loyalty?: { before: number; after: number; conquered: boolean; no_coins?: boolean } | null
|
|
|
|
|
|
/** Units shot by archers and catapults before the melee (already counted in `lost`). */
|
|
|
|
|
|
volley?: Volley | null
|
2026-10-29 15:17:00 +00:00
|
|
|
|
/** Raiders from a barbarian camp attacked; a beaten band leaves a bounty in the village. */
|
|
|
|
|
|
raid?: boolean
|
|
|
|
|
|
bounty?: Cost | null
|
2026-10-30 12:54:57 +00:00
|
|
|
|
/** Defence reports only: the own fallen taken into the hospital, and when they stand again. */
|
|
|
|
|
|
wounded?: { units: Units; heals_at: string } | null
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
/** Only when scouts went along. Resources and buildings only when some got through. */
|
|
|
|
|
|
scouting?: {
|
|
|
|
|
|
sent: number
|
|
|
|
|
|
lost: number
|
|
|
|
|
|
through: boolean
|
|
|
|
|
|
resources: Cost | null
|
|
|
|
|
|
/** Levels of every instance, highest first. */
|
|
|
|
|
|
buildings: Partial<Record<BuildingType, number[]>> | null
|
|
|
|
|
|
} | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `rally.simulate`: a battle on paper with the world's rules. */
|
|
|
|
|
|
export interface SimulatedBattle {
|
|
|
|
|
|
won: boolean
|
|
|
|
|
|
attacker: { units: Record<string, number>; lost: Record<string, number> }
|
|
|
|
|
|
defender: { units: Record<string, number>; lost: Record<string, number> }
|
|
|
|
|
|
wall: { before: number; after: number } | null
|
|
|
|
|
|
building: { before: number; after: number } | null
|
|
|
|
|
|
power: { attack: number; defense: number }
|
2026-10-31 09:57:07 +00:00
|
|
|
|
volley?: Volley | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Each side's units killed by the other side's archers and catapults before the melee, by unit;
|
|
|
|
|
|
* they are part of that side's `lost`. defender is null in an attacker's report that saw nothing.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface Volley {
|
|
|
|
|
|
attacker: Record<string, number>
|
|
|
|
|
|
defender: Record<string, number> | null
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface SupportReport {
|
|
|
|
|
|
from: VillageRef
|
|
|
|
|
|
to: VillageRef
|
|
|
|
|
|
units: Units
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface ReportBase {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
happened_at: string
|
|
|
|
|
|
read: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-29 15:17:00 +00:00
|
|
|
|
/** Raiders whose camp was beaten down before they arrived: no battle. */
|
|
|
|
|
|
export interface ScatteredRaid {
|
|
|
|
|
|
raid: true
|
|
|
|
|
|
scattered: true
|
|
|
|
|
|
attacker: { village: VillageRef; units: null; lost: null }
|
|
|
|
|
|
defender: { village: VillageRef; units: null; lost: null }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
export type Report =
|
2026-10-29 15:17:00 +00:00
|
|
|
|
| (ReportBase & { type: 'attack' | 'defense'; payload: BattleReport | ScatteredRaid })
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
| (ReportBase & { type: 'support'; payload: SupportReport })
|
2026-10-31 10:07:33 +00:00
|
|
|
|
| (ReportBase & { type: 'trade'; payload: TradeReport })
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
|
2026-10-30 09:54:16 +00:00
|
|
|
|
export type TribeRole = 'leader' | 'council' | 'member'
|
|
|
|
|
|
export type Pact = 'ally' | 'nap'
|
|
|
|
|
|
/** What one player's tribe is to another's. */
|
|
|
|
|
|
export type TribeRelation = 'tribe' | 'ally' | 'nap' | 'enemy' | 'none'
|
|
|
|
|
|
export interface TribeRef {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
tag: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `tribe.show` and the reply to every `tribe.*` change. */
|
|
|
|
|
|
export interface TribePage {
|
|
|
|
|
|
tribe: {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
name: string
|
|
|
|
|
|
tag: string
|
|
|
|
|
|
description: string | null
|
|
|
|
|
|
/** The player's own role and player id. */
|
|
|
|
|
|
role: TribeRole
|
|
|
|
|
|
player_id: number
|
|
|
|
|
|
members: { player: { id: number; name: string }; role: TribeRole; points: number; villages: number }[]
|
|
|
|
|
|
/** Invites sent, for the leader and the council. */
|
|
|
|
|
|
invites: { player: { id: number; name: string }; at: string }[]
|
|
|
|
|
|
/**
|
|
|
|
|
|
* holds/ending: a pact both accepted (ending: until ends_at); offered: ours waiting;
|
|
|
|
|
|
* incoming: theirs waiting for us; enemy: we declared them; hostile: they declared us.
|
|
|
|
|
|
*/
|
|
|
|
|
|
relations: { tribe: TribeRef; state: Pact | 'enemy'; status: 'holds' | 'ending' | 'offered' | 'incoming' | 'enemy' | 'hostile'; ends_at: string | null }[]
|
|
|
|
|
|
events: { type: string; payload: Record<string, any>; at: string }[]
|
|
|
|
|
|
} | null
|
|
|
|
|
|
/** Invites the player has received. */
|
|
|
|
|
|
invites: { tribe: TribeRef; members: number; at: string }[]
|
|
|
|
|
|
max_members: number
|
|
|
|
|
|
/** How long ending a pact takes. */
|
|
|
|
|
|
notice_seconds: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-30 09:59:07 +00:00
|
|
|
|
/** A chat channel as the player names it: world, tribe, or dm:<player id>. */
|
|
|
|
|
|
export interface ChatChannel {
|
|
|
|
|
|
channel: string
|
|
|
|
|
|
/** The other player of a direct conversation. */
|
|
|
|
|
|
with: { id: number; name: string } | null
|
|
|
|
|
|
unread: number
|
|
|
|
|
|
}
|
|
|
|
|
|
export interface ChatMessage {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
player: { id: number; name: string }
|
|
|
|
|
|
body: string
|
|
|
|
|
|
at: string
|
|
|
|
|
|
}
|
|
|
|
|
|
/** `chat.history`: oldest first; more when older ones exist. */
|
|
|
|
|
|
export interface ChatHistory {
|
|
|
|
|
|
channel: string
|
|
|
|
|
|
messages: ChatMessage[]
|
|
|
|
|
|
more: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
/** Push `chat:message` to everyone who reads the channel. */
|
|
|
|
|
|
export interface ChatPush {
|
|
|
|
|
|
world_id: number
|
|
|
|
|
|
channel: string
|
|
|
|
|
|
message: ChatMessage
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-30 09:54:16 +00:00
|
|
|
|
/** `tribe.list`: every tribe of the world, strongest first. */
|
|
|
|
|
|
export interface TribeListRow extends TribeRef {
|
|
|
|
|
|
members: number
|
|
|
|
|
|
points: number
|
|
|
|
|
|
relation: TribeRelation
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export type RankingKind = 'players' | 'tribes' | 'villages' | 'attack' | 'defense'
|
2026-10-29 15:27:21 +00:00
|
|
|
|
|
|
|
|
|
|
export interface RankingRow {
|
|
|
|
|
|
rank: number
|
2026-10-30 09:54:16 +00:00
|
|
|
|
/** Every kind but tribes. */
|
|
|
|
|
|
player?: { id: number; name: string; tribe: { id: number; tag: string } | null }
|
|
|
|
|
|
/** Only in the tribe ranking. */
|
|
|
|
|
|
tribe?: TribeRef
|
|
|
|
|
|
members?: number
|
2026-10-29 15:27:21 +00:00
|
|
|
|
/** Only in the village ranking. */
|
|
|
|
|
|
village?: { id: number; name: string; x: number; y: number }
|
|
|
|
|
|
/** Points, or opponents defeated (by the food the fallen ate). */
|
|
|
|
|
|
value: number
|
|
|
|
|
|
/** Only in the player ranking. */
|
|
|
|
|
|
villages?: number
|
|
|
|
|
|
own: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `ranking.index`: one page; without a page asked for, the one with the own row. */
|
|
|
|
|
|
export interface RankingPage {
|
|
|
|
|
|
kind: RankingKind
|
|
|
|
|
|
page: number
|
|
|
|
|
|
pages: number
|
|
|
|
|
|
rows: RankingRow[]
|
|
|
|
|
|
own: { rank: number; page: number } | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
/** `report.index`, `report.delete` and `report.readAll`. */
|
|
|
|
|
|
export interface ReportPage {
|
|
|
|
|
|
reports: Report[]
|
|
|
|
|
|
page: number
|
|
|
|
|
|
pages: number
|
|
|
|
|
|
unread: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Counted in heads: a head eats one food per hour at world speed 1, world speed times that
|
|
|
|
|
|
* on a faster world. So a village holds the same heads on every world speed.
|
|
|
|
|
|
*/
|
2026-10-28 16:57:43 +00:00
|
|
|
|
export interface Population {
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Heads the farms feed. */
|
2026-10-28 16:57:43 +00:00
|
|
|
|
food_budget: number
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Heads that eat: villagers, soldiers, support stationed here, units in training, the wounded. */
|
2026-10-28 16:57:43 +00:00
|
|
|
|
upkeep: number
|
|
|
|
|
|
villagers: number
|
|
|
|
|
|
/** Villagers assigned to buildings. */
|
|
|
|
|
|
workers: number
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Villagers free for a new building level: not drafted, not needed by the buildings, not held back by the queue. */
|
|
|
|
|
|
idle: number
|
|
|
|
|
|
/** Villagers the build queue holds back for the levels it will add. */
|
|
|
|
|
|
reserved: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
soldiers: number
|
2026-10-28 20:51:43 +00:00
|
|
|
|
/** Units queued but not trained yet; they already eat instead of working. */
|
|
|
|
|
|
training: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-28 20:58:09 +00:00
|
|
|
|
export interface Levy {
|
|
|
|
|
|
/** 0 when no levy is under way. */
|
|
|
|
|
|
militia: number
|
|
|
|
|
|
/** When the militia go back to work on their own. */
|
|
|
|
|
|
until: string | null
|
|
|
|
|
|
/** How long a new levy would last. */
|
|
|
|
|
|
seconds: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-28 21:05:45 +00:00
|
|
|
|
/** Upkeep above income drains the food stock; once it is empty, soldiers desert after a grace time. */
|
|
|
|
|
|
export interface Starvation {
|
|
|
|
|
|
/** When the stock runs out at the current rates; null while food isn't draining. */
|
|
|
|
|
|
food_empty_at: string | null
|
|
|
|
|
|
/** Set while the stock is empty and the village eats more than it harvests. */
|
|
|
|
|
|
since: string | null
|
|
|
|
|
|
/** The next desertion wave, while starving. */
|
|
|
|
|
|
desertion_at: string | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-28 20:51:43 +00:00
|
|
|
|
/** A barracks, stable, workshop or academy: what it trains and its own queue. */
|
|
|
|
|
|
export interface MilitaryBuilding {
|
|
|
|
|
|
building_id: number
|
|
|
|
|
|
type: BuildingType
|
|
|
|
|
|
level: number
|
|
|
|
|
|
units: RecruitOption[]
|
|
|
|
|
|
queue: RecruitOrder[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface RecruitOption {
|
|
|
|
|
|
unit: UnitType
|
|
|
|
|
|
/** Per unit. */
|
|
|
|
|
|
cost: Cost
|
|
|
|
|
|
/** Per unit at this building, from its level and staffing. */
|
|
|
|
|
|
seconds: number
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Heads one unit takes: the food per hour it eats at world speed 1. */
|
2026-10-28 20:51:43 +00:00
|
|
|
|
upkeep: number
|
|
|
|
|
|
/** Most units that resources and villagers allowed when the snapshot was taken. */
|
|
|
|
|
|
max: number
|
|
|
|
|
|
blocked: 'requires' | null
|
|
|
|
|
|
requires: { type: BuildingType; level: number }[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface RecruitOrder {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
unit: UnitType
|
|
|
|
|
|
count: number
|
|
|
|
|
|
/** Units trained by the snapshot; the rest arrive every seconds_per_unit after starts_at. */
|
|
|
|
|
|
done: number
|
|
|
|
|
|
seconds_per_unit: number
|
|
|
|
|
|
starts_at: string
|
|
|
|
|
|
finishes_at: string
|
2026-10-28 16:57:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface Building {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
type: BuildingType
|
|
|
|
|
|
level: number
|
2026-10-28 18:54:19 +00:00
|
|
|
|
/** Building space this instance takes, fixed per type (0 for the wall). */
|
|
|
|
|
|
space: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
priority: number
|
|
|
|
|
|
workers: { assigned: number; required: number }
|
|
|
|
|
|
/** assigned / required, 0..1. */
|
|
|
|
|
|
staffing: number
|
|
|
|
|
|
production: { resource: Resource; per_hour: number } | null
|
|
|
|
|
|
/** Next level after everything already queued; null at max level. */
|
|
|
|
|
|
upgrade: Offer | null
|
2026-10-28 21:26:50 +00:00
|
|
|
|
/** null when the building cannot go lower (core buildings at level 1); target level 0 removes it. */
|
2026-10-28 20:18:57 +00:00
|
|
|
|
demolish: { target_level: number; refund: Cost; seconds: number } | null
|
2026-10-31 09:54:49 +00:00
|
|
|
|
/** What one instance does at its level, and one level up (null at max level); a copy's come scaled by `instance_share`. */
|
2026-10-29 13:38:34 +00:00
|
|
|
|
effects: BuildingEffect[]
|
|
|
|
|
|
next_effects: BuildingEffect[] | null
|
2026-10-31 09:54:49 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Share of full output this instance works at (production, capacity, hides, beds, training
|
|
|
|
|
|
* speed): 1 for the only or first instance of its type, then 0.5, 0.25, … for the copies,
|
|
|
|
|
|
* ranked by level. Copies cost more too; the server's costs include it.
|
|
|
|
|
|
*/
|
|
|
|
|
|
instance_share: number
|
2026-10-29 13:38:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** One line of what a building does: production at full staffing (per hour), percentages as whole numbers. */
|
|
|
|
|
|
export interface BuildingEffect {
|
2026-10-31 10:07:33 +00:00
|
|
|
|
key: 'production' | 'capacity' | 'hides' | 'beds' | 'detection' | 'wall_defense' | 'wall_bonus' | 'build_speed' | 'builders' | 'space' | 'recruit_speed' | 'merchants'
|
2026-10-29 13:38:34 +00:00
|
|
|
|
value: number
|
|
|
|
|
|
resource?: Resource
|
2026-10-28 16:57:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Whether it is affordable is left to the client, which compares the cost to projected resources. */
|
|
|
|
|
|
export interface Offer {
|
|
|
|
|
|
target_level: number
|
|
|
|
|
|
cost: Cost
|
|
|
|
|
|
seconds: number
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Idle villagers the level needs as extra workers; 0 for farms, which bring their own. */
|
|
|
|
|
|
villagers: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
blocked: BlockedReason | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface BuildOption extends Offer {
|
|
|
|
|
|
type: BuildingType
|
2026-10-28 18:54:19 +00:00
|
|
|
|
space: number
|
2026-10-28 20:01:23 +00:00
|
|
|
|
/** Requirements no building meets yet; only advanced buildings have any. */
|
|
|
|
|
|
requires: { type: BuildingType; level: number }[]
|
2026-10-31 09:54:49 +00:00
|
|
|
|
/** Share the new instance would work at: 1 for the first of its type, below 1 for a copy (whose `cost` is already raised). */
|
|
|
|
|
|
instance_share: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface BuildOrder {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
/** null for a new instance that does not exist yet. */
|
|
|
|
|
|
building_id: number | null
|
|
|
|
|
|
type: BuildingType
|
|
|
|
|
|
action: 'build' | 'upgrade' | 'demolish'
|
2026-10-28 21:26:50 +00:00
|
|
|
|
/** 0 means the instance is removed; levels start at 1. */
|
2026-10-28 16:57:43 +00:00
|
|
|
|
target_level: number
|
2026-10-28 18:54:19 +00:00
|
|
|
|
space: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
cost: Cost
|
2026-11-03 08:56:08 +00:00
|
|
|
|
/** Idle villagers the order holds back until it finishes; 0 for demolitions and farms. */
|
|
|
|
|
|
villagers: number
|
2026-10-28 16:57:43 +00:00
|
|
|
|
position: number
|
|
|
|
|
|
/** Builder slot working on it, or null while it waits. */
|
|
|
|
|
|
builder: number | null
|
|
|
|
|
|
starts_at: string | null
|
|
|
|
|
|
finishes_at: string | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Push `village:updated` after the server processed an event for this village. */
|
|
|
|
|
|
export interface VillageUpdated {
|
|
|
|
|
|
village_id: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** What a rejected `ws.send` carries. */
|
|
|
|
|
|
export interface GameError {
|
|
|
|
|
|
message: string
|
|
|
|
|
|
code?: string
|
2026-10-30 10:17:34 +00:00
|
|
|
|
/** The form field a refused registration points at. */
|
|
|
|
|
|
field?: string
|
2026-10-28 16:57:43 +00:00
|
|
|
|
}
|
2026-10-29 09:15:36 +00:00
|
|
|
|
|
|
|
|
|
|
/** A screen a quest goal points at that is not a building's row on the headquarters screen. */
|
|
|
|
|
|
export type QuestScreen = 'overview' | 'recruit' | 'rally' | 'workforce' | 'map' | 'reports'
|
|
|
|
|
|
|
|
|
|
|
|
export interface QuestGoal {
|
|
|
|
|
|
/** building: a type at a level in any village; instances: that many of a type in one village; counter: an action done that often. */
|
|
|
|
|
|
kind: 'building' | 'instances' | 'counter'
|
|
|
|
|
|
/** A building type, or a counter key such as `recruited.spear`. */
|
|
|
|
|
|
subject: string
|
|
|
|
|
|
have: number
|
|
|
|
|
|
need: number
|
|
|
|
|
|
met: boolean
|
|
|
|
|
|
/** Where to go: a building type (its headquarters row) or a screen. */
|
|
|
|
|
|
hint: BuildingType | QuestScreen
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface Quest {
|
|
|
|
|
|
key: string
|
|
|
|
|
|
goals: QuestGoal[]
|
|
|
|
|
|
reward: Partial<Resources>
|
|
|
|
|
|
complete: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface QuestLine {
|
|
|
|
|
|
line: 'construction' | 'army' | 'village'
|
|
|
|
|
|
done: number
|
|
|
|
|
|
total: number
|
|
|
|
|
|
/** The first unclaimed quest; null once the line is finished. */
|
|
|
|
|
|
quest: Quest | null
|
|
|
|
|
|
quests: { key: string; claimed: boolean }[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** A building level reached for the first time pays back part of its cost. */
|
|
|
|
|
|
export interface LevelReward {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
type: BuildingType
|
|
|
|
|
|
level: number
|
|
|
|
|
|
reward: Partial<Resources>
|
|
|
|
|
|
/** Where it was reached; it is collected into the current village. */
|
|
|
|
|
|
village: { id: number; name: string | null }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `quest.index`. */
|
|
|
|
|
|
export interface QuestBookState {
|
|
|
|
|
|
lines: QuestLine[]
|
|
|
|
|
|
rewards: LevelReward[]
|
|
|
|
|
|
/** What the next level of each building type in this village would pay back. */
|
|
|
|
|
|
upcoming: { type: BuildingType; level: number; reward: Partial<Resources> }[]
|
|
|
|
|
|
/** Share of a level's cost paid back, 0..1. */
|
|
|
|
|
|
share: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `quest.claim` and `quest.collect`. */
|
|
|
|
|
|
export interface QuestClaimed {
|
|
|
|
|
|
book: QuestBookState
|
|
|
|
|
|
village: VillageState
|
|
|
|
|
|
}
|
2026-10-29 09:33:26 +00:00
|
|
|
|
|
2026-10-31 09:55:45 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* The player's coins and the villages they pay for. Coins pay for villages beyond the first;
|
|
|
|
|
|
* noblemen take no slot, but at loyalty 0 they only take a village the coins pay for.
|
|
|
|
|
|
*/
|
2026-10-29 09:33:26 +00:00
|
|
|
|
export interface Conquest {
|
|
|
|
|
|
coins: number
|
2026-10-31 09:55:45 +00:00
|
|
|
|
/** Villages beyond the first that the coins pay for. */
|
2026-10-29 09:33:26 +00:00
|
|
|
|
slots: number
|
2026-10-31 09:55:45 +00:00
|
|
|
|
/** Villages the player holds beyond the first. */
|
2026-10-29 09:33:26 +00:00
|
|
|
|
used: number
|
2026-10-31 09:55:45 +00:00
|
|
|
|
/** Coins in total (not still missing) that pay for one more village than `slots`. */
|
2026-10-29 09:33:26 +00:00
|
|
|
|
next_slot_coins: number
|
|
|
|
|
|
coin_cost: Cost
|
|
|
|
|
|
/** Fields a nobleman marches at most; 0 for no limit. */
|
|
|
|
|
|
max_distance: number
|
|
|
|
|
|
}
|
2026-10-31 10:07:33 +00:00
|
|
|
|
|
|
|
|
|
|
// The market: merchants carry wood, clay and iron (never food) to other villages, for
|
|
|
|
|
|
// offers on the world's market and on repeating trade routes.
|
|
|
|
|
|
|
|
|
|
|
|
/** What merchants carry. */
|
|
|
|
|
|
export type TradeResource = Exclude<Resource, 'food'>
|
|
|
|
|
|
|
|
|
|
|
|
/** The village payload's market: merchants in all, free ones, and what one carries. */
|
|
|
|
|
|
export interface VillageMarket {
|
|
|
|
|
|
building_id: number
|
|
|
|
|
|
level: number
|
|
|
|
|
|
merchants: number
|
|
|
|
|
|
free: number
|
|
|
|
|
|
carry: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** A resource and an amount: one side of an offer. */
|
|
|
|
|
|
export interface TradeSide {
|
|
|
|
|
|
resource: TradeResource
|
|
|
|
|
|
amount: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Merchants under way. out: this village's merchants on the way there; back: on their way
|
|
|
|
|
|
* home; in: anyone's merchants coming here with cargo. Cargo is null on the way back.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface Trade {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
kind: 'out' | 'back' | 'in'
|
|
|
|
|
|
from: VillageRef
|
|
|
|
|
|
to: VillageRef
|
|
|
|
|
|
cargo: Cost | null
|
|
|
|
|
|
merchants: number
|
|
|
|
|
|
sent_at: string
|
|
|
|
|
|
arrives_at: string
|
|
|
|
|
|
route_id: number | null
|
|
|
|
|
|
/** Part of an accepted offer. */
|
|
|
|
|
|
offer: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** One of this village's open offers, its resources and merchants reserved; `merchants` per unit of `count`. */
|
|
|
|
|
|
export interface OwnOffer {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
give: TradeSide
|
|
|
|
|
|
want: TradeSide
|
|
|
|
|
|
count: number
|
|
|
|
|
|
merchants: number
|
|
|
|
|
|
created_at: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* A repeating trade route: every `every` real seconds it sends what the stock and the free
|
|
|
|
|
|
* merchants allow, up to the amounts. It pauses itself when the target changes owner.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface TradeRoute {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
to: VillageRef
|
|
|
|
|
|
resources: Cost
|
|
|
|
|
|
every: number
|
|
|
|
|
|
next_at: string
|
|
|
|
|
|
paused: boolean
|
|
|
|
|
|
paused_reason: null | 'owner_changed'
|
|
|
|
|
|
last_sent_at: string | null
|
|
|
|
|
|
last_cargo: Cost | null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `market.show`, and the reply to every mutating `market.*` intent. */
|
|
|
|
|
|
export interface MarketState {
|
|
|
|
|
|
server_time: string
|
|
|
|
|
|
market: {
|
|
|
|
|
|
building_id: number
|
|
|
|
|
|
level: number
|
|
|
|
|
|
merchants: number
|
|
|
|
|
|
free: number
|
|
|
|
|
|
busy: number
|
|
|
|
|
|
carry: number
|
|
|
|
|
|
minutes_per_field: number
|
|
|
|
|
|
resources: TradeResource[]
|
|
|
|
|
|
/** An offer may want at most this many times what it gives, and give at most this many times what it wants. */
|
|
|
|
|
|
max_ratio: number
|
|
|
|
|
|
/** Route intervals in real seconds, and how many routes the market runs at most. */
|
|
|
|
|
|
route: { min_every: number; max_every: number; max_routes: number }
|
|
|
|
|
|
} | null
|
|
|
|
|
|
trades: Trade[]
|
|
|
|
|
|
/** This village's own open offers. */
|
|
|
|
|
|
offers: OwnOffer[]
|
|
|
|
|
|
routes: TradeRoute[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `market.preview`: who lives on the field and how long merchants walk there. */
|
|
|
|
|
|
export interface TradePlan {
|
|
|
|
|
|
target: VillageRef
|
|
|
|
|
|
distance: number
|
|
|
|
|
|
seconds: number
|
|
|
|
|
|
arrives_at: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** An open offer on the world, as `market.offers` lists it, nearest first. */
|
|
|
|
|
|
export interface WorldOffer {
|
|
|
|
|
|
id: number
|
|
|
|
|
|
village: VillageRef
|
|
|
|
|
|
give: TradeSide
|
|
|
|
|
|
want: TradeSide
|
|
|
|
|
|
count: number
|
|
|
|
|
|
distance: number
|
|
|
|
|
|
seconds: number
|
|
|
|
|
|
own: boolean
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** `market.offers`. */
|
|
|
|
|
|
export interface MarketOffers {
|
|
|
|
|
|
server_time: string
|
|
|
|
|
|
offers: WorldOffer[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Report `trade`: a delivery arrived; `offer` when it was part of an accepted offer. */
|
|
|
|
|
|
export interface TradeReport {
|
|
|
|
|
|
from: VillageRef
|
|
|
|
|
|
to: VillageRef
|
|
|
|
|
|
cargo: Cost
|
|
|
|
|
|
offer: boolean
|
|
|
|
|
|
}
|