feat: coins pay for villages, not noblemen: the academy's coin box shows coins minted, villages held and paid for beyond the first, the coins one more village needs in total, and warns in amber when the coins pay for no further village; loyalty and error wording follow; the mock keeps minted coins
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b746bb9b00
commit
836907a783
|
|
@ -9,14 +9,16 @@ const count = ref(1)
|
||||||
const affordable = computed(() =>
|
const affordable = computed(() =>
|
||||||
Math.floor(Math.min(...(['wood', 'clay', 'iron'] as const).map((r) => (props.conquest.coin_cost[r] ? props.resources[r] / props.conquest.coin_cost[r] : Infinity)))),
|
Math.floor(Math.min(...(['wood', 'clay', 'iron'] as const).map((r) => (props.conquest.coin_cost[r] ? props.resources[r] / props.conquest.coin_cost[r] : Infinity)))),
|
||||||
)
|
)
|
||||||
|
/** Coins pay for another village: noblemen at loyalty 0 take one. */
|
||||||
|
const room = computed(() => props.conquest.slots > props.conquest.used)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Minting coins at the academy: coins pay for noble slots, the n-th slot n more coins. -->
|
<!-- Minting coins at the academy: coins pay for every village beyond the first; noblemen take no slot. -->
|
||||||
<template>
|
<template>
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<span class="panel-title">{{ $t('village.conquest.title') }}</span>
|
<span class="panel-title">{{ $t('village.conquest.title') }}</span>
|
||||||
<span class="badge badge-plain tabular-nums">{{ $t('village.conquest.slots', { used: conquest.used, slots: conquest.slots }) }}</span>
|
<span class="badge badge-plain tabular-nums">{{ $t('village.conquest.badge', { used: conquest.used, slots: conquest.slots }) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body space-y-2 text-sm">
|
<div class="panel-body space-y-2 text-sm">
|
||||||
<p class="text-ink-700">{{ $t('village.conquest.about') }}</p>
|
<p class="text-ink-700">{{ $t('village.conquest.about') }}</p>
|
||||||
|
|
@ -27,11 +29,17 @@ const affordable = computed(() =>
|
||||||
<td class="text-right font-semibold tabular-nums">{{ conquest.coins }}</td>
|
<td class="text-right font-semibold tabular-nums">{{ conquest.coins }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="whitespace-nowrap">{{ $t('village.conquest.next_slot') }}</td>
|
<td class="whitespace-nowrap">{{ $t('village.conquest.villages') }}</td>
|
||||||
<td class="text-right tabular-nums">{{ $t('village.conquest.coins_more', { count: conquest.next_slot_coins }) }}</td>
|
<td class="text-right whitespace-nowrap tabular-nums">{{ $t('village.conquest.villages_value', { used: conquest.used, slots: conquest.slots }) }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="whitespace-nowrap">{{ $t('village.conquest.next_village') }}</td>
|
||||||
|
<td class="text-right whitespace-nowrap tabular-nums">{{ $t('village.conquest.coins_total', { count: conquest.next_slot_coins }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<p v-if="room" class="text-xs font-semibold text-moss-700">{{ $t('village.conquest.room') }}</p>
|
||||||
|
<p v-else class="border border-gold-600 bg-gold-400 px-2 py-0.5 text-xs text-ink-900">{{ $t('village.conquest.full') }}</p>
|
||||||
<p class="flex flex-wrap items-center justify-between gap-x-2 gap-y-1">
|
<p class="flex flex-wrap items-center justify-between gap-x-2 gap-y-1">
|
||||||
<span>{{ $t('village.conquest.coin_cost') }}</span>
|
<span>{{ $t('village.conquest.coin_cost') }}</span>
|
||||||
<UiCost :cost="conquest.coin_cost" :have="resources" />
|
<UiCost :cost="conquest.coin_cost" :have="resources" />
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,8 @@ interface MockState {
|
||||||
quests?: Record<string, string[]>
|
quests?: Record<string, string[]>
|
||||||
/** Chat messages; the mock has no other players, so only the player's own talk. */
|
/** Chat messages; the mock has no other players, so only the player's own talk. */
|
||||||
chat?: { id: number; world_id: number; channel: string; user_id: number; body: string; at: number }[]
|
chat?: { id: number; world_id: number; channel: string; user_id: number; body: string; at: number }[]
|
||||||
|
/** Coins minted per `user:world`. */
|
||||||
|
coins?: Record<string, number>
|
||||||
/** Tribes, each led by the one user who founded it: the mock has no other players. */
|
/** Tribes, each led by the one user who founded it: the mock has no other players. */
|
||||||
tribes?: { id: number; world_id: number; user_id: number; name: string; tag: string; description: string | null; events: { type: string; payload: Record<string, any>; at: string }[] }[]
|
tribes?: { id: number; world_id: number; user_id: number; name: string; tag: string; description: string | null; events: { type: string; payload: Record<string, any>; at: string }[] }[]
|
||||||
}
|
}
|
||||||
|
|
@ -646,7 +648,7 @@ function view(state: MockState, v: MockVillage, now: number): VillageState {
|
||||||
support: support(state, v),
|
support: support(state, v),
|
||||||
rally: rallyInfo(v),
|
rally: rallyInfo(v),
|
||||||
loyalty: 100,
|
loyalty: 100,
|
||||||
conquest: { coins: 0, slots: 0, used: 0, next_slot_coins: 1, coin_cost: { wood: 28000, clay: 30000, iron: 25000 }, max_distance: 100 },
|
conquest: conquest(state, v),
|
||||||
villages: state.villages
|
villages: state.villages
|
||||||
.filter((o) => o.user_id === v.user_id && o.world_id === v.world_id)
|
.filter((o) => o.user_id === v.user_id && o.world_id === v.world_id)
|
||||||
.map((o) => ({ id: o.id, name: o.name, x: o.x, y: o.y, points: points(o) })),
|
.map((o) => ({ id: o.id, name: o.name, x: o.x, y: o.y, points: points(o) })),
|
||||||
|
|
@ -704,6 +706,21 @@ function view(state: MockState, v: MockVillage, now: number): VillageState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** One coin a piece. */
|
||||||
|
const COIN_COST: Cost = { wood: 28000, clay: 30000, iron: 25000 }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coins pay for villages beyond the first: the n-th extra village takes n more coins (1, 3, 6, …
|
||||||
|
* in total). A crude stand-in for the backend's curve; noblemen take no slot.
|
||||||
|
*/
|
||||||
|
function conquest(state: MockState, v: MockVillage): VillageState['conquest'] {
|
||||||
|
const coins = state.coins?.[`${v.user_id}:${v.world_id}`] ?? 0
|
||||||
|
let slots = 0
|
||||||
|
while (((slots + 1) * (slots + 2)) / 2 <= coins) slots++
|
||||||
|
const held = state.villages.filter((o) => o.user_id === v.user_id && o.world_id === v.world_id).length
|
||||||
|
return { coins, slots, used: Math.max(0, held - 1), next_slot_coins: ((slots + 1) * (slots + 2)) / 2, coin_cost: COIN_COST, max_distance: 100 }
|
||||||
|
}
|
||||||
|
|
||||||
const continentOf = (x: number, y: number) => `K${Math.floor((y - MAP_MIN) / 100)}${Math.floor((x - MAP_MIN) / 100)}`
|
const continentOf = (x: number, y: number) => `K${Math.floor((y - MAP_MIN) / 100)}${Math.floor((x - MAP_MIN) / 100)}`
|
||||||
|
|
||||||
/** Placeholder points: 5 per building level. */
|
/** Placeholder points: 5 per building level. */
|
||||||
|
|
@ -1518,12 +1535,13 @@ const handlers: Record<string, Handler> = {
|
||||||
return view(state, v, now)
|
return view(state, v, now)
|
||||||
},
|
},
|
||||||
|
|
||||||
// The mock takes the payment but keeps no coins; the backend has the real slots.
|
|
||||||
'village.mint': (state, user, data, now) => {
|
'village.mint': (state, user, data, now) => {
|
||||||
const v = ownVillage(state, user, data.village_id, now)
|
const v = ownVillage(state, user, data.village_id, now)
|
||||||
if (!v.buildings.some((b) => b.type === 'academy')) fail('requires')
|
if (!v.buildings.some((b) => b.type === 'academy')) fail('requires')
|
||||||
const n = Math.max(1, Number(data.count) || 1)
|
const n = Math.max(1, Math.floor(Number(data.count) || 1))
|
||||||
pay(v, { wood: 28000 * n, clay: 30000 * n, iron: 25000 * n })
|
pay(v, mapCost(COIN_COST, (c) => c * n))
|
||||||
|
const key = `${v.user_id}:${v.world_id}`
|
||||||
|
state.coins = { ...state.coins, [key]: (state.coins?.[key] ?? 0) + n }
|
||||||
return view(state, v, now)
|
return view(state, v, now)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ export interface VillageState {
|
||||||
rally: RallyInfo
|
rally: RallyInfo
|
||||||
/** The player's unread reports on this world. */
|
/** The player's unread reports on this world. */
|
||||||
unread_reports: number
|
unread_reports: number
|
||||||
/** 0..100; noblemen lower it, at 0 the village changes hands. */
|
/** 0..100; noblemen lower it, at 0 the village changes hands if the attacker's coins pay for another village. */
|
||||||
loyalty: number
|
loyalty: number
|
||||||
conquest: Conquest
|
conquest: Conquest
|
||||||
/** The player's villages in this world, by id: the switcher. */
|
/** The player's villages in this world, by id: the switcher. */
|
||||||
|
|
@ -661,12 +661,17 @@ export interface QuestClaimed {
|
||||||
village: VillageState
|
village: VillageState
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Coins and noble slots of the player. Every nobleman alive and every village beyond the first takes a slot. */
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
export interface Conquest {
|
export interface Conquest {
|
||||||
coins: number
|
coins: number
|
||||||
|
/** Villages beyond the first that the coins pay for. */
|
||||||
slots: number
|
slots: number
|
||||||
|
/** Villages the player holds beyond the first. */
|
||||||
used: number
|
used: number
|
||||||
/** Coins still missing for the next slot. */
|
/** Coins in total (not still missing) that pay for one more village than `slots`. */
|
||||||
next_slot_coins: number
|
next_slot_coins: number
|
||||||
coin_cost: Cost
|
coin_cost: Cost
|
||||||
/** Fields a nobleman marches at most; 0 for no limit. */
|
/** Fields a nobleman marches at most; 0 for no limit. */
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ export default {
|
||||||
name: 'A village name has 1 to 32 characters.',
|
name: 'A village name has 1 to 32 characters.',
|
||||||
world_full: 'This world is full.',
|
world_full: 'This world is full.',
|
||||||
quest_open: 'This quest is not complete yet.',
|
quest_open: 'This quest is not complete yet.',
|
||||||
coins: 'Mint more coins at the academy for another nobleman.',
|
coins: 'Your coins don\'t pay for another village yet: mint more at the academy.',
|
||||||
too_far: 'Noblemen don\'t march that far.',
|
too_far: 'Noblemen don\'t march that far.',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export default {
|
||||||
barracks: "Trains spear fighters, swordsmen and archers. A higher level trains faster.",
|
barracks: "Trains spear fighters, swordsmen and archers. A higher level trains faster.",
|
||||||
stable: "Trains scouts and cavalry. A higher level trains faster.",
|
stable: "Trains scouts and cavalry. A higher level trains faster.",
|
||||||
workshop: "Builds rams and catapults. A higher level builds faster.",
|
workshop: "Builds rams and catapults. A higher level builds faster.",
|
||||||
academy: "Trains noblemen and mints the coins that pay for them.",
|
academy: "Trains noblemen and mints the coins that pay for every village beyond your first.",
|
||||||
hospital: "Half of your own soldiers who fall defending the village are carried in here wounded, as far as there are beds, and stand again after a few hours. They eat meanwhile.",
|
hospital: "Half of your own soldiers who fall defending the village are carried in here wounded, as far as there are beds, and stand again after a few hours. They eat meanwhile.",
|
||||||
},
|
},
|
||||||
effects: {
|
effects: {
|
||||||
|
|
@ -180,11 +180,15 @@ export default {
|
||||||
},
|
},
|
||||||
conquest: {
|
conquest: {
|
||||||
title: 'Coins',
|
title: 'Coins',
|
||||||
about: 'Noblemen need noble slots. Coins minted here pay for them: the first slot takes 1 coin, the second 2 more, the third 3 more. Every nobleman and every village beyond your first takes a slot.',
|
about: 'Coins pay for every village beyond your first, and each further village needs more of them. Noblemen need no coins, but at loyalty 0 they only take a village your coins pay for.',
|
||||||
slots: '{used}/{slots} noble slots',
|
badge: '{used}/{slots} extra villages',
|
||||||
coins: 'Coins minted',
|
coins: 'Coins minted',
|
||||||
next_slot: 'Next slot',
|
villages: 'Villages beyond your first',
|
||||||
coins_more: '{count} more coins',
|
villages_value: '{used} held, {slots} paid for',
|
||||||
|
next_village: 'One more village',
|
||||||
|
coins_total: '{count} coins in total',
|
||||||
|
room: 'Your coins pay for another village now.',
|
||||||
|
full: 'Your coins pay for no further village: mint more before your noblemen bring loyalty to 0.',
|
||||||
coin_cost: 'One coin costs',
|
coin_cost: 'One coin costs',
|
||||||
count: 'Coins to mint',
|
count: 'Coins to mint',
|
||||||
mint: 'Mint',
|
mint: 'Mint',
|
||||||
|
|
@ -192,7 +196,7 @@ export default {
|
||||||
},
|
},
|
||||||
switcher: { label: 'Your villages', prev: 'Previous village', next: 'Next village' },
|
switcher: { label: 'Your villages', prev: 'Previous village', next: 'Next village' },
|
||||||
loyalty: 'Loyalty',
|
loyalty: 'Loyalty',
|
||||||
loyalty_about: 'Noblemen lower it; at 0 the village changes hands. It grows back by itself.',
|
loyalty_about: 'Noblemen lower it; at 0 the village changes hands if the attacker\'s coins pay for another village. It grows back by itself.',
|
||||||
troops: {
|
troops: {
|
||||||
title: 'Troops',
|
title: 'Troops',
|
||||||
training: '{count} in training',
|
training: '{count} in training',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue