Add Five Objectives achievement and release viewer 223 engine 156

This commit is contained in:
coyotte508 2026-11-18 22:48:58 +00:00
commit 59fd267138
9 changed files with 211 additions and 42 deletions

View file

@ -1,12 +1,10 @@
# Clash of Cultures achievements
Delivered engine release: `@boardgamers/clash-server` **0.4.151**, BGS `clash/1`
(Clash of Cultures: Monumental edition). Revision 2 and all 15 faction assets were
independently reviewed, published and verified. The hosted viewer remains 0.1.217;
no viewer release was made. See `web-client/release/engine-package.json` and the
[revision-2 delivery receipt](../web-client/docs/achievements-0.4.151-receipt.md).
The [revision-1 receipt](../web-client/docs/achievements-0.4.150-receipt.md)
records the previously delivered 0.4.150 artifact.
Release **viewer 0.1.223 / engine 0.4.156** publishes catalog revision **4**
with **42 definitions**. The previous live catalog was revision 3 (41 definitions),
verified before this release. Artwork remains the existing 41 named achievement
images; Five Objectives shares the Three Objectives image without changing bytes.
Historical delivery receipts remain in `web-client/docs/achievements-*-receipt.md`.
The native Rust evaluator is the single source of truth. The WASM package exports
`achievementDefinitions()` and `achievements(serializedData)` directly, alongside
@ -14,7 +12,32 @@ its existing engine hooks. The web-client tests check the generated API against
`@boardgamers/protocol` **0.11.0** types and runtime schemas; there is no separate
JavaScript scoring implementation.
## Revision 2 catalog — 41 definitions
## Revision 4 — 42 definitions
Adds **Five Objectives** (`five-objectives`): “Complete 5 objectives in a single
game.” The condition is `completed_objectives.len() >= 5` in one eligible finished
save, additive to the existing three-objective tier and independent of winning.
The engine records one completed objective when its card is completed and discarded;
it does not count both printed options, cards in hand, objective opportunities,
objective victory points, or lifetime totals. Instant and status-phase completions
feed the same list; platform clock modes do not change this evaluator.
Reuses `achievement-three-objectives` as objective-category artwork (the existing
three-tablet image), with no new named asset or upload. The faction artwork manifest only refreshes
its package-lock integrity hash for the wrapper version bump.
Revision-2 faction and revision-3 nonfaction artwork inventories remain intact;
multiple definitions may reference the same asset. Achievement metadata is excluded
from viewer localization extraction, so no changes to the 17 viewer locales are
needed. All prior definitions, award conditions and eligibility gates are unchanged.
The matching engine upload activates the installer-owned achievement manifest;
a generic metadata PUT cannot set it. Release verification must confirm revision 4
and the exact 42-definition catalog through both authenticated and public GETs,
not merely confirm that the engine archive uploaded. Existing 41 entries must
remain identical. Publication uses the normal viewer/engine publisher after source
push and green CI. No historical backfill or live-game edits are performed; the
platform captures achievements on future natural eligible completions.
## Previously delivered revision 2 catalog — 41 definitions
Revision 2 removes `four-cities` and replaces it with a distinct `seven-cities` ID.
There is no migration, historical backfill, or repurposing of the old ID.

View file

@ -79,7 +79,7 @@ const WONDERS: [(Wonder, &str, &str); 8] = [
(Wonder::GreatStatue, "built-great-statue", "Great Statue"),
(Wonder::GreatWall, "built-great-wall", "Great Wall"),
];
const FEATS: [(&str, &str, &str); 7] = [
const FEATS: [(&str, &str, &str); 8] = [
(
"score-30",
"30 Points",
@ -105,6 +105,11 @@ const FEATS: [(&str, &str, &str); 7] = [
"Three Objectives",
"Finish a game with at least 3 completed objectives in the final state.",
),
(
"five-objectives",
"Five Objectives",
"Complete 5 objectives in a single game.",
),
(
"two-wonders-built",
"Two Wonders Built",
@ -120,7 +125,7 @@ const FEATS: [(&str, &str, &str); 7] = [
/// The stable achievement catalogue. Array order also defines award order.
#[must_use]
pub fn definitions() -> Manifest {
let mut definitions = Vec::with_capacity(41);
let mut definitions = Vec::with_capacity(42);
for (_, id, name) in LENGTHS {
definitions.push(Definition {
id: format!("complete-{id}"),
@ -142,7 +147,15 @@ pub fn definitions() -> Manifest {
name: name.into(),
description: description.into(),
icon: Some(Icon::Asset {
key: format!("achievement-{id}"),
// Reuse the existing objective-category artwork; no new asset upload.
key: format!(
"achievement-{}",
if id == "five-objectives" {
"three-objectives"
} else {
id
}
),
}),
}));
definitions.extend(WONDERS.map(|(_, id, name)| Definition {
@ -166,7 +179,7 @@ pub fn definitions() -> Manifest {
icon: Some(Icon::Asset { key: format!("achievement-faction-{slug}") }),
}));
Manifest {
revision: 3,
revision: 4,
achievements: definitions,
}
}
@ -206,6 +219,7 @@ pub fn achievements(game: &Game) -> Vec<SeatAchievements> {
p.cities.len() >= 7,
p.advances.len() >= 20,
p.completed_objectives.len() >= 3,
p.completed_objectives.len() >= 5,
p.wonders_built.len() >= 2,
!p.captured_leaders.is_empty(),
];
@ -319,8 +333,8 @@ mod tests {
#[test]
fn manifest_and_real_end_turn_for_all_lengths() {
let manifest = definitions();
assert_eq!(manifest.revision, 3);
assert_eq!(manifest.achievements.len(), 41);
assert_eq!(manifest.revision, 4);
assert_eq!(manifest.achievements.len(), 42);
assert_eq!(
manifest
.achievements
@ -328,7 +342,7 @@ mod tests {
.map(|d| &d.id)
.collect::<HashSet<_>>()
.len(),
41
42
);
assert!(
manifest
@ -433,6 +447,55 @@ mod tests {
}
}
#[test]
fn five_objectives_counts_completed_records_in_one_eligible_game() {
let definition = definitions()
.achievements
.into_iter()
.find(|d| d.id == "five-objectives")
.unwrap();
assert_eq!(definition.name, "Five Objectives");
assert_eq!(
definition.description,
"Complete 5 objectives in a single game."
);
for (length, _, _) in LENGTHS {
for variant in [GameVariant::Standard, GameVariant::Builder] {
for count in [4, 5, 6] {
let mut game = setup_variant(length.clone(), variant.clone());
game.player_mut(0).completed_objectives = (0..count)
.map(|card| CompletedObjective {
card,
name: format!("test {card}"),
})
.collect();
// A high score is not a substitute for completed records.
set_score(&mut game, 0, 40.0);
set_score(&mut game, 1, 100.0);
assert!(achievements(&game).is_empty());
let mut game = finish(game);
assert_eq!(achievements(&game)[0].outcome, "loss");
assert_eq!(has(&game, 0, "five-objectives"), count >= 5);
assert!(has(&game, 0, "three-objectives"));
assert!(!has(&game, 1, "five-objectives"));
let before = serde_json::to_value(game.cloned_data()).unwrap();
let restored = Game::from_data(
serde_json::from_value(before.clone()).unwrap(),
game.cache.clone(),
GameContext::Play,
);
assert_eq!(achievements(&game), achievements(&restored));
assert_eq!(before, serde_json::to_value(game.cloned_data()).unwrap());
game.secrets_stripped = true;
assert!(achievements(&game).is_empty());
game.secrets_stripped = false;
game.dropped_players.push(0);
assert!(!has(&game, 0, "five-objectives"));
}
}
}
}
#[test]
fn faction_catalog_matches_every_playable_civilization_and_wire_shape() {
let playable: HashSet<_> = crate::content::civilizations::get_all_uncached()
@ -445,10 +508,10 @@ mod tests {
FACTIONS.iter().map(|(name, _)| (*name).into()).collect()
);
let manifest = serde_json::to_value(definitions()).unwrap();
assert_eq!(manifest["revision"], 3);
assert_eq!(manifest["revision"], 4);
assert_eq!(manifest.as_object().unwrap().len(), 2);
let entries = manifest["achievements"].as_array().unwrap();
assert_eq!(entries.len(), 41);
assert_eq!(entries.len(), 42);
for entry in entries {
let faction = FACTIONS
.iter()
@ -466,7 +529,14 @@ mod tests {
} else {
assert_eq!(
entry["icon"]["key"],
format!("achievement-{}", entry["id"].as_str().unwrap())
format!(
"achievement-{}",
if entry["id"] == "five-objectives" {
"three-objectives"
} else {
entry["id"].as_str().unwrap()
}
)
);
assert_eq!(entry.as_object().unwrap().len(), 4);
}

View file

@ -1566,3 +1566,19 @@ four localization-source tests passed. Svelte reports zero errors/warnings;
both 17-language catalogs validate. Rust 1.94.1 Clippy completes with existing
warnings. Six actual-engine preparation tests also run against the extracted
release tarball. No production publication is implied by these local results.
# Viewer 0.1.223 / engine 0.4.156
Adds Five Objectives (`five-objectives`): complete at least five objective records
in one eligible finished authoritative game, regardless of winning. Cards in hand
and objective victory points do not count. Catalog revision 4 has 42 definitions;
the existing 41 definitions and all eligibility/privacy rules are unchanged.
Reuses the existing `achievement-three-objectives` named artwork without upload.
Publish the matching tested engine and viewer together. The supported engine POST
activates the installer-owned achievement metadata (generic metadata PUTs strip
`achievementManifest`). Verify the public and admin revision-4 catalog against the
packaged engine, including every old definition and the shared asset URL/bytes.
Gallery, options (including Standard length), settings and unrelated metadata must
remain unchanged. No backfill or live-game mutation is part of this release.

View file

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

View file

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

View file

@ -13,7 +13,7 @@
"web-client/src/civilization-emblems.ts": "01b0cbf3fa77a8466532ccd73d63c1a3ddc9bbc79fc06ce7224b425322a9c9f0",
"web-client/src/civilization-flags.ts": "cd176076bfe05b3059093b80c88596b7ae46b77898695c6c7406cbe1a3a0f78b",
"server/src/content/civilizations.rs": "73602f3db506f3dc2dbc6de43d01179440fd3bb034c997ff209336faaef2a332",
"web-client/package-lock.json": "fdd8822dddd32f6cead371a15091c6c5394cb6687a380ac4d17a3fceb4798bf0",
"web-client/package-lock.json": "dd6f525866176b7264fcf813b41f824b290961b5eda28a5e0d1a52d7e745ceb3",
"web-client/node_modules/lucide-svelte/dist/Icon.svelte": "f7b49ab842c143fa680fa8bd9a54a9efdc48c2e2d49fa574bd5ccf8f6cfca5be",
"web-client/node_modules/lucide-svelte/dist/defaultAttributes.js": "5b8981c6e3434ae6538716af9e0403554e7708c4087f18d060950a7bef00d96a",
"web-client/node_modules/lucide-svelte/LICENSE": "668dcc52803480e0a026b31140a4cae668772663cd764e5991d252eef03f98db"

View file

@ -1,6 +1,6 @@
{
"name": "@boardgamers/clash-server",
"version": "0.4.155",
"version": "0.4.156",
"description": "Clash of Cultures: Monumental edition engine for Boardgamers Space",
"license": "MIT",
"type": "commonjs",

View file

@ -10,15 +10,27 @@ import { inspectEngine } from '@boardgamers/protocol/engine';
import { ids } from './nonfaction-art.mjs';
import { validateOutputs, outputDir } from './nonfaction-assets.mjs';
import { root } from './achievement-asset-inputs.mjs';
const baseline = '0099fa11cd697080bc8dccda629d8d4f5c92aae5';
test('evaluation body and existing faction manifest remain byte identical', async () => {
// Last source release before the additive five-objective tier.
const baseline = 'e69d7148fb38775898389a1a5eef458993d540b1';
test('existing evaluation and faction assets are unchanged apart from the new objective tier', async () => {
const file = 'server/src/achievements.rs';
const old = execFileSync('git', ['show', `${baseline}:${file}`], { cwd: root, encoding: 'utf8' });
const current = await readFile(path.join(root, file), 'utf8');
const body = (s) => s.split('pub fn achievements(game: &Game)')[1].split('#[cfg(test)]')[0];
assert.equal(body(current), body(old));
// The sole evaluator change is the inclusive five-record objective predicate.
const addedPredicate = ' p.completed_objectives.len() >= 5,\n';
assert.equal(body(current).split(addedPredicate).length, 2);
assert.equal(body(current).replace(addedPredicate, ''), body(old));
const artworkFile = 'web-client/release/achievement-assets.json';
const previousArtwork = JSON.parse(
execFileSync('git', ['show', `${baseline}:${artworkFile}`], { cwd: root, encoding: 'utf8' }),
);
const currentArtwork = JSON.parse(await readFile(path.join(root, artworkFile), 'utf8'));
// Only the wrapper-version lockfile integrity pin changes; artwork is identical.
previousArtwork.integrity['web-client/package-lock.json'] =
currentArtwork.integrity['web-client/package-lock.json'];
assert.deepEqual(currentArtwork, previousArtwork);
for (const file of [
'web-client/release/achievement-assets.json',
'web-client/scripts/publish-achievement-assets.mjs',
'web-client/scripts/achievement-asset-inputs.mjs',
])
@ -27,30 +39,36 @@ test('evaluation body and existing faction manifest remain byte identical', asyn
execFileSync('git', ['show', `${baseline}:${file}`], { cwd: root, encoding: 'utf8' }),
);
});
test('exact packed engine schema, complete stable catalogue and 26 asset refs', async () => {
test('exact packed engine schema, 42 definitions sharing 41 existing assets', async () => {
const dir = await mkdtemp(path.join(tmpdir(), 'clash-packed-'));
const metadata = JSON.parse(await readFile(path.join(root, 'web-client/release/engine-package.json')));
execFileSync('tar', [
'xzf',
path.join(root, 'web-client/.engine/releases/boardgamers-clash-server-0.4.152.tgz'),
path.join(root, `web-client/.engine/releases/boardgamers-clash-server-${metadata.version}.tgz`),
'-C',
dir,
]);
const engine = createRequire(import.meta.url)(path.join(dir, 'package/server.js'));
assert.ok(inspectEngine(engine).compatible);
const m = engine.achievementDefinitions();
assert.equal(m.revision, 3);
assert.equal(m.achievements.length, 41);
assert.equal(m.revision, 4);
assert.equal(m.achievements.length, 42);
const factions = JSON.parse(
await readFile(path.join(root, 'web-client/release/achievement-assets.json')),
).assets;
assert.deepEqual(
m.achievements.map((a) => a.id),
m.achievements.filter((a) => a.id !== 'five-objectives').map((a) => a.id),
[...ids, ...factions.map((a) => 'win-' + a.key.slice('achievement-faction-'.length))],
);
for (const a of m.achievements)
assert.deepEqual(a.icon, {
type: 'asset',
key: ids.includes(a.id) ? `achievement-${a.id}` : `achievement-faction-${a.id.slice(4)}`,
key:
a.id === 'five-objectives'
? 'achievement-three-objectives'
: ids.includes(a.id)
? `achievement-${a.id}`
: `achievement-faction-${a.id.slice(4)}`,
});
const raw = await engine.init(2, [], {}, 'artwork-package-test', {});
assert.deepEqual(engine.achievements(raw), []);

View file

@ -7,7 +7,9 @@ import { achievementManifestSchema, achievementResultsSchema } from '@boardgamer
const require = createRequire(import.meta.url);
// Check the generated WASM API, not a parallel JS achievement implementation.
const engine: typeof import('../.bridge/server.js') = require('../.engine/server.js');
const engine: typeof import('../.bridge/server.js') = require(
process.env.CLASH_TEST_ENGINE ?? '../.engine/server.js',
);
const hooks = {
achievementDefinitions: (): AchievementManifest => engine.achievementDefinitions(),
achievements: (data: string): SeatAchievements[] => engine.achievements(data),
@ -20,8 +22,8 @@ const finish = () => engine.tryMove(fixture, JSON.stringify({ Playing: 'EndTurn'
test('WASM achievement catalog follows official protocol 0.11.0', () => {
const manifest = achievementManifestSchema.parse(hooks.achievementDefinitions());
assert.equal(manifest.revision, 3);
assert.equal(manifest.achievements.length, 41);
assert.equal(manifest.revision, 4);
assert.equal(manifest.achievements.length, 42);
assert.ok(!manifest.achievements.some((a) => a.id === 'four-cities'));
assert.ok(manifest.achievements.some((a) => a.id === 'seven-cities'));
assert.ok(manifest.achievements.some((a) => a.id === 'complete-builder'));
@ -35,13 +37,16 @@ test('WASM achievement catalog follows official protocol 0.11.0', () => {
const nonfactionArt = JSON.parse(
readFileSync(new URL('../release/achievement-assets-nonfaction.json', import.meta.url), 'utf8'),
);
assert.equal(nonfactionArt.revision, manifest.revision);
assert.equal(art.revision, 2, 'revision 3 preserves the existing faction artwork');
assert.equal(nonfactionArt.revision, 3, 'revision 4 reuses the existing objective artwork');
assert.equal(art.revision, 2, 'revision 4 preserves the existing faction artwork');
assert.deepEqual(
manifest.achievements
.filter((a) => a.icon?.type === 'asset')
.map((a) => (a.icon!.type === 'asset' ? a.icon!.key : ''))
.sort(),
[
...new Set(
manifest.achievements
.filter((a) => a.icon?.type === 'asset')
.map((a) => (a.icon!.type === 'asset' ? a.icon!.key : '')),
),
].sort(),
[...art.assets, ...nonfactionArt.assets].map((a: { key: string }) => a.key).sort(),
);
for (const length of ['shorter', 'standard', 'roll-to-end', 'wonderful-ending', 'epic']) {
@ -286,3 +291,40 @@ test('filtered snapshots and all-withdrawn completions cannot award achievements
dropped.dropped_players = [0, 1];
assert.deepEqual(hooks.achievements(JSON.stringify(dropped)), []);
});
test('five objectives uses completed records, with inclusive boundaries and unchanged eligibility', () => {
const manifest = hooks.achievementDefinitions();
assert.deepEqual(
manifest.achievements.find((a) => a.id === 'five-objectives'),
{
id: 'five-objectives',
name: 'Five Objectives',
description: 'Complete 5 objectives in a single game.',
icon: { type: 'asset', key: 'achievement-three-objectives' },
},
);
for (const count of [4, 5, 6]) {
const data = JSON.parse(finish());
data.players[0].completed_objectives = Array.from({ length: count }, (_, card) => ({
card,
name: `test ${card}`,
}));
data.players[1].completed_objectives = [];
data.players[1].special_victory_points = [
{ points: 100, origin: { Ability: 'objective fixture' }, attribution: 'Events' },
];
const raw = JSON.stringify(data);
const results = achievementResultsSchema(manifest, 2).parse(hooks.achievements(raw));
assert.equal(results[0].outcome, 'loss');
assert.equal(results[0].earned.includes('five-objectives'), count >= 5);
assert.ok(results[0].earned.includes('three-objectives'));
assert.ok(!results[1].earned.includes('five-objectives'));
assert.deepEqual(hooks.achievements(raw), results);
assert.deepEqual(hooks.achievements(engine.stripSecret(raw, 0)), []);
data.dropped_players = [0];
assert.ok(hooks.achievements(JSON.stringify(data)).every((r) => r.seat !== 0));
data.dropped_players = [];
data.state = 'Playing';
assert.deepEqual(hooks.achievements(JSON.stringify(data)), []);
}
});