diff --git a/app/composables/useVillage.ts b/app/composables/useVillage.ts
index 45d73f9..0d92856 100644
--- a/app/composables/useVillage.ts
+++ b/app/composables/useVillage.ts
@@ -91,6 +91,11 @@ export function useVillage(villageId: number) {
}
const queueOrder = (v: VillageState, order: Omit) =>
v.queue.push({ ...order, id: --placeholder, position: v.queue.length + 1, builder: null, starts_at: null, finishes_at: null })
+ /** The queue holds back (or, with sign 1, frees) the villagers an order needs, as the server counts them. */
+ const hold = (v: VillageState, villagers: number, sign = -1) => {
+ v.population.idle = Math.max(0, v.population.idle + sign * villagers)
+ v.population.reserved = Math.max(0, v.population.reserved - sign * villagers)
+ }
/** stored + rate × elapsed, kept between 0 and the storage cap. */
const resources = computed(() => {
@@ -152,8 +157,9 @@ export function useVillage(villageId: number) {
const o = v.buildable.find((b) => b.type === type)
if (!o) return
pay(v, o.cost)
- queueOrder(v, { building_id: null, type, action: 'build', target_level: 1, space: o.space, cost: o.cost })
+ queueOrder(v, { building_id: null, type, action: 'build', target_level: 1, space: o.space, cost: o.cost, villagers: o.villagers })
v.space.used += o.space
+ hold(v, o.villagers)
},
}),
upgrade: (buildingId: number) =>
@@ -162,7 +168,8 @@ export function useVillage(villageId: number) {
const b = v.buildings.find((x) => x.id === buildingId)
if (!b?.upgrade) return
pay(v, b.upgrade.cost)
- queueOrder(v, { building_id: b.id, type: b.type, action: 'upgrade', target_level: b.upgrade.target_level, space: b.space, cost: b.upgrade.cost })
+ queueOrder(v, { building_id: b.id, type: b.type, action: 'upgrade', target_level: b.upgrade.target_level, space: b.space, cost: b.upgrade.cost, villagers: b.upgrade.villagers })
+ hold(v, b.upgrade.villagers)
},
}),
demolish: (buildingId: number) =>
@@ -170,7 +177,7 @@ export function useVillage(villageId: number) {
optimistic: (v) => {
const b = v.buildings.find((x) => x.id === buildingId)
if (!b?.demolish) return
- queueOrder(v, { building_id: b.id, type: b.type, action: 'demolish', target_level: b.demolish.target_level, space: b.space, cost: { wood: 0, clay: 0, iron: 0 } })
+ queueOrder(v, { building_id: b.id, type: b.type, action: 'demolish', target_level: b.demolish.target_level, space: b.space, cost: { wood: 0, clay: 0, iron: 0 }, villagers: 0 })
},
}),
cancel: (orderId: number) =>
@@ -181,6 +188,7 @@ export function useVillage(villageId: number) {
v.queue = v.queue.filter((x) => x !== o)
pay(v, o.cost, 1)
if (o.action === 'build') v.space.used -= o.space
+ hold(v, o.villagers ?? 0, 1)
},
}),
setPriority: (buildingId: number, priority: number) =>
diff --git a/app/pages/village/[id]/index.vue b/app/pages/village/[id]/index.vue
index b2da09c..3acfdfc 100644
--- a/app/pages/village/[id]/index.vue
+++ b/app/pages/village/[id]/index.vue
@@ -29,6 +29,7 @@ async function build(type: BuildingType) {
:resources="resources"
:can-afford="v.canAfford"
:busy="v.busy.value"
+ :idle="village.population.idle"
:another="village.buildings.some((b) => b.type === plotOption!.type)"
:all-link="`${base}/build`"
@build="build"
diff --git a/app/utils/buildingTags.ts b/app/utils/buildingTags.ts
index 02ead7c..cb968c7 100644
--- a/app/utils/buildingTags.ts
+++ b/app/utils/buildingTags.ts
@@ -73,7 +73,8 @@ export function buildingTag(
case 'farm': {
const p = village.population
- const free = Math.max(0, p.villagers - p.workers - village.levy.militia)
+ // Free for a new building level, from the server: not drafted, not working, not held for the queue.
+ const free = p.idle
const wanted = village.buildings.reduce((n, x) => n + x.workers.required, 0)
const short = wanted > p.workers
return {
diff --git a/i18n/locales/en.ts b/i18n/locales/en.ts
index 464024d..2c90546 100644
--- a/i18n/locales/en.ts
+++ b/i18n/locales/en.ts
@@ -100,7 +100,7 @@ export default {
resources: 'Not enough resources.',
core_building: 'Core buildings cannot go below level 1.',
requires: 'Build its requirements first.',
- villagers: 'Not enough villagers to train that many.',
+ villagers: 'Not enough free villagers: build up the farm.',
count: 'Pick at least one.',
levy_active: 'A levy is already under way.',
no_rally_point: 'Build a rally point first.',
diff --git a/i18n/pages/village.ts b/i18n/pages/village.ts
index ddf9052..3e05c4e 100644
--- a/i18n/pages/village.ts
+++ b/i18n/pages/village.ts
@@ -139,9 +139,12 @@ export default {
villagers: 'Villagers',
workers: 'Working',
idle: 'Idle',
+ reserved: 'Held for the queue',
soldiers: 'Soldiers',
workforce: 'Villagers at work',
- food_per_hour: '{value} food/h',
+ heads: '{value} heads',
+ upkeep_of: '{upkeep}/{budget} heads',
+ heads_hint: 'A head eats one food per hour at world speed 1, more on faster worlds. The farms feed the same heads on every world speed.',
},
buildings: {
title: 'Workforce',
@@ -340,8 +343,12 @@ export default {
space: 'Space {space}',
free_space: '{free} space free',
submit: 'Build',
+ villagers_title: '{need} free villagers needed as workers, {idle} free',
+ group: '{name} · {count}',
},
copy: {
+ name: '{name}, copy {n}',
+ nth: 'Copy {n} · {share}%',
share: 'works at {share}%',
this: 'Copy: works at {share}%',
new: 'New copy: works at {share}%, costs more',
@@ -368,6 +375,7 @@ export default {
max_level: 'Max level',
resources: 'Not enough resources',
requires: 'Needs a bigger headquarters',
+ villagers: 'Not enough free villagers: build up the farm',
},
},
},