fix(lantids): correct shared-mine rewards and scoring
This commit is contained in:
parent
b766f3b7a6
commit
d8f540d2f9
14 changed files with 363 additions and 97 deletions
47
docs/lost-fleet/LANTIDS_AUDIT.md
Normal file
47
docs/lost-fleet/LANTIDS_AUDIT.md
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Lantids rules audit — 2026-11-01
|
||||
|
||||
## Rules used
|
||||
|
||||
- [Base rules, Appendix I: Lantids](https://www.feuerland-spiele.de/fileadmin/game/Gaia_Project/GAIA_PROJECT_EN_rules_Web.pdf):
|
||||
a shared mine functions normally except that it cannot be upgraded and does not contribute to
|
||||
planet-type or Gaia conditions. Mine placement still pays the mine cost and range, but no
|
||||
habitability cost. Shared mines retain their owner's income and building value.
|
||||
- [Designer clarifications on shared mines](https://boardgamegeek.com/article/27462499):
|
||||
sector/structure presence and navigation count; planet-specific effects do not.
|
||||
- [Lost Fleet rules](https://capstone-games.com/cdn/shop/files/GP_Exp_Rule_EN_V1_Web.pdf?v=6134275372584409409),
|
||||
pp. 8, 14–15: adjusted PI, Deep Space sector rewards, bonus mine actions.
|
||||
- [Protoplanet/asteroid clarification](https://boardgamegeek.com/thread/3389868/lantids-plus-protoplanet):
|
||||
a shared protoplanet grants no 6 VP and a shared asteroid does not count for asteroid scoring.
|
||||
This thread relays the designer ruling; the existing implementation already follows it for
|
||||
ordinary builds. The audit applies that same rule to bonus mine actions.
|
||||
|
||||
## Findings and coverage
|
||||
|
||||
| Area | Outcome |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Deep Space final goal, booster, immediate/pass Advanced Tech | Fixed: include shared mines; count each physical sector once. Gaiaformers, stations and off-map artifacts do not add sectors. |
|
||||
| Bonus mine from Range/Terraform federation or Terraform tech | Fixed: sharing Gaia needs no habitability QIC; sharing an asteroid needs no Gaiaformer; sharing a protoplanet gives no 6 VP. Normal range rules still apply. |
|
||||
| Solo/2-player PI on a shared Terra planet | Fixed: one 2-knowledge reward, not two. Shared mines already receive the base PI reward and do not also qualify for a planet-type reward. |
|
||||
| Charts and scoring help | Fixed: include shared deep-sector mines, recognize own first colonization, track Lost Planet ownership, and isolate each chart's history state. Completed Gaia projects count when their mine is built. |
|
||||
| Ordinary shared-mine costs and benefits | Verified: mine cost, range, mine income/scoring, PI knowledge, structure/federation count, own power value and leech. No Gaia/asteroid/planet-type scoring or protoplanet reward. |
|
||||
| Build restrictions | Verified: no upgrade of a shared mine, no sharing an unfinished Gaia project, normal mine supply limit. Starting placement remains restricted to vacant home planets. |
|
||||
| Lost Fleet adjustments | Existing tests cover +1 token income, own Terra PI bonus in solo/2p, extra PI charge in 3p, and unchanged 4p/base behavior. |
|
||||
| Round sector/planet-type scoring | Existing tests and the protoplanet regression distinguish sector presence from planet-type colonization. |
|
||||
|
||||
The old fuzzer exclusion of shared Deep Space mines was based on the implementation rather than
|
||||
the rules. Both the production count and independent map-scan oracle now include them.
|
||||
|
||||
The existing house ruling for the base game's **ordinary sector** goal remains separate from
|
||||
Deep Space scoring (RULES_CLARIFICATIONS §G4c). This audit does not change that ruling.
|
||||
|
||||
Regression files: `engine/src/faction-boards/lantids-rules.spec.ts`, existing
|
||||
`lantids.spec.ts` / `tiles/scoring.spec.ts`, and `viewer/src/logic/charts/lantids-charts.spec.ts`.
|
||||
The existing all-families chart fixture now correctly credits Lantids with their starting Terra
|
||||
planet type rather than zero planet types.
|
||||
|
||||
## Reported game
|
||||
|
||||
In Wicked-banana-8201 at move 201, Lantids have a shared mine on DS14_0: their Deep Space count
|
||||
must be **1**, previously **0**. The mine's ordinary 3-VP new-sector reward is already present;
|
||||
the earlier removal of its incorrect 6-VP protoplanet bonus remains valid. Deep Space progress is
|
||||
computed from the board, so this correction does not require rewriting that game's moves.
|
||||
|
|
@ -729,6 +729,13 @@ yellow = Credit action.** Source for C1–C4 effects/costs below: owner board-re
|
|||
|
||||
- I1. Ivits — **CLOSED**, see I7: power 2/2 (table-confirmed, matches p.8 and pre-existing vanilla
|
||||
value), no LF-specific ability or other delta found.
|
||||
- I2a. Lantids shared mines count for **sector presence**, including the Lost Fleet Deep Space
|
||||
final goal, booster and Advanced Tech tiles. They do not count for planet-type/Gaia/asteroid
|
||||
conditions or grant the 6-VP protoplanet reward. The exclusion is about planet types, not sector
|
||||
presence. Use `colonizedBy(player)` for sector counts, not `isMainOccupier(player)`.
|
||||
The earlier fuzzer note calling shared Deep Space mines an oracle bug was incorrect;
|
||||
both the engine and oracle were excluding valid mines. See [Lantids audit](LANTIDS_AUDIT.md)
|
||||
for sources, verified mechanics and regression coverage (2026-11-01).
|
||||
- I2. Lantids: +1 power Area I income (CONFIRMED, p.8). Adjusted PI tile, text-only (no image in the
|
||||
uiqoo.kr randomizer, see COMPONENTS.md §8), both sides: **solo/2-player side** — gain 2 knowledge
|
||||
both when adding a mine to a colonized planet AND when building a mine on the Lantids' home planet
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/engine",
|
||||
"version": "4.17.3",
|
||||
"version": "4.17.4",
|
||||
"description": "Javascript engine for project gaia",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.ts",
|
||||
|
|
|
|||
|
|
@ -136,17 +136,18 @@ function possibleFreeBuildMine(
|
|||
if (hex.data.planet === Planet.Transdim || !pl.canOccupy(hex)) {
|
||||
continue;
|
||||
}
|
||||
if (hex.data.planet === Planet.Asteroid && !pl.data.hasResource(new Reward(1, Resource.GaiaFormer))) {
|
||||
// Shared Lantids mines have no habitability cost or planet-specific reward.
|
||||
const planet = hex.occupied() ? pl.planet : hex.data.planet;
|
||||
if (planet === Planet.Asteroid && !pl.data.hasResource(new Reward(1, Resource.GaiaFormer))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rewards: Reward[] = [];
|
||||
let steps = 0;
|
||||
|
||||
if (hex.data.planet === Planet.Gaia) {
|
||||
if (planet === Planet.Gaia) {
|
||||
rewards.push(pl.gaiaFormingCost());
|
||||
} else {
|
||||
const planet = hex.occupied() ? pl.planet : hex.data.planet;
|
||||
steps = terraformingStepsRequired(pl.faction, planet, pl.data.lostFleetCost3Planets);
|
||||
const discountedSteps = Math.max(steps - discount.terraformDiscount, 0);
|
||||
const oreCost = terraformingCost(pl.data, discountedSteps, engine.replay);
|
||||
|
|
@ -158,8 +159,7 @@ function possibleFreeBuildMine(
|
|||
}
|
||||
}
|
||||
|
||||
// Only the initial setup mine is exempt, including for Protoplanet factions.
|
||||
if (hex.data.planet === Planet.Protoplanet) {
|
||||
if (planet === Planet.Protoplanet) {
|
||||
rewards.push(new Reward(-6, Resource.VictoryPoint));
|
||||
}
|
||||
|
||||
|
|
|
|||
157
engine/src/faction-boards/lantids-rules.spec.ts
Normal file
157
engine/src/faction-boards/lantids-rules.spec.ts
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
import { expect } from "chai";
|
||||
import { possibleBuildings } from "../available/buildings";
|
||||
import { possibleFederationTokenBuildMine, possibleSpaceshipTechTileBuildMine } from "../available/federations";
|
||||
import { qicForDistance } from "../cost";
|
||||
import Engine from "../engine";
|
||||
import {
|
||||
AdvTechTile,
|
||||
AdvTechTilePos,
|
||||
Booster,
|
||||
Building,
|
||||
Condition,
|
||||
Faction,
|
||||
FinalTile,
|
||||
Phase,
|
||||
Planet,
|
||||
Player as PlayerEnum,
|
||||
ScoringTile,
|
||||
SpaceshipFederation,
|
||||
} from "../enums";
|
||||
import { moveBuild } from "../move/buildings";
|
||||
import { leechPossible } from "../move/phase";
|
||||
import Reward from "../reward";
|
||||
import { roundScoringEvents } from "../tiles/scoring";
|
||||
import { techTileEventWithSource } from "../tiles/techs";
|
||||
|
||||
function position(nbPlayers = 4) {
|
||||
const engine = new Engine([`init ${nbPlayers} lantids-rules-audit`], { lostFleet: true });
|
||||
engine.players.forEach((player, i) => {
|
||||
player.faction = [Faction.Lantids, Faction.Geodens, Faction.Xenos, Faction.Darkanians][i];
|
||||
player.loadFaction(null, engine.expansions, false, nbPlayers);
|
||||
player.data.credits = 25;
|
||||
player.data.ores = 15;
|
||||
player.data.qics = 10;
|
||||
player.data.range = 99;
|
||||
});
|
||||
engine.phase = Phase.RoundMove;
|
||||
const player = engine.players[0];
|
||||
const host = engine.players[1];
|
||||
const target = engine.map.getS("DS11_0");
|
||||
const share = (location: string, planet: Planet) => {
|
||||
const hex = engine.map.getS(location);
|
||||
hex.data.planet = planet;
|
||||
host.build(Building.Mine, hex, [], engine.map, 0, false);
|
||||
player.build(Building.Mine, hex, [], engine.map);
|
||||
return hex;
|
||||
};
|
||||
const home = [...engine.map.grid.values()].find((h) => h.data.planet === Planet.Terra);
|
||||
player.build(Building.Mine, home, [], engine.map);
|
||||
return { engine, player, host, target, share };
|
||||
}
|
||||
|
||||
describe("Lantids shared-mine rules audit", () => {
|
||||
for (const reward of ["final", "booster", "advanced", "advanced-pass"]) {
|
||||
it(`counts distinct shared deep sectors for ${reward}, excluding Gaiaformers and stations`, () => {
|
||||
const { engine, player, share } = position();
|
||||
share("DS11_0", Planet.Protoplanet);
|
||||
share("DS11_1", Planet.Asteroid);
|
||||
share("DS12_0", Planet.Lost);
|
||||
const own = engine.map.getS("DS13_0");
|
||||
own.data.planet = Planet.Terra;
|
||||
player.build(Building.Mine, own, [], engine.map);
|
||||
const former = engine.map.getS("DS14_0");
|
||||
former.data.planet = Planet.Transdim;
|
||||
player.build(Building.GaiaFormer, former, [], engine.map);
|
||||
const station = engine.map.getS("DS15_0");
|
||||
station.data.planet = Planet.Empty;
|
||||
player.build(Building.SpaceStation, station, [], engine.map);
|
||||
expect(player.finalCount(FinalTile.DeepSpaceSector)).to.equal(3);
|
||||
expect(player.finalCount(FinalTile.PlanetType)).to.equal(1);
|
||||
expect(player.finalCount(FinalTile.Asteroid)).to.equal(0);
|
||||
const before = player.data.victoryPoints;
|
||||
if (reward === "booster") player.getRoundBooster(Booster.LostFleetDeep);
|
||||
if (reward === "advanced")
|
||||
player.loadEvents(techTileEventWithSource(AdvTechTile.Deep, AdvTechTilePos.Intelligence));
|
||||
if (reward === "advanced-pass")
|
||||
player.loadEvents(techTileEventWithSource(AdvTechTile.DeepPass, AdvTechTilePos.Intelligence));
|
||||
player.receivePassIncome();
|
||||
expect(player.data.victoryPoints - before).to.equal(reward === "final" ? 0 : reward === "advanced" ? 12 : 6);
|
||||
});
|
||||
}
|
||||
|
||||
for (const planet of [Planet.Terra, Planet.Gaia, Planet.Asteroid, Planet.Protoplanet, Planet.Lost]) {
|
||||
it(`treats a shared ${planet} as a mine, with no planet cost or planet scoring`, () => {
|
||||
const { engine, player, host, target } = position();
|
||||
target.data.planet = planet;
|
||||
host.build(Building.PlanetaryInstitute, target, [], engine.map, 0, false);
|
||||
player.data.gaiaformers = 0;
|
||||
player.data.buildings[Building.PlanetaryInstitute] = 1;
|
||||
player.loadEvents(roundScoringEvents(ScoringTile.Score3, 1));
|
||||
player.loadEvents(roundScoringEvents(ScoringTile.Score6, 2));
|
||||
player.loadEvents(roundScoringEvents(ScoringTile.LfPlanet3, 3));
|
||||
const command = possibleBuildings(engine, player.player)[0];
|
||||
const offer = command.data.buildings.find((b) => b.coordinates === target.toString());
|
||||
expect(offer.cost).to.equal("2c,o");
|
||||
expect(offer.steps).to.equal(0);
|
||||
const vp = player.data.victoryPoints;
|
||||
const k = player.data.knowledge;
|
||||
moveBuild(engine, command, player.player, Building.Mine, target.toString());
|
||||
expect(player.data.victoryPoints - vp).to.equal(2);
|
||||
expect(player.data.knowledge - k).to.equal(2);
|
||||
expect(player.data.gaiaformersUsedForAsteroid).to.equal(0);
|
||||
expect(player.eventConditionCount(Condition.Mine)).to.equal(2);
|
||||
expect(player.finalCount(FinalTile.Structure)).to.equal(2);
|
||||
expect(player.finalCount(FinalTile.PlanetType)).to.equal(1);
|
||||
expect(player.finalCount(FinalTile.Gaia)).to.equal(0);
|
||||
expect(player.finalCount(FinalTile.Asteroid)).to.equal(0);
|
||||
expect(player.buildingValue(target, { federation: true })).to.equal(1);
|
||||
target.addToFederationOf(player.player);
|
||||
expect(player.finalCount(FinalTile.StructureFed)).to.equal(1);
|
||||
expect(qicForDistance(engine.map, target, player, false).distance).to.equal(0);
|
||||
expect(leechPossible(engine, target, (hex) => player.buildingValue(hex))).to.equal(1);
|
||||
expect(leechPossible(engine, target, (hex) => host.buildingValue(hex))).to.equal(3);
|
||||
expect(
|
||||
possibleBuildings(engine, player.player)[0].data.buildings.some((b) => b.coordinates === target.toString())
|
||||
).to.equal(false);
|
||||
});
|
||||
}
|
||||
|
||||
for (const action of [SpaceshipFederation.Range, SpaceshipFederation.Terraform, "tech"] as const) {
|
||||
for (const planet of [Planet.Gaia, Planet.Asteroid, Planet.Protoplanet, Planet.Lost]) {
|
||||
it(`${action}: a free shared mine on ${planet} needs no habitability payment and gives no protoplanet VP`, () => {
|
||||
const { engine, player, host, target } = position();
|
||||
target.data.planet = planet;
|
||||
host.build(Building.Mine, target, [], engine.map, 0, false);
|
||||
player.data.gaiaformers = 0;
|
||||
player.data.qics = 0;
|
||||
const command =
|
||||
action === "tech"
|
||||
? possibleSpaceshipTechTileBuildMine(engine, player.player)[0]
|
||||
: possibleFederationTokenBuildMine(engine, player.player, { federation: action })[0];
|
||||
const offer = command.data.buildings.find((b) => b.coordinates === target.toString());
|
||||
expect(offer, "shared mine must be available without a Gaiaformer or Gaia QIC").not.to.equal(undefined);
|
||||
expect(Reward.parse(offer.cost).every((r) => r.count === 0)).to.equal(true);
|
||||
const vp = player.data.victoryPoints;
|
||||
moveBuild(engine, command, player.player, Building.Mine, target.toString());
|
||||
expect(player.data.victoryPoints).to.equal(vp);
|
||||
expect(player.data.gaiaformersUsedForAsteroid).to.equal(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it("does not share an unfinished Gaia project", () => {
|
||||
const { player, target } = position();
|
||||
target.data.planet = Planet.Gaia;
|
||||
target.data.player = PlayerEnum.Player2;
|
||||
target.data.building = Building.GaiaFormer;
|
||||
expect(player.canOccupy(target)).to.equal(false);
|
||||
});
|
||||
|
||||
it("grants the solo/2p PI knowledge once for a shared Terra mine", () => {
|
||||
const { player, share } = position(2);
|
||||
player.data.buildings[Building.PlanetaryInstitute] = 1;
|
||||
const k = player.data.knowledge;
|
||||
share("DS11_0", Planet.Terra);
|
||||
expect(player.data.knowledge - k).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
|
@ -16,7 +16,8 @@ function gainAdjustedPiBonus(player: Player, hex: GaiaHex) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (player.nbPlayers <= 2 && hex.data.planet === Planet.Terra) {
|
||||
// A shared mine already received the PI reward in build(), regardless of its planet type.
|
||||
if (player.nbPlayers <= 2 && hex.data.planet === Planet.Terra && hex.isMainOccupier(player.player)) {
|
||||
player.gainRewards(Reward.parse("2k"), Faction.Lantids);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -232,12 +232,11 @@ function countDistinctPlanetTypes(engine: Engine, pl: Player): number {
|
|||
return new Set([...real, ...pl.data.artifactPlanetTypes]).size;
|
||||
}
|
||||
|
||||
/** Mirrors `Player.ownedPlanets` (main-occupier only — excludes a Lantids-style "additional
|
||||
* mine" guest colonization, which does not count as this player's own colonization). */
|
||||
/** Sector presence includes shared Lantids mines; only planet-type scoring excludes them. */
|
||||
function countDeepSpaceSectors(engine: Engine, player: number): number {
|
||||
const keys = new Set<string>();
|
||||
for (const hex of engine.map.grid.values()) {
|
||||
if (!hex.isMainOccupier(player)) {
|
||||
if (!hex.colonizedBy(player)) {
|
||||
continue;
|
||||
}
|
||||
if (classifySectorId(hex.data.sector) !== LostFleetSectorType.DeepSpace) {
|
||||
|
|
|
|||
|
|
@ -1205,7 +1205,8 @@ export default class Player extends EventEmitter {
|
|||
case Condition.Asteroid:
|
||||
return this.ownedPlanetsCount[Planet.Asteroid] ?? 0;
|
||||
case Condition.DeepSpaceSector:
|
||||
return colonizedDeepSpaceSectorCount(this.ownedPlanets);
|
||||
// Sector scoring counts shared Lantids mines, unlike planet-type scoring.
|
||||
return colonizedDeepSpaceSectorCount(this.data.occupied.filter((hex) => hex.colonizedBy(this.player)));
|
||||
case Condition.PlanetaryInstituteAcademyDistance: {
|
||||
const pi = this.data.occupied.find((hex) => hex.buildingOf(this.player) === Building.PlanetaryInstitute);
|
||||
const academies = this.data.occupied.filter((hex) => isAcademy(hex.buildingOf(this.player)));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.2.20",
|
||||
"version": "1.2.21",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.22.19",
|
||||
"version": "5.22.20",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -178,80 +178,26 @@ const asteroids: FinalScoringExtractLog = planetCounter(
|
|||
false
|
||||
);
|
||||
|
||||
const deepSpaceSectors: FinalScoringExtractLog = ExtractLog.new((want) => {
|
||||
const sectors = new Set<string>();
|
||||
const transdim = new Set<string>();
|
||||
const owners: { [key: string]: Faction } = {};
|
||||
|
||||
return (e) => {
|
||||
const cmd = e.cmd;
|
||||
if (!cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (cmd.command) {
|
||||
case Command.PlaceLostPlanet: {
|
||||
if (cmd.faction !== want.faction) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const hex = e.data.map.getS(cmd.args[0]);
|
||||
if (classifySectorId(hex.data.sector) !== LostFleetSectorType.DeepSpace) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const sectorKey = hex.data.sector.replace(/_\d+$/, "");
|
||||
if (sectors.has(sectorKey)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sectors.add(sectorKey);
|
||||
return 1;
|
||||
const deepSpaceSectors: FinalScoringExtractLog = ExtractLog.wrapper((player, source, engine) => {
|
||||
const seen = new Set<string>();
|
||||
return planetCounter(
|
||||
() => true,
|
||||
() => true,
|
||||
() => true,
|
||||
false,
|
||||
(cmd, log, planet, location) => {
|
||||
const sector = engine.map.getS(location).data.sector;
|
||||
if (classifySectorId(sector) !== LostFleetSectorType.DeepSpace) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
case Command.Build: {
|
||||
const building = cmd.args[0] as Building;
|
||||
const location = cmd.args[1];
|
||||
const hex = e.data.map.getS(location);
|
||||
const sectorType = classifySectorId(hex.data.sector);
|
||||
const owner = owners[location];
|
||||
|
||||
if (owner == null) {
|
||||
owners[location] = cmd.faction;
|
||||
}
|
||||
|
||||
if (cmd.faction !== want.faction) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (owner !== want.faction && want.faction === Faction.Lantids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (building === Building.GaiaFormer) {
|
||||
transdim.add(location);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (
|
||||
sectorType === LostFleetSectorType.DeepSpace &&
|
||||
(building === Building.Mine ||
|
||||
(building === Building.PlanetaryInstitute && want.faction === Faction.Ivits)) &&
|
||||
!transdim.has(location)
|
||||
) {
|
||||
const sectorKey = hex.data.sector.replace(/_\d+$/, "");
|
||||
if (sectors.has(sectorKey)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sectors.add(sectorKey);
|
||||
return 1;
|
||||
}
|
||||
const key = sector.replace(/_\d+$/, "");
|
||||
if (seen.has(key)) {
|
||||
return 0;
|
||||
}
|
||||
seen.add(key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
);
|
||||
});
|
||||
|
||||
const piAcademyDistance: FinalScoringExtractLog = ExtractLog.wrapper((want) => {
|
||||
|
|
@ -331,7 +277,7 @@ export const finalScoringSources: { [key in FinalTile]: FinalScoringSource } = {
|
|||
extractLog: piAcademyDistance,
|
||||
}),
|
||||
[FinalTile.DeepSpaceSector]: {
|
||||
contributors: ["Regular Building", "Lost Planet"],
|
||||
contributors: ["Regular Building", "Lost Planet", "Lantids Guest Mine"],
|
||||
shortcut: "d",
|
||||
name: "Deep Space sectors",
|
||||
color: "--lost",
|
||||
|
|
|
|||
106
viewer/src/logic/charts/lantids-charts.spec.ts
Normal file
106
viewer/src/logic/charts/lantids-charts.spec.ts
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import Engine, { Expansion, Faction, FinalTile, Planet, Player } from "@gaia-project/engine";
|
||||
import { expect } from "chai";
|
||||
import { parseCommands } from "../recent";
|
||||
import { ChartSource } from "./charts";
|
||||
import { finalScoringExtractLog, finalScoringSources } from "./final-scoring";
|
||||
import { planetsSourceFactory } from "./plantets";
|
||||
import { ExtractLog } from "./simple-charts";
|
||||
|
||||
function fixture() {
|
||||
const engine = new Engine(["init 2 lantids-chart-audit"], { lostFleet: true });
|
||||
engine.players.forEach((p, i) => {
|
||||
p.faction = i ? Faction.Xenos : Faction.Lantids;
|
||||
p.loadFaction(null, Expansion.LostFleet);
|
||||
});
|
||||
// Charts read the final board while walking the full move log.
|
||||
for (const [location, planet] of [
|
||||
["DS11_0", Planet.Terra],
|
||||
["DS11_1", Planet.Protoplanet],
|
||||
["DS12_0", Planet.Gaia],
|
||||
["DS13_0", Planet.Lost],
|
||||
["DS14_0", Planet.Gaia],
|
||||
] as const) {
|
||||
engine.map.getS(location).data.planet = planet;
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
|
||||
function walk<T extends FinalTile | Planet>(
|
||||
engine: Engine,
|
||||
player: Player,
|
||||
extract: ExtractLog<ChartSource<T>>,
|
||||
type: T,
|
||||
moves: string[]
|
||||
) {
|
||||
const source = { type, label: type, color: "black", weight: 1 };
|
||||
const process = extract.processor(player, source, engine);
|
||||
return moves.map((move) => {
|
||||
const commands = parseCommands(move);
|
||||
return commands.reduce(
|
||||
(n, cmd, cmdIndex) => n + process({ cmd, allCommands: commands, cmdIndex, source, data: engine, log: {} }),
|
||||
0
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
describe("Lantids scoring charts", () => {
|
||||
it("counts own and shared deep sectors once, including Lost Planets and completed Gaia projects", () => {
|
||||
const engine = fixture();
|
||||
const moves = [
|
||||
`lantids build m ${engine.map.getS("DS11_0").toString()}`,
|
||||
"xenos build m DS11_1",
|
||||
"lantids build m DS11_1",
|
||||
`xenos build m ${engine.map.getS("DS12_0").toString()}`,
|
||||
"lantids build m DS12_0",
|
||||
"xenos lostPlanet DS13_0",
|
||||
"lantids build m DS13_0",
|
||||
"lantids build gf DS14_0",
|
||||
"lantids build m DS14_0",
|
||||
"lantids build ts DS11_0",
|
||||
];
|
||||
const counts = () => walk(engine, engine.players[0], finalScoringExtractLog, FinalTile.DeepSpaceSector, moves);
|
||||
expect(counts()).to.deep.equal([1, 0, 0, 0, 1, 0, 1, 0, 1, 0]);
|
||||
expect(counts()).to.deep.equal([1, 0, 0, 0, 1, 0, 1, 0, 1, 0]);
|
||||
expect(finalScoringSources[FinalTile.DeepSpaceSector].contributors).to.include("Lantids Guest Mine");
|
||||
});
|
||||
|
||||
it("distinguishes independent colonization from sharing, including on the Lost Planet", () => {
|
||||
const engine = fixture();
|
||||
const moves = [
|
||||
`lantids build m ${engine.map.getS("DS11_0").toString()}`,
|
||||
`xenos build m ${engine.map.getS("DS12_0").toString()}`,
|
||||
"lantids build m DS12_0",
|
||||
"xenos lostPlanet DS13_0",
|
||||
"lantids build m DS13_0",
|
||||
"lantids build gf DS14_0",
|
||||
"lantids build m DS14_0",
|
||||
];
|
||||
const count = (tile: FinalTile) => walk(engine, engine.players[0], finalScoringExtractLog, tile, moves);
|
||||
expect(count(FinalTile.PlanetType)).to.deep.equal([1, 0, 0, 0, 0, 0, 1]);
|
||||
expect(count(FinalTile.Gaia)).to.deep.equal([0, 0, 0, 0, 0, 0, 1]);
|
||||
expect(count(FinalTile.Structure)).to.deep.equal([1, 0, 1, 0, 1, 0, 1]);
|
||||
});
|
||||
|
||||
it("keeps planet-chart state separate between players, sources and rebuilds", () => {
|
||||
const engine = fixture();
|
||||
const moves = [
|
||||
`lantids build m ${engine.map.getS("DS11_0").toString()}`,
|
||||
`xenos build m ${engine.map.getS("DS12_0").toString()}`,
|
||||
"lantids build m DS12_0",
|
||||
"xenos lostPlanet DS13_0",
|
||||
"lantids build m DS13_0",
|
||||
"lantids build gf DS14_0",
|
||||
"lantids build m DS14_0",
|
||||
];
|
||||
for (let repeat = 0; repeat < 2; repeat++) {
|
||||
for (const p of engine.players) {
|
||||
const guest = walk(engine, p, planetsSourceFactory.extractLog, Planet.Empty, moves);
|
||||
expect(guest.reduce((a, b) => a + b, 0)).to.equal(p.faction === Faction.Lantids ? 2 : 0);
|
||||
const terra = walk(engine, p, planetsSourceFactory.extractLog, Planet.Terra, moves);
|
||||
expect(terra.reduce((a, b) => a + b, 0)).to.equal(p.faction === Faction.Lantids ? 1 : 0);
|
||||
const transdim = walk(engine, p, planetsSourceFactory.extractLog, Planet.Transdim, moves);
|
||||
expect(transdim.reduce((a, b) => a + b, 0)).to.equal(p.faction === Faction.Lantids ? 1 : 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -160,10 +160,10 @@ export function planetCounter<T extends ChartKind>(
|
|||
countTransdim = true,
|
||||
value: (cmd: CommandObject, log: LogEntry, planet: Planet, location: string) => number = () => 1
|
||||
): ExtractLog<ChartSource<T>> {
|
||||
const transdim = new Set<string>();
|
||||
const owners: { [key: string]: Faction } = {};
|
||||
|
||||
return ExtractLog.new((want) => {
|
||||
// Each player/source and each chart rebuild needs its own history.
|
||||
const transdim = new Set<string>();
|
||||
const owners: { [key: string]: Faction } = {};
|
||||
return (e) => {
|
||||
const cmd = e.cmd;
|
||||
if (!cmd) {
|
||||
|
|
@ -173,6 +173,7 @@ export function planetCounter<T extends ChartKind>(
|
|||
const source = e.source;
|
||||
switch (cmd.command) {
|
||||
case Command.PlaceLostPlanet:
|
||||
owners[data.map.getS(cmd.args[0]).toString()] = cmd.faction;
|
||||
return cmd.faction == want.faction && includeLostPlanet(source)
|
||||
? value(cmd, e.log, Planet.Lost, cmd.args[0])
|
||||
: 0;
|
||||
|
|
@ -183,20 +184,21 @@ export function planetCounter<T extends ChartKind>(
|
|||
const hex = data.map.grid.get({ q, r });
|
||||
const planet = hex.data.planet;
|
||||
|
||||
const owner = owners[location];
|
||||
const key = hex.toString();
|
||||
const owner = owners[key];
|
||||
if (owner == null) {
|
||||
owners[location] = cmd.faction;
|
||||
owners[key] = cmd.faction;
|
||||
}
|
||||
if (cmd.faction != want.faction) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (owner != want.faction && want.faction == Faction.Lantids) {
|
||||
if (owner != null && owner != want.faction && want.faction == Faction.Lantids) {
|
||||
return includeLantidsGuestMine(source) ? value(cmd, e.log, planet, location) : 0;
|
||||
}
|
||||
|
||||
if (building == Building.GaiaFormer && countTransdim) {
|
||||
transdim.add(location);
|
||||
transdim.add(key);
|
||||
|
||||
if (includeRegularPlanet(Planet.Transdim, source.type, want)) {
|
||||
return value(cmd, e.log, Planet.Transdim, location);
|
||||
|
|
@ -206,7 +208,7 @@ export function planetCounter<T extends ChartKind>(
|
|||
if (
|
||||
includeRegularPlanet(planet, source.type, want) &&
|
||||
(building == Building.Mine || (building == Building.PlanetaryInstitute && want.faction == Faction.Ivits)) &&
|
||||
!transdim.has(location)
|
||||
!transdim.has(key)
|
||||
) {
|
||||
return value(cmd, e.log, planet, location);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
"label": "Taklons",
|
||||
"total": 7
|
||||
},
|
||||
"Lantids (8)": {
|
||||
"Lantids (9)": {
|
||||
"label": "Lantids",
|
||||
"total": 8
|
||||
"total": 9
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -35,8 +35,8 @@
|
|||
"data": [0, 2, 3, 2, 4, 3]
|
||||
},
|
||||
{
|
||||
"label": "Lantids (8)",
|
||||
"data": [0, 0, 3, 0, 5, 0]
|
||||
"label": "Lantids (9)",
|
||||
"data": [0, 1, 3, 0, 5, 0]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (7)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue