Skip Provinces happiness for razed cities and recover pending choices
This commit is contained in:
parent
f8f8fc49cf
commit
2aa06b61a5
5 changed files with 54 additions and 5 deletions
|
|
@ -122,8 +122,8 @@ fn provinces() -> SpecialAdvanceInfo {
|
|||
|event| &mut event.combat_end,
|
||||
21,
|
||||
|game, player, s| {
|
||||
s.captured_city(player.index)
|
||||
.is_some()
|
||||
(s.captured_city(player.index).is_some()
|
||||
&& player.get(game).try_get_city(s.defender.position).is_some())
|
||||
.then_some(vec![PaymentRequest::optional(
|
||||
player
|
||||
.payment_options()
|
||||
|
|
@ -132,6 +132,13 @@ fn provinces() -> SpecialAdvanceInfo {
|
|||
)])
|
||||
},
|
||||
|game, c, s| {
|
||||
// Older saved games may already be waiting for Provinces after the
|
||||
// city was automatically razed at the city limit. Refund any payment
|
||||
// and finish that obsolete choice without touching a missing city.
|
||||
if game.player(c.player_index).try_get_city(s.defender.position).is_none() {
|
||||
c.player().gain_resources(game, c.choice[0].clone());
|
||||
return;
|
||||
}
|
||||
set_city_mood(
|
||||
game,
|
||||
s.defender.position,
|
||||
|
|
|
|||
|
|
@ -251,3 +251,9 @@ When Port has multiple legal sea spaces, city construction offers Choose port lo
|
|||
Public event triggers open a dismissible explanation with official display names, engine-provided rules and resource icons, including events that resolve without a decision. Joining during a pending event also shows its rules. Acknowledgements do not repeat the popup; undo removes withdrawn notices. Research-choice dialogs include the notice so it remains visible above the modal.
|
||||
|
||||
Replay displays event explanations only for the displayed historical action interval, including since-my-turn recap and full replay. Recap autoplay pauses at a new event so the rules can be read, then resumes with Play. Public log origins disambiguate same-name cards; incomplete old records show only shared rules rather than guessing a variant. Verified live/replay desktop and mobile browser tests, controller autoplay/acknowledgement checks and history/undo tests.
|
||||
|
||||
# Viewer 0.1.80 / engine 0.4.69
|
||||
|
||||
Provinces only offers its happiness payment if the captured city still belongs to the attacker. Captures automatically razed at the seven-city limit no longer offer an impossible choice. Existing saved Provinces prompts for missing cities resolve safely; any culture payment is refunded before continuing combat-end rewards. Capture and razing gold remain unchanged.
|
||||
|
||||
Verified both responses against a local copy of Willful-vertex-9913 without submitting live moves. Five regression tests cover retained-city happiness, obsolete prompts and automatic razing; all 732 tests, locale validation, type checks and production build pass.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.79",
|
||||
"version": "0.1.80",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.79",
|
||||
"version": "0.1.80",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.79",
|
||||
"version": "0.1.80",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
36
web-client/src/provinces.test.ts
Normal file
36
web-client/src/provinces.test.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createRequire } from 'node:module';
|
||||
import { readFileSync } from 'node:fs';
|
||||
const engine = createRequire(import.meta.url)('../.engine/server.js');
|
||||
function fixture() {
|
||||
const g = JSON.parse(readFileSync(new URL('../../server/tests/test_games/civilizations/rome/provinces.json', import.meta.url), 'utf8'));
|
||||
g.players[0].advances.push('Voting');
|
||||
return g;
|
||||
}
|
||||
const move = (g: any, action: any) => JSON.parse(engine.tryMove(JSON.stringify(g), JSON.stringify(action), 0));
|
||||
const capture = (g: any) => move(g, { Movement: { Move: { units: [0], destination: 'C1' } } });
|
||||
const provinces = (g: any) => g.events?.some((e: any) => e.handler?.origin?.SpecialAdvance === 'Provinces');
|
||||
for (const [payment, mood] of [[{}, 'Neutral'], [{ culture_tokens: 1 }, 'Happy']] as const) {
|
||||
test(`Provinces retained city becomes ${mood}`, () => {
|
||||
const g = capture(fixture());
|
||||
assert(provinces(g));
|
||||
const after = move(g, { Response: { Payment: [payment] } });
|
||||
assert.equal(after.players[0].cities.find((c: any) => c.position === 'C1').mood_state, mood);
|
||||
});
|
||||
test(`Provinces obsolete ${mood} choice resolves without charging culture`, () => {
|
||||
const g = capture(fixture());
|
||||
g.players[0].cities = g.players[0].cities.filter((c: any) => c.position !== 'C1');
|
||||
const after = move(g, { Response: { Payment: [payment] } });
|
||||
assert(!provinces(after));
|
||||
assert.equal(after.players[0].resources.culture_tokens, g.players[0].resources.culture_tokens);
|
||||
});
|
||||
}
|
||||
test('Provinces does not prompt for a city automatically razed at the city limit', () => {
|
||||
const g = fixture();
|
||||
g.players[0].cities.push(...['D1', 'D2', 'E1'].map(position => ({ position, mood_state: 'Neutral' })));
|
||||
const after = capture(g);
|
||||
assert.equal(after.players[0].cities.length, 7);
|
||||
assert(!after.players.some((p: any) => p.cities?.some((c: any) => c.position === 'C1')));
|
||||
assert(!provinces(after));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue