diff --git a/docs/achievements.md b/docs/achievements.md index b7c12678..6253240b 100644 --- a/docs/achievements.md +++ b/docs/achievements.md @@ -1,6 +1,6 @@ # Clash of Cultures achievements -Release **viewer 0.1.223 / engine 0.4.156** publishes catalog revision **4** +Previously delivered **viewer 0.1.223 / engine 0.4.156** published 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. @@ -12,6 +12,39 @@ 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. +## Viewer 0.1.224 / engine 0.4.157 — revision 5, 45 definitions + +Adds three independent, inclusive final-state milestones: + +| Name | ID | Condition | Reused asset key | +| --- | --- | --- | --- | +| 60 Points | `score-60` | `player.victory_points(game) >= 60` | `achievement-score-40` | +| Seven Objectives | `seven-objectives` | `completed_objectives.len() >= 7` | `achievement-three-objectives` | +| Thirty Advances | `thirty-advances` | `advances.len() >= 30` | `achievement-twenty-advances` | + +The score is the canonical total VP, including city pieces, regular and special +advances, completed objectives and objective bonus VP, wonders, event VP and +captured leaders (and the engine's applicable scoring adjustments). It is not a +resource count. Objectives use the same completed-record list as the three- and +five-objective tiers: instant and status-phase completions count alike; held cards, +printed options, bonus VP and lifetime totals do not. Advances follow the existing +Twenty Advances tier: regular advances currently in the set, regardless of how +acquired, excluding civilization special advances (including automatically unlocked +ones). The prior catalog has no 50-point or 25-advance tier. + +All three require an authoritative `Finished` save and an eligible non-dropped human +civilization seat, but not a win. Existing platform eligibility responsibilities +still apply. The previous 42 definitions and their conditions are unchanged. +There are still 41 unique achievement asset keys (58 named artwork assets overall); +no artwork bytes, assets or localization metadata change. The wrapper versions and +artwork package-lock integrity hash are updated for the matching release. +Publish only after matching main-branch Check and Web viewer CI pass, using the +frozen tested engine/viewer. The asynchronous engine installer owns activation: +verify public and admin revision 5 with exactly 45 definitions before reporting +completion, including equality of the previous 42 definitions and all 58 named +asset bytes. No historical backfill or live-game mutation is performed; awards +apply to future natural eligible completions. Generated artifacts remain ignored. + ## Revision 4 — 42 definitions Adds **Five Objectives** (`five-objectives`): “Complete 5 objectives in a single diff --git a/server/src/achievements.rs b/server/src/achievements.rs index dcbedbd5..fa64b4bd 100644 --- a/server/src/achievements.rs +++ b/server/src/achievements.rs @@ -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); 8] = [ +const FEATS: [(&str, &str, &str); 11] = [ ( "score-30", "30 Points", @@ -120,12 +120,27 @@ const FEATS: [(&str, &str, &str); 8] = [ "Captured Leader", "Finish a game with at least 1 captured leader in the final state.", ), + ( + "score-60", + "60 Points", + "Finish a game with at least 60 victory points in the final state.", + ), + ( + "seven-objectives", + "Seven Objectives", + "Finish a game with at least 7 completed objectives in the final state.", + ), + ( + "thirty-advances", + "Thirty Advances", + "Finish a game with at least 30 regular advances in the final state; special advances do not count.", + ), ]; /// The stable achievement catalogue. Array order also defines award order. #[must_use] pub fn definitions() -> Manifest { - let mut definitions = Vec::with_capacity(42); + let mut definitions = Vec::with_capacity(45); for (_, id, name) in LENGTHS { definitions.push(Definition { id: format!("complete-{id}"), @@ -147,13 +162,14 @@ pub fn definitions() -> Manifest { name: name.into(), description: description.into(), icon: Some(Icon::Asset { - // Reuse the existing objective-category artwork; no new asset upload. + // Reuse existing category artwork; no new assets or uploads. key: format!( "achievement-{}", - if id == "five-objectives" { - "three-objectives" - } else { - id + match id { + "five-objectives" | "seven-objectives" => "three-objectives", + "score-60" => "score-40", + "thirty-advances" => "twenty-advances", + _ => id, } ), }), @@ -179,7 +195,7 @@ pub fn definitions() -> Manifest { icon: Some(Icon::Asset { key: format!("achievement-faction-{slug}") }), })); Manifest { - revision: 4, + revision: 5, achievements: definitions, } } @@ -222,6 +238,9 @@ pub fn achievements(game: &Game) -> Vec { p.completed_objectives.len() >= 5, p.wonders_built.len() >= 2, !p.captured_leaders.is_empty(), + score >= 60.0, + p.completed_objectives.len() >= 7, + p.advances.len() >= 30, ]; for ((id, _, _), met) in FEATS.iter().zip(predicates) { if met { @@ -333,8 +352,8 @@ mod tests { #[test] fn manifest_and_real_end_turn_for_all_lengths() { let manifest = definitions(); - assert_eq!(manifest.revision, 4); - assert_eq!(manifest.achievements.len(), 42); + assert_eq!(manifest.revision, 5); + assert_eq!(manifest.achievements.len(), 45); assert_eq!( manifest .achievements @@ -342,7 +361,7 @@ mod tests { .map(|d| &d.id) .collect::>() .len(), - 42 + 45 ); assert!( manifest @@ -496,6 +515,89 @@ mod tests { } } + #[test] + fn seven_objectives_combines_instant_and_status_phase_records() { + let instant: crate::game_data::GameData = serde_json::from_str(include_str!( + "../tests/test_games/objective_cards/instant/warmonger.outcome4.json" + )) + .unwrap(); + let status: crate::game_data::GameData = serde_json::from_str(include_str!( + "../tests/test_games/objective_cards/status_phase/large_civ.outcome8.json" + )) + .unwrap(); + let instant_cache = crate::cache::Cache::new(&instant.options); + let instant = Game::from_data(instant, instant_cache, GameContext::Play); + let status_cache = crate::cache::Cache::new(&status.options); + let status = Game::from_data(status, status_cache, GameContext::Play); + let mut game = finish(setup(GameLength::Standard)); + game.player_mut(0).completed_objectives = + status.players[0].completed_objectives[..6].to_vec(); + assert!(!has(&game, 0, "seven-objectives")); + game.player_mut(0) + .completed_objectives + .extend(instant.players[0].completed_objectives.clone()); + assert_eq!(game.player(0).completed_objectives.len(), 7); + assert!(has(&game, 0, "seven-objectives")); + } + + #[test] + fn revision_five_thresholds_and_eligibility() { + for (length, _, _) in LENGTHS { + for variant in [GameVariant::Standard, GameVariant::Builder] { + for offset in 0..3 { + let mut game = finish(setup_variant(length.clone(), variant.clone())); + let p = game.player_mut(0); + p.advances = EnumSet::::all().iter().take(29 + offset).collect(); + p.special_advances.insert(SpecialAdvance::Aqueduct); + p.completed_objectives = (0..6 + offset) + .map(|i| CompletedObjective { + card: i as u8, + name: format!("test {i}"), + }) + .collect(); + // Held cards and bonus objective VP are not completed records. + p.objective_cards = vec![1, 2, 3]; + p.special_victory_points.push(SpecialVictoryPoints::new( + 10.0, + EventOrigin::Ability("objective bonus".into()), + VictoryPointAttribution::Objectives, + )); + // Loading derives civilization special advances from regular advances. + // Normalize the fixture before targeting canonical total VP. + let mut game = + Game::from_data(game.cloned_data(), game.cache.clone(), GameContext::Play); + assert!(!game.player(0).special_advances.is_empty()); + let score = [59.5, 60.0, 60.5][offset]; + set_score(&mut game, 0, score); + set_score(&mut game, 1, 100.0); + assert_eq!(game.player(0).victory_points(&game), score); + assert_eq!(achievements(&game)[0].outcome, "loss"); + for id in ["score-60", "seven-objectives", "thirty-advances"] { + assert_eq!(has(&game, 0, id), offset >= 1, "{id}"); + } + assert!(!has(&game, 1, "seven-objectives")); + assert!(!has(&game, 1, "thirty-advances")); + 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!(achievements(&game).iter().all(|r| r.seat != 0)); + game.dropped_players.clear(); + game.state = GameState::Playing; + assert!(achievements(&game).is_empty()); + } + } + } + } + #[test] fn faction_catalog_matches_every_playable_civilization_and_wire_shape() { let playable: HashSet<_> = crate::content::civilizations::get_all_uncached() @@ -508,10 +610,10 @@ mod tests { FACTIONS.iter().map(|(name, _)| (*name).into()).collect() ); let manifest = serde_json::to_value(definitions()).unwrap(); - assert_eq!(manifest["revision"], 4); + assert_eq!(manifest["revision"], 5); assert_eq!(manifest.as_object().unwrap().len(), 2); let entries = manifest["achievements"].as_array().unwrap(); - assert_eq!(entries.len(), 42); + assert_eq!(entries.len(), 45); for entry in entries { let faction = FACTIONS .iter() @@ -531,10 +633,11 @@ mod tests { entry["icon"]["key"], format!( "achievement-{}", - if entry["id"] == "five-objectives" { - "three-objectives" - } else { - entry["id"].as_str().unwrap() + match entry["id"].as_str().unwrap() { + "five-objectives" | "seven-objectives" => "three-objectives", + "score-60" => "score-40", + "thirty-advances" => "twenty-advances", + id => id, } ) ); diff --git a/web-client/docs/viewer-publishing.md b/web-client/docs/viewer-publishing.md index b66ad074..90d97789 100644 --- a/web-client/docs/viewer-publishing.md +++ b/web-client/docs/viewer-publishing.md @@ -1582,3 +1582,22 @@ activates the installer-owned achievement metadata (generic metadata PUTs strip 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. + +# Viewer 0.1.224 / engine 0.4.157 + +Adds 60 Points (`score-60`), Seven Objectives (`seven-objectives`) and Thirty +Advances (`thirty-advances`) to catalog revision 5 (45 definitions). Inclusive +thresholds use canonical final VP, completed-objective records and regular +advances, respectively. Eligible authoritative finished non-dropped human seats +qualify regardless of winning; held objectives, objective bonus VP and civilization +special advances do not count toward their respective record/advance thresholds. +The previous 42 definitions remain unchanged. All three reuse existing named +category artwork, with no artwork upload or changed bytes. + +Publish the matching frozen engine and viewer only after main-branch Check and +Web viewer pass. Wait for installer-owned activation and verify public/admin +revision 5 with exactly 45 definitions; an accepted upload alone is not activation. +Independently download and compare every viewer asset, engine archive and all 58 +existing named assets. Preserve real-game gallery, game-length labels/order and +Standard default, plus all unrelated metadata. No historical award backfill, +live-game moves, history repair or Fossil refresh is included. diff --git a/web-client/package-lock.json b/web-client/package-lock.json index 61e917ce..ea0a569f 100644 --- a/web-client/package-lock.json +++ b/web-client/package-lock.json @@ -1,12 +1,12 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.223", + "version": "0.1.224", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@boardgamers/clash-web-client", - "version": "0.1.223", + "version": "0.1.224", "dependencies": { "@boardgamers/protocol": "0.11.0", "lucide-svelte": "^0.577.0", diff --git a/web-client/package.json b/web-client/package.json index 113cc3ad..88f1cde1 100644 --- a/web-client/package.json +++ b/web-client/package.json @@ -1,6 +1,6 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.223", + "version": "0.1.224", "private": true, "type": "module", "scripts": { diff --git a/web-client/release/achievement-assets.json b/web-client/release/achievement-assets.json index c08e36ff..8785fb90 100644 --- a/web-client/release/achievement-assets.json +++ b/web-client/release/achievement-assets.json @@ -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": "dd6f525866176b7264fcf813b41f824b290961b5eda28a5e0d1a52d7e745ceb3", + "web-client/package-lock.json": "e4f33a57d5e2b65923711e1c11de61261c4d7b62e3f5344322cf8116d675de70", "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" diff --git a/web-client/release/engine-package.json b/web-client/release/engine-package.json index b2bec45b..61bf1a3c 100644 --- a/web-client/release/engine-package.json +++ b/web-client/release/engine-package.json @@ -1,6 +1,6 @@ { "name": "@boardgamers/clash-server", - "version": "0.4.156", + "version": "0.4.157", "description": "Clash of Cultures: Monumental edition engine for Boardgamers Space", "license": "MIT", "type": "commonjs", diff --git a/web-client/scripts/nonfaction-assets.test.mjs b/web-client/scripts/nonfaction-assets.test.mjs index 6c21ff48..d3bb0130 100644 --- a/web-client/scripts/nonfaction-assets.test.mjs +++ b/web-client/scripts/nonfaction-assets.test.mjs @@ -1,8 +1,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; -import { readFile, mkdtemp } from 'node:fs/promises'; -import { tmpdir } from 'node:os'; +import { readFile } from 'node:fs/promises'; import path from 'node:path'; import { createRequire } from 'node:module'; import { chromium } from 'playwright'; @@ -10,17 +9,24 @@ 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'; -// 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 () => { +// Last source release before the three additive revision-5 milestones. +const baseline = '59fd2671380391889d1dff0e0f15db16fdc215ff'; +test('existing evaluation and faction assets are unchanged apart from the three new milestones', 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]; - // 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)); + // Only these three inclusive predicates may change evaluation. + let evaluator = body(current); + for (const predicate of [ + ' score >= 60.0,\n', + ' p.completed_objectives.len() >= 7,\n', + ' p.advances.len() >= 30,\n', + ]) { + assert.equal(evaluator.split(predicate).length, 2); + evaluator = evaluator.replace(predicate, ''); + } + assert.equal(evaluator, body(old)); const artworkFile = 'web-client/release/achievement-assets.json'; const previousArtwork = JSON.parse( execFileSync('git', ['show', `${baseline}:${artworkFile}`], { cwd: root, encoding: 'utf8' }), @@ -31,6 +37,7 @@ test('existing evaluation and faction assets are unchanged apart from the new ob currentArtwork.integrity['web-client/package-lock.json']; assert.deepEqual(currentArtwork, previousArtwork); for (const file of [ + 'web-client/release/achievement-assets-nonfaction.json', 'web-client/scripts/publish-achievement-assets.mjs', 'web-client/scripts/achievement-asset-inputs.mjs', ]) @@ -39,36 +46,35 @@ test('existing evaluation and faction assets are unchanged apart from the new ob execFileSync('git', ['show', `${baseline}:${file}`], { cwd: root, encoding: 'utf8' }), ); }); -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-${metadata.version}.tgz`), - '-C', - dir, - ]); - const engine = createRequire(import.meta.url)(path.join(dir, 'package/server.js')); +test('generated engine schema, 45 definitions sharing 41 existing assets', async () => { + // Test current local WASM, not a stale published archive; an explicit packed + // engine can still be supplied during a future release verification. + const engine = createRequire(import.meta.url)(process.env.CLASH_TEST_ENGINE ?? '../.engine/server.js'); assert.ok(inspectEngine(engine).compatible); const m = engine.achievementDefinitions(); - assert.equal(m.revision, 4); - assert.equal(m.achievements.length, 42); + assert.equal(m.revision, 5); + assert.equal(m.achievements.length, 45); const factions = JSON.parse( await readFile(path.join(root, 'web-client/release/achievement-assets.json')), ).assets; + const reused = { + 'five-objectives': 'three-objectives', + 'score-60': 'score-40', + 'seven-objectives': 'three-objectives', + 'thirty-advances': 'twenty-advances', + }; assert.deepEqual( - m.achievements.filter((a) => a.id !== 'five-objectives').map((a) => a.id), + m.achievements.filter((a) => !Object.hasOwn(reused, a.id)).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: - a.id === 'five-objectives' - ? 'achievement-three-objectives' - : ids.includes(a.id) - ? `achievement-${a.id}` - : `achievement-faction-${a.id.slice(4)}`, + key: Object.hasOwn(reused, a.id) + ? `achievement-${reused[a.id]}` + : 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), []); diff --git a/web-client/src/achievements.test.ts b/web-client/src/achievements.test.ts index 39ec66f6..c3b9a02e 100644 --- a/web-client/src/achievements.test.ts +++ b/web-client/src/achievements.test.ts @@ -22,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, 4); - assert.equal(manifest.achievements.length, 42); + assert.equal(manifest.revision, 5); + assert.equal(manifest.achievements.length, 45); 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')); @@ -37,8 +37,8 @@ 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, 3, 'revision 4 reuses the existing objective artwork'); - assert.equal(art.revision, 2, 'revision 4 preserves the existing faction artwork'); + assert.equal(nonfactionArt.revision, 3, 'revision 5 reuses the existing objective artwork'); + assert.equal(art.revision, 2, 'revision 5 preserves the existing faction artwork'); assert.deepEqual( [ ...new Set( @@ -328,3 +328,127 @@ test('five objectives uses completed records, with inclusive boundaries and unch assert.deepEqual(hooks.achievements(JSON.stringify(data)), []); } }); + +const regularAdvances = [ + 'Farming', + 'Storage', + 'Irrigation', + 'Husbandry', + 'Mining', + 'Engineering', + 'Sanitation', + 'Roads', + 'Fishing', + 'Navigation', + 'WarShips', + 'Cartography', + 'Writing', + 'PublicEducation', + 'FreeEducation', + 'Philosophy', + 'Tactics', + 'Siegecraft', + 'SteelWeapons', + 'Draft', + 'Myths', + 'Rituals', + 'Priesthood', + 'StateReligion', + 'Bartering', + 'TradeRoutes', + 'Taxes', + 'Currency', + 'Arts', + 'Sports', + 'Monuments', +]; + +test('revision 5 milestones use inclusive canonical totals and unchanged eligibility', () => { + const manifest = hooks.achievementDefinitions(); + for (const [id, name, description, key] of [ + [ + 'score-60', + '60 Points', + 'Finish a game with at least 60 victory points in the final state.', + 'score-40', + ], + [ + 'seven-objectives', + 'Seven Objectives', + 'Finish a game with at least 7 completed objectives in the final state.', + 'three-objectives', + ], + [ + 'thirty-advances', + 'Thirty Advances', + 'Finish a game with at least 30 regular advances in the final state; special advances do not count.', + 'twenty-advances', + ], + ]) { + assert.deepEqual( + manifest.achievements.find((a) => a.id === id), + { + id, + name, + description, + icon: { type: 'asset', key: `achievement-${key}` }, + }, + ); + } + for (const offset of [0, 1, 2]) { + const data = JSON.parse(finish()); + const p = data.players[0]; + // Rome's special advances are derived on load, not counted as regular research. + p.civilization = 'Rome'; + p.advances = regularAdvances.slice(0, 29 + offset); + p.completed_objectives = Array.from({ length: 6 + offset }, (_, card) => ({ + card, + name: `test ${card}`, + })); + p.objective_cards = [1, 2, 3]; + p.special_victory_points = [ + { points: 10, origin: { Ability: 'objective bonus' }, attribution: 'Objectives' }, + ]; + data.players[1].completed_objectives = []; + const scores = engine.scores(JSON.stringify(data)) as number[]; + const target = [59, 60, 61][offset]; + for (const seat of [0, 1]) { + data.players[seat].special_victory_points ??= []; + data.players[seat].special_victory_points.push({ + points: (seat === 0 ? target : 100) - scores[seat], + origin: { Ability: 'revision 5 boundary' }, + attribution: 'Events', + }); + } + const raw = JSON.stringify(data); + assert.equal((engine.scores(raw) as number[])[0], target); + const results = achievementResultsSchema(manifest, 2).parse(hooks.achievements(raw)); + assert.equal(results[0].outcome, 'loss'); + for (const id of ['score-60', 'seven-objectives', 'thirty-advances']) + assert.equal(results[0].earned.includes(id), offset >= 1, id); + assert.ok(!results[1].earned.includes('seven-objectives')); + assert.ok(!results[1].earned.includes('thirty-advances')); + assert.deepEqual(hooks.achievements(JSON.stringify(JSON.parse(raw))), results); + assert.equal(JSON.stringify(data), raw); + for (const seat of [undefined, 0, 1]) + assert.deepEqual(hooks.achievements(engine.stripSecret(raw, seat)), []); + 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)), []); + } +}); + +test('seven objectives combines real instant and status-phase completion records', () => { + const completed = (path: string) => + JSON.parse( + readFileSync(new URL(`../../server/tests/test_games/objective_cards/${path}`, import.meta.url), 'utf8'), + ).players[0].completed_objectives; + const data = JSON.parse(finish()); + data.players[0].completed_objectives = completed('status_phase/large_civ.outcome8.json').slice(0, 6); + assert.ok(!hooks.achievements(JSON.stringify(data))[0].earned.includes('seven-objectives')); + data.players[0].completed_objectives.push(...completed('instant/warmonger.outcome4.json')); + assert.equal(data.players[0].completed_objectives.length, 7); + assert.ok(hooks.achievements(JSON.stringify(data))[0].earned.includes('seven-objectives')); +});