Expand map victories and raise fully supplied achievement threshold
This commit is contained in:
parent
eb08aaf26d
commit
2f89876e71
5 changed files with 226 additions and 49 deletions
|
|
@ -1,10 +1,12 @@
|
|||
# Power Grid achievements
|
||||
|
||||
Approved for engine **2.0.32** after independent review of `c8aae016`. No viewer or artwork changes are required. Publication verification is recorded in `docs/releases/achievements-2.0.32.json`.
|
||||
**Unpublished review candidate: engine 2.0.33, manifest revision 2, 36 achievements.** Adds 20 map victories (24 total) and raises Fully Supplied from a 10-city to a 15-city minimum, preserving its complete-network condition. The separate powered-city tiers remain 15 and 18. No viewer, artwork, map-cap, scoring, or backfill changes. Existing awards are not recalculated or revoked by this change.
|
||||
|
||||
The live 2.0.32 / revision-1 release remains documented in `docs/releases/achievements-2.0.32.json`. Do not publish this candidate until coordinator review.
|
||||
|
||||
## Contract
|
||||
|
||||
`engine/wrapper.ts` exports the optional `achievementDefinitions()` and `achievements(data)` hooks. Both use the published `@boardgamers/protocol@0.11.0` `/engine` types. The manifest has revision 1. IDs are stable game-local identifiers: do not rename or reuse them after publication. Future definition changes require a manifest revision bump. Icons are omitted, allowing platform fallback icons; no asset upload is needed.
|
||||
`engine/wrapper.ts` exports the optional `achievementDefinitions()` and `achievements(data)` hooks. Both use the published `@boardgamers/protocol@0.11.0` `/engine` types. The candidate manifest has revision 2. IDs are stable game-local identifiers: do not rename or reuse them after publication. Future definition changes require a manifest revision bump. Icons are omitted, allowing platform fallback icons; no asset upload is needed.
|
||||
|
||||
The input is the deserialized, authoritative saved `GameState`, not a viewer payload or client-supplied achievement claim. Evaluation is pure, repeatable, and does not store counters or mutate state. Results use player-array indexes as seats. The hook returns nothing for unfinished, tentative, analysis/simulation, or fewer-than-two-player states. Power Grid has no standalone solo rules; a human against bots competes normally and receives an explicit win/loss outcome.
|
||||
|
||||
|
|
@ -25,7 +27,7 @@ Winning follows the existing three tie breakers: powered cities, money, built ci
|
|||
| `japan-champion` | Japan Champion | Win on Japan. |
|
||||
| `power-fifteen` | Power Fifteen | Able to power at least 15 owned cities. |
|
||||
| `power-eighteen` | Power Eighteen | Able to power at least 18 owned cities. |
|
||||
| `fully-supplied` | Fully Supplied | Able to power every owned city, with at least 10 owned. |
|
||||
| `fully-supplied` | Fully Supplied | Able to power every owned city, with at least 15 owned. |
|
||||
| `network-seventeen` | Network Seventeen | Own at least 17 cities. |
|
||||
| `network-twenty` | Network Twenty | Own at least 20 cities. |
|
||||
| `cash-reserve` | Cash Reserve | At least 100 Elektro. |
|
||||
|
|
@ -35,13 +37,62 @@ Winning follows the existing three tie breakers: powered cities, money, built ci
|
|||
|
||||
`PowerPlantType.Nuclear` means fuel-free fusion in this engine and does not count as wind or uranium-fuelled capacity. On Australia, Uranium plants are mines, not generators. Conditions use types/output rather than card numbers so alternate and shuffled decks work too. Map feats use the resolved `data.map.name`, including games created with Random map selection.
|
||||
|
||||
### Complete map-win catalog
|
||||
|
||||
Each entry is **Win on the named map**, including shared first place, never mere participation. The 24-name set matches both runtime `maps` and `mapsRecharged`, including expansion maps. Existing Germany, USA, France and Japan IDs and descriptions are unchanged.
|
||||
|
||||
| Canonical map name | Stable achievement ID |
|
||||
| ------------------ | ---------------------------- |
|
||||
| USA | `usa-champion` |
|
||||
| Germany | `germany-champion` |
|
||||
| Brazil | `brazil-champion` |
|
||||
| Spain & Portugal | `spain-portugal-champion` |
|
||||
| France | `france-champion` |
|
||||
| India | `india-champion` |
|
||||
| Italy | `italy-champion` |
|
||||
| Quebec | `quebec-champion` |
|
||||
| Middle East | `middle-east-champion` |
|
||||
| China | `china-champion` |
|
||||
| Benelux | `benelux-champion` |
|
||||
| Russia | `russia-champion` |
|
||||
| Central Europe | `central-europe-champion` |
|
||||
| Baden-Württemberg | `baden-wurttemberg-champion` |
|
||||
| Northern Europe | `northern-europe-champion` |
|
||||
| Korea | `korea-champion` |
|
||||
| Europe | `europe-champion` |
|
||||
| North America | `north-america-champion` |
|
||||
| South Africa | `south-africa-champion` |
|
||||
| UK & Ireland | `uk-ireland-champion` |
|
||||
| Australia | `australia-champion` |
|
||||
| Bremen | `bremen-champion` |
|
||||
| Manhattan | `manhattan-champion` |
|
||||
| Japan | `japan-champion` |
|
||||
|
||||
Names are matched exactly against resolved `data.map.name`; `options.map` is not consulted. Random selection therefore earns the resolved map badge. Original and Recharged share an ID, as do deck/region variants on the same named map. USA is not an alias for North America. Internal module names such as `america`/`indian`, translations, accent-stripped names, and unsupported names are not accepted map aliases. Explicit ASCII IDs omit ampersands and transliterate ü to u, without runtime slug generation.
|
||||
|
||||
### Powered-city target rationale
|
||||
|
||||
Most maps end when a player builds 21/17/17/15/14 cities at 2/3/4/5/6 players, not when anyone powers that many. South Africa and Manhattan use 18 at two players. Bremen uses 13/13/13/12/11; its two-/three-player map has only 15 cities. UK & Ireland caps the two-player ending target to available map cities. Stalled games can end below these triggers. Legal building stops at 21 owned cities (`buildOptions`), despite the legacy `housesLeft: 22` initialization.
|
||||
|
||||
Thus the 15/18 powered ladder remains meaningful without a near-ceiling 20 target. Fully Supplied at 15 is stricter than Power Fifteen: all owned cities must be powerable. Some small maps cannot award the upper tier; the game/map limits remain untouched. Every powered predicate uses official fuel-constrained, network-capped final `citiesPowered`, not plant capacity.
|
||||
|
||||
## Server eligibility boundary
|
||||
|
||||
Power Grid state contains neither platform account identities nor cancellation metadata. The existing BGS achievement capture/adjudication path must remain enabled: it captures first natural completion only, rejects cancelled/claimed-win/edited-solo games, and excludes platform bot/dropped/quit seats before persisting human awards. In particular, BGS does **not** propagate `isBot` into Power Grid's `isAI`; `isAI === false` alone is not proof of a human account. Do not call these hooks directly to persist user awards outside that server path. Host-side evidence and award deduplication remain authoritative.
|
||||
|
||||
Analysis constructors and moves mark their copies with `achievementAnalysis: true`; full wrapper replay preserves this exclusion. Older analyses may not have the marker, so the host's analysis isolation is still required. Ordinary historical replay is a pure engine operation, not permission to backfill achievements.
|
||||
|
||||
## Review verification
|
||||
## Revision-2 review verification
|
||||
|
||||
- 150 achievement tests pass, including all 24 maps in both variants at two and six seats, winner/loser checks, runtime catalog parity, resolved-map handling, unsupported names, thresholds, eligibility, ties, and real replay fixtures.
|
||||
- Full suite: **725 passing** with `pnpm --filter powergrid-engine exec mocha -r ts-node/register 'src/*.spec.ts' --timeout 10000`. An archived unchanged `eb08aaf` baseline passes **625** with the same timeout. Both baseline and candidate hit existing 2-second replay timeouts under the default limit; the override is command-line only, with no skipped tests or assertion changes. An initial candidate run also hit the historically recorded China shuffled-deck analysis assertion; it did not recur in the comparison runs or targeted baseline test.
|
||||
- Engine build and published protocol schema validation pass. The compiled manifest is compared with the recorded revision-1 catalog: exactly 20 additions, with only Fully Supplied's approved description change among existing IDs.
|
||||
- 102 viewer unit tests pass. Engine lint passes with 0 errors and 41 warnings. Frozen installation, formatting, and whitespace checks pass.
|
||||
- Scoped read-only review found no concrete issues; final coordinator approval is still required before publication.
|
||||
|
||||
## Previous release verification (2.0.32)
|
||||
|
||||
The following results describe the shipped revision-1 release, not approval of revision 2.
|
||||
|
||||
- Full engine suite: **625 passing**, including **50 achievement tests**.
|
||||
- Engine build and published protocol 0.11.0 manifest/result schema validation: passed.
|
||||
|
|
@ -57,7 +108,7 @@ An earlier full engine run concurrent with builds hit two 2-second replay-test t
|
|||
|
||||
- Run `pnpm install --frozen-lockfile`, `pnpm --filter powergrid-engine test`, and `pnpm --filter powergrid-engine test:achievements` (builds and validates the compiled hooks with the published protocol's runtime schemas).
|
||||
- Engine TypeScript is pinned to the 4.9 minor line to resolve the protocol's CommonJS `.d.cts` declarations while retaining compatibility with the existing ESLint parser and Node type declarations. The legacy npm lockfile is already stale; pnpm and `engine/pnpm-lock.yaml` are authoritative.
|
||||
- Review all 16 IDs/descriptions, thresholds, tie semantics, and human-versus-bot policy with the coordinator.
|
||||
- Review all 36 IDs/descriptions, thresholds, tie semantics, and human-versus-bot policy with the coordinator.
|
||||
- Validate the compiled hooks against protocol manifest/result schemas and the actual BGS install/adjudication path before release, including cancellation, bot/account filtering, duplicate completion, and edited-solo exclusions. Unit tests cannot substitute for server-owned eligibility checks.
|
||||
- After approval, allocate an engine release version, fetch/integrate the latest canonical release, rerun relevant checks, and publish through the existing engine release workflow. Verify the installed artifact contains both hooks and the expected manifest revision. No artwork is required.
|
||||
- Only when authorized to publish: follow AGENTS.md's corresponding source/lockfile/version commit, canonical release-branch push, public mirror update, and remote-delivery verification requirements. The approved 2.0.32 delivery follows that workflow; consult its release receipt for the installed artifact and verification results.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "powergrid-engine",
|
||||
"version": "2.0.32",
|
||||
"version": "2.0.33",
|
||||
"description": "An engine for Power Grid",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.ts",
|
||||
|
|
|
|||
|
|
@ -7,8 +7,24 @@ import wrapper from '../dist/wrapper.js';
|
|||
// entry point, not local copies of the contract or TypeScript-only assertions.
|
||||
const manifest = wrapper.achievementDefinitions();
|
||||
achievementManifestSchema.parse(manifest);
|
||||
assert.equal(manifest.revision, 1);
|
||||
assert.equal(manifest.achievements.length, 16);
|
||||
assert.equal(manifest.revision, 2);
|
||||
assert.equal(manifest.achievements.length, 36);
|
||||
const previous = JSON.parse(
|
||||
readFileSync(new URL('../../docs/releases/achievements-2.0.32.json', import.meta.url), 'utf8')
|
||||
).achievementManifest;
|
||||
for (const definition of previous.achievements) {
|
||||
const next = manifest.achievements.find((entry) => entry.id === definition.id);
|
||||
assert.deepEqual(
|
||||
next,
|
||||
definition.id === 'fully-supplied'
|
||||
? { ...definition, description: 'Finish able to power every city in a network of at least 15 cities.' }
|
||||
: definition
|
||||
);
|
||||
}
|
||||
assert.equal(
|
||||
manifest.achievements.filter((entry) => !previous.achievements.some((old) => old.id === entry.id)).length,
|
||||
20
|
||||
);
|
||||
for (const fixture of ['GermanyRecharged', 'USAOriginal']) {
|
||||
const data = JSON.parse(readFileSync(new URL(`../src/fixtures/${fixture}.json`, import.meta.url), 'utf8'));
|
||||
const completed = wrapper.replay(data);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ import { createAnalysisScenario } from './analysis';
|
|||
import { setup } from './engine';
|
||||
import GermanyRecharged from './fixtures/GermanyRecharged.json';
|
||||
import USAOriginal from './fixtures/USAOriginal.json';
|
||||
import { GameState, MapName, Phase, Player, PowerPlantType } from './gamestate';
|
||||
import { GameState, MapName, Phase, Player, PowerPlantType, Variant } from './gamestate';
|
||||
import { LogMove } from './log';
|
||||
import { maps, mapsRecharged } from './maps';
|
||||
|
||||
const ids = [
|
||||
'grid-champion',
|
||||
|
|
@ -18,6 +19,26 @@ const ids = [
|
|||
'usa-champion',
|
||||
'france-champion',
|
||||
'japan-champion',
|
||||
'brazil-champion',
|
||||
'spain-portugal-champion',
|
||||
'india-champion',
|
||||
'italy-champion',
|
||||
'quebec-champion',
|
||||
'middle-east-champion',
|
||||
'china-champion',
|
||||
'benelux-champion',
|
||||
'russia-champion',
|
||||
'central-europe-champion',
|
||||
'baden-wurttemberg-champion',
|
||||
'northern-europe-champion',
|
||||
'korea-champion',
|
||||
'europe-champion',
|
||||
'north-america-champion',
|
||||
'south-africa-champion',
|
||||
'uk-ireland-champion',
|
||||
'australia-champion',
|
||||
'bremen-champion',
|
||||
'manhattan-champion',
|
||||
'power-fifteen',
|
||||
'power-eighteen',
|
||||
'fully-supplied',
|
||||
|
|
@ -29,10 +50,38 @@ const ids = [
|
|||
'atomic-power',
|
||||
];
|
||||
|
||||
// Independent explicit expectations: do not derive badge IDs from implementation slugs.
|
||||
const mapBadges: [MapName, string][] = [
|
||||
['Germany', 'germany-champion'],
|
||||
['USA', 'usa-champion'],
|
||||
['France', 'france-champion'],
|
||||
['Japan', 'japan-champion'],
|
||||
['Brazil', 'brazil-champion'],
|
||||
['Spain & Portugal', 'spain-portugal-champion'],
|
||||
['India', 'india-champion'],
|
||||
['Italy', 'italy-champion'],
|
||||
['Quebec', 'quebec-champion'],
|
||||
['Middle East', 'middle-east-champion'],
|
||||
['China', 'china-champion'],
|
||||
['Benelux', 'benelux-champion'],
|
||||
['Russia', 'russia-champion'],
|
||||
['Central Europe', 'central-europe-champion'],
|
||||
['Baden-Württemberg', 'baden-wurttemberg-champion'],
|
||||
['Northern Europe', 'northern-europe-champion'],
|
||||
['Korea', 'korea-champion'],
|
||||
['Europe', 'europe-champion'],
|
||||
['North America', 'north-america-champion'],
|
||||
['South Africa', 'south-africa-champion'],
|
||||
['UK & Ireland', 'uk-ireland-champion'],
|
||||
['Australia', 'australia-champion'],
|
||||
['Bremen', 'bremen-champion'],
|
||||
['Manhattan', 'manhattan-champion'],
|
||||
];
|
||||
|
||||
// Deliberately synthetic final positions: setup supplies the complete state shape,
|
||||
// but these boundary tests do not claim their scores came from legal game play.
|
||||
function finalState(count = 2, map: MapName = 'Germany'): GameState {
|
||||
const state = setup(count, { map }, 'achievement-boundaries');
|
||||
function finalState(count = 2, map: MapName = 'Germany', variant: Variant = 'original'): GameState {
|
||||
const state = setup(count, { map, variant }, 'achievement-boundaries');
|
||||
state.phase = Phase.GameEnd;
|
||||
state.newTurn = true;
|
||||
state.currentPlayers = [];
|
||||
|
|
@ -63,11 +112,11 @@ function freezeDeep(value: unknown) {
|
|||
describe('achievements', function () {
|
||||
this.timeout(30000);
|
||||
|
||||
it('publishes all 16 stable IDs in a fresh revisioned manifest', () => {
|
||||
it('publishes all 36 stable IDs in a fresh revisioned manifest', () => {
|
||||
const manifest = achievementDefinitions();
|
||||
expect(manifest.revision).to.equal(1);
|
||||
expect(manifest.revision).to.equal(2);
|
||||
expect(manifest.achievements.map((a) => a.id)).to.deep.equal(ids);
|
||||
expect(new Set(ids).size).to.equal(16);
|
||||
expect(new Set(ids).size).to.equal(36);
|
||||
manifest.achievements.forEach((a) => {
|
||||
expect(a.name).to.be.a('string').and.not.equal('');
|
||||
expect(a.description).to.be.a('string').and.not.equal('');
|
||||
|
|
@ -79,25 +128,50 @@ describe('achievements', function () {
|
|||
expect(wrapper.achievementDefinitions()).to.deep.equal(original);
|
||||
});
|
||||
|
||||
for (const map of ['Germany', 'USA', 'France', 'Japan'] as MapName[]) {
|
||||
for (const count of [2, 6]) {
|
||||
it(`awards only the ${map} and ${count}-seat win predicates to the winner`, () => {
|
||||
const state = finalState(count, map);
|
||||
state.players[1].citiesPowered = 1;
|
||||
const expected = [
|
||||
'grid-champion',
|
||||
count === 2 ? 'head-to-head' : 'full-table',
|
||||
`${map.toLowerCase()}-champion`,
|
||||
];
|
||||
expect(earned(state, 1)).to.deep.equal(expected);
|
||||
expect(earned(state)).to.deep.equal([]);
|
||||
expect(achievements(state).map((r) => r.outcome)).to.deep.equal(
|
||||
state.players.map((_, seat) => (seat === 1 ? 'win' : 'loss'))
|
||||
);
|
||||
});
|
||||
for (const [variant, runtimeMaps] of [
|
||||
['original', maps],
|
||||
['recharged', mapsRecharged],
|
||||
] as const) {
|
||||
it(`${variant} runtime maps exactly match the 24 supported badge names`, () => {
|
||||
expect(mapBadges).to.have.length(24);
|
||||
expect(new Set(mapBadges.map(([name]) => name)).size).to.equal(24);
|
||||
expect(runtimeMaps.map((map) => map.name).sort()).to.deep.equal(mapBadges.map(([name]) => name).sort());
|
||||
});
|
||||
|
||||
for (const [map, badge] of mapBadges) {
|
||||
for (const count of [2, 6]) {
|
||||
it(`awards only the ${map} (${variant}) and ${count}-seat win predicates to the winner`, () => {
|
||||
const state = finalState(count, map, variant);
|
||||
expect(state.map.name).to.equal(map);
|
||||
state.players[1].citiesPowered = 1;
|
||||
const expected = ['grid-champion', count === 2 ? 'head-to-head' : 'full-table', badge];
|
||||
expect(earned(state, 1)).to.deep.equal(expected);
|
||||
state.players.forEach((_, seat) => {
|
||||
if (seat !== 1) expect(earned(state, seat)).to.deep.equal([]);
|
||||
});
|
||||
expect(achievements(state).map((r) => r.outcome)).to.deep.equal(
|
||||
state.players.map((_, seat) => (seat === 1 ? 'win' : 'loss'))
|
||||
);
|
||||
// Requested options may be Random or stale; only the resolved map counts.
|
||||
state.options.map = 'Random';
|
||||
expect(earned(state, 1)).to.deep.equal(expected);
|
||||
state.options.map = map === 'Germany' ? 'USA' : 'Germany';
|
||||
expect(earned(state, 1)).to.deep.equal(expected);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const unsupported of ['Atlantis', 'Random', 'toString', '__proto__']) {
|
||||
it(`does not award a map badge for unsupported resolved map ${unsupported}`, () => {
|
||||
const state = finalState();
|
||||
state.map.name = unsupported as MapName;
|
||||
state.players[0].citiesPowered = 1;
|
||||
expect(earned(state)).to.deep.equal(['grid-champion', 'head-to-head']);
|
||||
expect(earned(state, 1)).to.deep.equal([]);
|
||||
});
|
||||
}
|
||||
|
||||
for (const [id, field, threshold] of [
|
||||
['power-fifteen', 'power', 15],
|
||||
['power-eighteen', 'power', 18],
|
||||
|
|
@ -123,11 +197,17 @@ describe('achievements', function () {
|
|||
for (const [network, power, eligible] of [
|
||||
[9, 9, false],
|
||||
[10, 9, false],
|
||||
[10, 10, true],
|
||||
[10, 10, false],
|
||||
[10, 11, false],
|
||||
[11, 11, true],
|
||||
[14, 14, false],
|
||||
[15, 14, false],
|
||||
[15, 15, true],
|
||||
[15, 16, false],
|
||||
[16, 15, false],
|
||||
[16, 16, true],
|
||||
[16, 17, false],
|
||||
] as const) {
|
||||
it(`fully supplied requires at least ten cities and exact supply (${network}/${power})`, () => {
|
||||
it(`fully supplied requires at least fifteen cities and exact supply (${network}/${power})`, () => {
|
||||
const state = finalState();
|
||||
cities(state.players[0], network);
|
||||
state.players[0].citiesPowered = power;
|
||||
|
|
@ -155,7 +235,10 @@ describe('achievements', function () {
|
|||
const state = finalState(2, 'Australia');
|
||||
state.players[0].powerPlants = [{ number: 50, type: PowerPlantType.Uranium, cost: 2, citiesPowered: 8 }];
|
||||
expect(earned(state)).not.to.include('atomic-power');
|
||||
expect(earned(state).filter((id) => id.endsWith('-champion'))).to.deep.equal(['grid-champion']);
|
||||
expect(earned(state).filter((id) => id.endsWith('-champion'))).to.deep.equal([
|
||||
'grid-champion',
|
||||
'australia-champion',
|
||||
]);
|
||||
for (const map of ['Australia', 'Germany'] as MapName[]) {
|
||||
const fusion = finalState(2, map);
|
||||
fusion.players[0].powerPlants = [{ number: 50, type: PowerPlantType.Nuclear, cost: 0, citiesPowered: 8 }];
|
||||
|
|
|
|||
|
|
@ -1,15 +1,45 @@
|
|||
import type { AchievementDefinition, AchievementManifest, SeatAchievements } from '@boardgamers/protocol/engine';
|
||||
import { ended, playersSortedByScore } from './engine';
|
||||
import { GameState, Player, PowerPlantType } from './gamestate';
|
||||
import { GameState, MapName, Player, PowerPlantType } from './gamestate';
|
||||
|
||||
// Explicit stable IDs, not generated slugs. Match the resolved map name, never
|
||||
// the requested option (which may be Random). Original/Recharged share a badge.
|
||||
const mapAchievements: Record<MapName, string> = {
|
||||
Germany: 'germany-champion',
|
||||
USA: 'usa-champion',
|
||||
France: 'france-champion',
|
||||
Japan: 'japan-champion',
|
||||
Brazil: 'brazil-champion',
|
||||
'Spain & Portugal': 'spain-portugal-champion',
|
||||
India: 'india-champion',
|
||||
Italy: 'italy-champion',
|
||||
Quebec: 'quebec-champion',
|
||||
'Middle East': 'middle-east-champion',
|
||||
China: 'china-champion',
|
||||
Benelux: 'benelux-champion',
|
||||
Russia: 'russia-champion',
|
||||
'Central Europe': 'central-europe-champion',
|
||||
'Baden-Württemberg': 'baden-wurttemberg-champion',
|
||||
'Northern Europe': 'northern-europe-champion',
|
||||
Korea: 'korea-champion',
|
||||
Europe: 'europe-champion',
|
||||
'North America': 'north-america-champion',
|
||||
'South Africa': 'south-africa-champion',
|
||||
'UK & Ireland': 'uk-ireland-champion',
|
||||
Australia: 'australia-champion',
|
||||
Bremen: 'bremen-champion',
|
||||
Manhattan: 'manhattan-champion',
|
||||
};
|
||||
|
||||
const definitions: AchievementDefinition[] = [
|
||||
{ id: 'grid-champion', name: 'Grid Champion', description: 'Win a game of Power Grid.' },
|
||||
{ id: 'head-to-head', name: 'Head to Head', description: 'Win a two-player game.' },
|
||||
{ id: 'full-table', name: 'Full Table', description: 'Win a six-player game.' },
|
||||
{ id: 'germany-champion', name: 'Germany Champion', description: 'Win on the Germany map.' },
|
||||
{ id: 'usa-champion', name: 'USA Champion', description: 'Win on the USA map.' },
|
||||
{ id: 'france-champion', name: 'France Champion', description: 'Win on the France map.' },
|
||||
{ id: 'japan-champion', name: 'Japan Champion', description: 'Win on the Japan map.' },
|
||||
...Object.entries(mapAchievements).map(([map, id]) => ({
|
||||
id,
|
||||
name: `${map} Champion`,
|
||||
description: `Win on the ${map} map.`,
|
||||
})),
|
||||
{
|
||||
id: 'power-fifteen',
|
||||
name: 'Power Fifteen',
|
||||
|
|
@ -23,7 +53,7 @@ const definitions: AchievementDefinition[] = [
|
|||
{
|
||||
id: 'fully-supplied',
|
||||
name: 'Fully Supplied',
|
||||
description: 'Finish able to power every city in a network of at least 10 cities.',
|
||||
description: 'Finish able to power every city in a network of at least 15 cities.',
|
||||
},
|
||||
{
|
||||
id: 'network-seventeen',
|
||||
|
|
@ -48,7 +78,7 @@ const definitions: AchievementDefinition[] = [
|
|||
|
||||
export function achievementDefinitions(): AchievementManifest {
|
||||
// A host may cache or modify its copy without changing future evaluations.
|
||||
return { revision: 1, achievements: definitions.map((definition) => ({ ...definition })) };
|
||||
return { revision: 2, achievements: definitions.map((definition) => ({ ...definition })) };
|
||||
}
|
||||
|
||||
function tied(a: Player, b: Player): boolean {
|
||||
|
|
@ -81,17 +111,14 @@ export function achievements(data: GameState): SeatAchievements[] {
|
|||
earned.push('grid-champion');
|
||||
if (data.players.length === 2) earned.push('head-to-head');
|
||||
if (data.players.length === 6) earned.push('full-table');
|
||||
const maps: Record<string, string> = {
|
||||
Germany: 'germany-champion',
|
||||
USA: 'usa-champion',
|
||||
France: 'france-champion',
|
||||
Japan: 'japan-champion',
|
||||
};
|
||||
if (maps[data.map.name]) earned.push(maps[data.map.name]);
|
||||
const mapAchievement = Object.prototype.hasOwnProperty.call(mapAchievements, data.map.name)
|
||||
? mapAchievements[data.map.name as MapName]
|
||||
: undefined;
|
||||
if (mapAchievement) earned.push(mapAchievement);
|
||||
}
|
||||
if (player.citiesPowered >= 15) earned.push('power-fifteen');
|
||||
if (player.citiesPowered >= 18) earned.push('power-eighteen');
|
||||
if (player.cities.length >= 10 && player.citiesPowered === player.cities.length) earned.push('fully-supplied');
|
||||
if (player.cities.length >= 15 && player.citiesPowered === player.cities.length) earned.push('fully-supplied');
|
||||
if (player.cities.length >= 17) earned.push('network-seventeen');
|
||||
if (player.cities.length >= 20) earned.push('network-twenty');
|
||||
if (player.money >= 100) earned.push('cash-reserve');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue