From bb3796f22bbb435e9e4149543765d4f9060486ed Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 28 Oct 2026 22:05:45 +0100 Subject: [PATCH] feat: food warnings: a strip when the stock drains, an alert with the desertion countdown when starving Co-Authored-By: Claude Opus 5.5 --- app/components/village/FoodWarning.vue | 42 ++++++++++++++++++++++++++ app/composables/useVillage.ts | 2 +- app/mock/server.ts | 12 ++++++++ app/pages/village/[id].vue | 2 ++ app/types/game.ts | 11 +++++++ i18n/pages/village.ts | 8 +++++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/components/village/FoodWarning.vue diff --git a/app/components/village/FoodWarning.vue b/app/components/village/FoodWarning.vue new file mode 100644 index 0000000..17ebc2a --- /dev/null +++ b/app/components/village/FoodWarning.vue @@ -0,0 +1,42 @@ + + + + diff --git a/app/composables/useVillage.ts b/app/composables/useVillage.ts index 89d3d16..09d51ad 100644 --- a/app/composables/useVillage.ts +++ b/app/composables/useVillage.ts @@ -58,7 +58,7 @@ export function useVillage(villageId: number) { if (!v) return null const times = [ ...v.queue.flatMap((o) => (o.finishes_at ? [Date.parse(o.finishes_at)] : [])), - ...(v.levy.until ? [Date.parse(v.levy.until)] : []), + ...[v.levy.until, v.starvation.food_empty_at, v.starvation.desertion_at].flatMap((at) => (at ? [Date.parse(at)] : [])), ...v.military.flatMap((m) => m.queue.filter((o) => o.done < o.count).map((o) => Date.parse(o.starts_at) + (o.done + 1) * o.seconds_per_unit * 1000), ), diff --git a/app/mock/server.ts b/app/mock/server.ts index 8227b30..9411784 100644 --- a/app/mock/server.ts +++ b/app/mock/server.ts @@ -430,6 +430,17 @@ function enqueue(state: MockState, v: MockVillage, order: Omit sum + o.count - o.done, 0), }, levy: { militia: militia(v), until: v.levy_until ? iso(v.levy_until) : null, seconds: LEVY_SECONDS }, + starvation: starvation(v), troops: Object.fromEntries(Object.entries(v.troops ?? {}).filter(([, n]) => n)), military: military(v, now), builders: BUILDERS, diff --git a/app/pages/village/[id].vue b/app/pages/village/[id].vue index 777cbf4..636421b 100644 --- a/app/pages/village/[id].vue +++ b/app/pages/village/[id].vue @@ -67,6 +67,8 @@ function openRecruit(buildingId?: number) { + +
diff --git a/app/types/game.ts b/app/types/game.ts index 1e6303a..53887e0 100644 --- a/app/types/game.ts +++ b/app/types/game.ts @@ -76,6 +76,7 @@ export interface VillageState { population: Population /** Villagers drafted as militia: they eat but don't work until `until`. */ levy: Levy + starvation: Starvation /** Own units standing in the village. */ troops: Partial> /** One entry per building that trains units, in building order. */ @@ -110,6 +111,16 @@ export interface Levy { seconds: number } +/** 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 +} + /** A barracks, stable, workshop or academy: what it trains and its own queue. */ export interface MilitaryBuilding { building_id: number diff --git a/i18n/pages/village.ts b/i18n/pages/village.ts index 1d83b3e..e3eec1b 100644 --- a/i18n/pages/village.ts +++ b/i18n/pages/village.ts @@ -64,6 +64,14 @@ export default { recruit: 'Recruit', hint: 'Build barracks to recruit units.', }, + food: { + runs_out_in: 'Your village eats more than it harvests. Food runs out in', + then: 'Once the stores are empty, soldiers start to desert after a grace period.', + starving: 'Your village is starving.', + desertion_in: 'Soldiers desert in', + fix: 'More farms or fewer soldiers stop it.', + fix_levy: 'The drafted militia leave the farms unworked: ending the levy helps.', + }, levy: { title: 'Levy', militia: 'Militia',