Fix independent Explorers benefits; release viewer 0.1.216 engine 0.4.148

This commit is contained in:
coyotte508 2026-11-12 23:55:08 +00:00
commit c13e8e5dfe
8 changed files with 283 additions and 6 deletions

View file

@ -0,0 +1,23 @@
# Explorers eligibility (A21 / A22)
Independently checked both printed faces in the [English action-deck scan](https://cdn.steamusercontent.com/ugc/1781731512046582765/54C4F5AA6E9F0654E9E9379CD3D4BEECF8F7293C/)
identified by `card-text-audit.json` (Steam Workshop 2651868219, Monumental Edition).
This is a gameplay-text check, not an inference from that audit's title verification.
Both faces say (culture-token icon rendered in brackets):
> Pay 1 [culture token] to play.
>
> As an Action, do one or both of the following:
> 1. Reveal an unrevealed region adjacent to a region with one of your cities.
> 2. Place a free Settler in one of your cities.
The 9586 × 10000 texture has eight columns and six rows. A21 is column 5,
row 3; A22 is column 4, row 5 (one-based). Their tactics are Routing and
Prepared Defenses respectively.
The two benefits are independent: a city and a Settler in supply suffice even
without an eligible unrevealed region. An eligible region still suffices when
Settlers are exhausted. Neither benefit available remains ineligible. Existing
optional resolution, action/culture costs, Shogunate handling, and supply-based
unit gain without Recruit/city activation are unchanged.

View file

@ -154,9 +154,11 @@ fn explorer(id: u8, tactics_card: TacticsCardFactory) -> ActionCard {
AND/OR gain a free settler in one of your cities.",
|c| c.action().culture_tokens(1),
|game, player, _| {
!action_explore_request(game, player.index)
.choices
.is_empty()
// The printed card allows one or both benefits, independently.
(!player.cities.is_empty() && player.available_units().settlers > 0)
|| !action_explore_request(game, player.index)
.choices
.is_empty()
},
)
.tactics_card(tactics_card);

View file

@ -510,3 +510,87 @@ fn technology_trade_only_offers_partners_within_two_spaces() {
}
}
}
#[test]
fn test_explorers_independent_benefits() {
use server::action_card::ActionCardInfo;
use server::content::persistent_events::PersistentEventRequest;
use server::map::Terrain;
use server::unit::{Unit, UnitType};
for id in [21, 22] {
for revealed in [false, true] {
for settlers in [0, 4] {
for owns_city in [false, true] {
let mut game = JSON.load_game("explorer");
if revealed {
game.map.unexplored_blocks.clear();
for terrain in game.map.tiles.values_mut() {
if terrain.is_unexplored() {
*terrain = Terrain::Fertile;
}
}
}
let position = game.player(1).cities[0].position;
let p = game.player_mut(1);
p.action_cards = vec![id];
p.units = (0..settlers)
.map(|n| Unit::new(1, position, UnitType::Settler, n))
.collect();
p.next_unit_id = settlers;
if !owns_city {
p.cities.clear();
}
let card = game.cache.get_action_card(id);
assert_eq!(
(card.civil_card.can_play)(
&game,
game.player(1),
&ActionCardInfo::new(id, None, None)
),
owns_city && (!revealed || settlers < 4),
"card {id}, revealed {revealed}, settlers {settlers}, city {owns_city}"
);
if !revealed || !owns_city || settlers == 4 {
continue;
}
for accept in [false, true] {
let actions = game.actions_left;
let culture = game.player(1).resources.culture_tokens;
let activations = game.player(1).cities[0].activations;
let mut after = server::game_api::execute(
game.clone(),
Action::Playing(PlayingAction::ActionCard(id)),
1,
);
after = server::game_api::execute(
after,
payment_response(ResourcePile::culture_tokens(1)),
1,
);
let PersistentEventRequest::SelectPositions(request) =
&after.current_event_handler().unwrap().request
else {
panic!("expected settler placement, not exploration");
};
assert_eq!(request.description, "Gain a free settler");
after = server::game_api::execute(
after,
Action::Response(EventResponse::SelectPositions(if accept {
vec![position]
} else {
vec![]
})),
1,
);
assert!(after.current_event_handler().is_none());
assert_eq!(after.player(1).units.len(), usize::from(accept));
assert_eq!(after.actions_left, actions - 1);
assert_eq!(after.player(1).resources.culture_tokens, culture - 1);
assert_eq!(after.player(1).cities[0].activations, activations);
}
}
}
}
}
}

View file

@ -1268,3 +1268,25 @@ Verified with Rust 1.94.1: 500 native workspace tests pass (one existing ignored
1,062 frontend tests against the packed engine, gallery checks, all 17 locales,
extraction checks, Svelte (zero errors/warnings), and production build. Existing
Clippy warnings and expected rejected-move WASM diagnostics remain.
# Viewer 0.1.216 / engine 0.4.148
Explorers (A21 and A22) can be played for its free Settler even when no eligible
unrevealed region remains. The printed cards independently allow one or both
benefits; see `docs/explorers-eligibility.md` for the checked source and locations.
Exploration alone remains available with exhausted Settler supply, and a card
with neither benefit remains unavailable. Empty exploration is skipped; optional
choices, the action and culture costs, Japan's Shogunate exceptions, and placement
without city activation are preserved.
Publish the matching engine, bridge and viewer. Preserve the real-game gallery,
all unrelated metadata, and game-length labels/order with Standard as default.
No live game moves, historical repairs or Fossil refresh are part of this release.
Verified with Rust 1.94.1: 501 native workspace tests pass (one existing ignored),
1,064 frontend tests against the packed engine, gallery and locale checks, Svelte
with zero errors/warnings, and production build. Eight desktop/mobile browser
cases cover Japan/Rome and both cards through real card play, culture payment,
map city selection and Settler confirmation. Packed-engine protocol and split
WASM bundle checks pass. Existing Clippy warnings and expected rejected-move
WASM diagnostics remain.

View file

@ -1,12 +1,12 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.215",
"version": "0.1.216",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@boardgamers/clash-web-client",
"version": "0.1.215",
"version": "0.1.216",
"dependencies": {
"@boardgamers/protocol": "0.9.0",
"lucide-svelte": "^0.577.0",

View file

@ -1,6 +1,6 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.215",
"version": "0.1.216",
"private": true,
"type": "module",
"scripts": {

View file

@ -0,0 +1,74 @@
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { chromium } from 'playwright';
const engine = createRequire(import.meta.url)(process.env.EXPLORERS_ENGINE ?? '../.engine/server.js');
const dist = process.env.EXPLORERS_DIST ? new URL(`file://${process.env.EXPLORERS_DIST}/`) : new URL('../dist/', import.meta.url);
const browser = await chromium.launch({ headless: true, args: ['--use-gl=angle', '--use-angle=swiftshader'] });
try {
for (const width of [1400, 390]) for (const civ of ['Japan', 'Rome']) for (const id of [21, 22]) {
let raw = await engine.init(2, [], { civilization: 'ChooseCivilization' }, 'explorers-ui', {});
for (const choice of [civ, civ === 'Rome' ? 'India' : 'Rome'])
raw = engine.tryMove(raw, JSON.stringify({ ChooseCivilization: choice }), engine.currentPlayer(raw));
let state = JSON.parse(raw);
const seat = engine.currentPlayer(raw), p = state.players[seat];
p.action_cards = [id];
p.resources.culture_tokens = 3;
state.map.unexplored_blocks = [];
state.map.tiles = state.map.tiles.map(([pos, terrain]) => [pos, typeof terrain === 'object' || terrain === 'Unexplored' ? 'Fertile' : terrain]);
const before = structuredClone(state), city = p.cities[0].position;
const page = await browser.newPage({ viewport: { width, height: 900 } });
const errors = [], sent = [];
page.on('pageerror', e => errors.push(e.message));
await page.exposeFunction('applyMove', async action => {
const parsed = typeof action === 'string' ? JSON.parse(action) : action;
state = JSON.parse(engine.tryMove(JSON.stringify(state), JSON.stringify(parsed), seat));
sent.push(parsed);
await page.evaluate(state => host.emit('state', state), engine.stripSecret(JSON.stringify(state), seat));
});
await page.route('**/*', async route => {
const path = new URL(route.request().url()).pathname;
if (path === '/') return route.fulfill({ contentType: 'text/html', body: '<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><div id="app"></div><script src="/viewer.js"></script>' });
if (!['/viewer.js', '/server_bg.wasm'].includes(path)) return route.abort();
return route.fulfill({ contentType: path.endsWith('.wasm') ? 'application/wasm' : 'text/javascript', body: await readFile(new URL(path.slice(1), dist)) });
});
await page.goto('http://clash.test/');
await page.evaluate(({ state, seat }) => {
window.host = clash3d.launch('#app');
host.on('move', action => window.applyMove(action));
host.emit('player', { index: seat });
host.emit('preferences', { sound: false });
host.emit('state', state);
}, { state: engine.stripSecret(JSON.stringify(state), seat), seat });
await page.getByRole('button', { name: 'Action cards: 1', exact: true }).click();
await page.getByRole('button', { name: 'Play Explorers', exact: true }).click();
const panel = page.locator('.decision-panel');
await panel.getByText('Gain a free settler', { exact: false }).waitFor();
assert.equal(await page.getByText('Choose a region to explore', { exact: false }).count(), 0);
assert.deepEqual(await page.locator('.map-hit-target').evaluateAll(els => els.map(e => e.dataset.position)), [city]);
const target = page.locator(`.map-hit-target[data-position="${city}"]`);
await page.waitForTimeout(400);
const box = await target.boundingBox();
assert.ok(box);
// The canvas handles map pointer events; labels provide the projected position.
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
await page.screenshot({ path: `/tmp/clash-explorers-${civ}-${id}-${width}.png` });
await panel.getByRole('button', { name: 'Confirm', exact: true }).click();
await panel.waitFor({ state: 'detached' });
assert.deepEqual(sent, [{ Playing: { ActionCard: id } }, { Response: { Payment: [{ culture_tokens: 1 }] } }, { Response: { SelectPositions: [city] } }]);
const after = state.players[seat];
assert.equal(after.units.length, p.units.length + 1);
assert.equal(after.units.at(-1).unit_type, 'Settler');
assert.equal(after.units.at(-1).position, city);
assert.deepEqual(after.cities, p.cities);
assert.equal(after.resources.culture_tokens, 2);
assert.equal(state.actions_left, before.actions_left - 1);
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
assert.deepEqual(errors, []);
console.log(`${width}px ${civ} A${id}: fully revealed map → card play → free settler; one action/culture, no activation or exploration prompt`);
await page.close();
}
} finally {
await browser.close();
}

View file

@ -1876,3 +1876,75 @@ test('Great Engineer construction works at zero actions through Idol and Shoguna
assert.equal(after.actions_left, 0);
}
});
test('both Explorers cards independently grant settlers on a fully revealed map', async () => {
for (const civ of ['Japan', 'Rome']) for (const id of [21, 22]) {
for (const accept of [false, true]) for (const shogunate of ['none', 'accept', 'decline', 'zero']) {
if (shogunate !== 'none' && civ !== 'Japan') continue;
const freeAction = shogunate === 'accept' || shogunate === 'zero';
const g = await setup(civ), index = seat(g), p = g.players[index];
p.action_cards = [id];
g.map.unexplored_blocks = [];
g.map.tiles = g.map.tiles.map(([pos, terrain]: [string, any]) =>
[pos, typeof terrain === 'object' || terrain === 'Unexplored' ? 'Fertile' : terrain]);
if (shogunate !== 'none') addAdvance(p, 'Nationalism');
if (shogunate === 'zero') g.actions_left = 0;
const card = view(g).actionCards.find((c: any) => c.id === id);
assert.ok(card.action, `${civ} ${id}: ${card.reason}`);
let after = move(g, card.action);
if (shogunate === 'accept' || shogunate === 'decline') {
assert.match(view(after).choiceDecision.name, /Shogunate/);
after = move(after, { Response: { Bool: freeAction } });
}
after = move(after, { Response: { Payment: [{ culture_tokens: 1 }] } });
assert.equal(view(after).decision.description, 'Gain a free settler', 'no phantom exploration choice');
after = move(after, { Response: { SelectPositions: accept ? [p.cities[0].position] : [] } });
assert.equal(view(after).decision, null);
assert.equal(after.players[index].units.length, p.units.length + Number(accept));
if (accept) {
const settler = after.players[index].units.at(-1);
assert.equal(settler.unit_type, 'Settler');
assert.equal(settler.position, p.cities[0].position);
}
assert.equal(after.actions_left, g.actions_left - Number(!freeAction));
assert.equal(after.players[index].resources.culture_tokens, p.resources.culture_tokens - 1);
assert.deepEqual(after.players[index].cities, p.cities, 'free settler does not activate or change a city');
assert.ok(!(after.players[index].action_cards ?? []).includes(id));
assert.equal(after.players[index].event_info?.['Shogunate card'] === 'used', freeAction);
}
}
});
test('Explorers requires at least one available benefit and preserves ordinary costs', async () => {
for (const civ of ['Japan', 'Rome']) for (const id of [21, 22]) {
const original = await setup(civ), index = seat(original);
original.players[index].action_cards = [id];
for (const scenario of ['explore-only', 'neither', 'no-city', 'no-culture', 'no-actions']) {
const g = structuredClone(original), p = g.players[index];
if (scenario !== 'explore-only') {
g.map.unexplored_blocks = [];
g.map.tiles = g.map.tiles.map(([pos, terrain]: [string, any]) =>
[pos, typeof terrain === 'object' || terrain === 'Unexplored' ? 'Fertile' : terrain]);
}
if (scenario === 'explore-only' || scenario === 'neither') {
p.units = Array.from({ length: 4 }, (_, id) => ({ id, position: p.cities[0].position, unit_type: 'Settler' }));
p.next_unit_id = 4;
}
if (scenario === 'no-city') p.cities = [];
if (scenario === 'no-culture') p.resources.culture_tokens = 0;
if (scenario === 'no-actions') g.actions_left = 0;
const card = view(g).actionCards.find((c: any) => c.id === id);
assert.equal(Boolean(card.action), scenario === 'explore-only', `${civ} ${id}: ${scenario}`);
if (scenario === 'explore-only') {
let after = move(g, card.action);
after = move(after, { Response: { Payment: [{ culture_tokens: 1 }] } });
assert.match(view(after).decision.description, /explore/i);
after = move(after, { Response: { SelectPositions: [] } });
assert.equal(view(after).decision, null);
assert.equal(after.players[index].units.length, 4);
} else {
assert.throws(() => move(g, { Playing: { ActionCard: id } }), 'engine rejects ineligible play, not just UI');
}
}
}
});