fix: exclude shared Lantids mines from protoplanet bonus

This commit is contained in:
coyotte508 2026-10-29 21:15:05 +01:00
commit 8b648fcce1
5 changed files with 62 additions and 5 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/engine",
"version": "4.17.1",
"version": "4.17.2",
"description": "Javascript engine for project gaia",
"main": "dist/index.js",
"types": "index.ts",

View file

@ -1,13 +1,70 @@
import { expect } from "chai";
import Engine from "../engine";
import { Building, Command, Expansion, Faction, Operator, Planet, Player as PlayerEnum, Resource } from "../enums";
import {
Building,
Command,
Expansion,
Faction,
Operator,
Phase,
Planet,
Player as PlayerEnum,
Resource,
ScoringTile,
} from "../enums";
import SpaceMap from "../map";
import Player from "../player";
import { Power } from "../player-data";
import { roundScoringEvents } from "../tiles/scoring";
const parseMoves = Engine.parseMoves;
describe("Lantids", () => {
for (const shared of [true, false]) {
it(`should ${shared ? "not grant" : "grant"} the 6 VP bonus when ${shared ? "sharing" : "colonizing"} a protoplanet`, () => {
const engine = new Engine(["init 4 lantids-protoplanet-bonus"], { lostFleet: true });
const factions = [Faction.Lantids, Faction.Geodens, Faction.Xenos, Faction.Darkanians];
engine.players.forEach((player, seat) => {
player.faction = factions[seat];
player.loadFaction(null, engine.expansions);
});
engine.phase = Phase.RoundMove;
engine.round = 3;
engine.turnOrder = engine.players.map((player) => player.player);
engine.currentPlayer = PlayerEnum.Player1;
engine.clearAvailableCommands();
const player = engine.player(PlayerEnum.Player1);
const home = [...engine.map.grid.values()].find((hex) => hex.data.planet === Planet.Terra);
player.build(Building.Mine, home, [], engine.map);
player.data.buildings[Building.PlanetaryInstitute] = 1;
player.data.credits = 20;
player.data.ores = 20;
player.data.range = 99;
player.loadEvents(roundScoringEvents(ScoringTile.LfSector3, 3));
const target = [...engine.map.grid.values()].find(
(hex) => hex.data.planet === Planet.Protoplanet && hex.data.sector.startsWith("DS")
);
if (shared) {
engine.player(PlayerEnum.Player2).build(Building.Mine, target, [], engine.map);
}
const beforeVp = player.data.victoryPoints;
const beforeKnowledge = player.data.knowledge;
const command = engine.findAvailableCommand(PlayerEnum.Player1, Command.Build);
const build = command.data.buildings.find((entry) => entry.coordinates === target.toString());
expect(build.cost).to.equal(shared ? "2c,o" : "2c,10o,-6vp");
expect(build.steps).to.equal(shared ? 0 : 3);
engine.move(`lantids build m ${target.toString()}.`);
expect(player.data.victoryPoints - beforeVp).to.equal(shared ? 3 : 9);
expect(player.data.knowledge - beforeKnowledge).to.equal(shared ? 2 : 0);
expect(target.data.player).to.equal(shared ? PlayerEnum.Player2 : PlayerEnum.Player1);
expect(target.data.additionalMine).to.equal(shared ? PlayerEnum.Player1 : undefined);
});
}
it("should be able to build a mine on other players' planets", () => {
const moves = parseMoves(`
init 2 randomSeed

View file

@ -446,7 +446,7 @@ export default class Player extends EventEmitter {
addedCost.push(reward);
const scoredPlanet = hex?.data?.planet ?? targetPlanet;
if (scoredPlanet === Planet.Protoplanet) {
if (scoredPlanet === Planet.Protoplanet && !hex?.occupied()) {
addedCost.push(new Reward(-6, Resource.VictoryPoint));
} else if (targetPlanet === Planet.Asteroid) {
if (!this.data.hasResource(new Reward(1, Resource.GaiaFormer))) {

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/old-ui",
"version": "1.2.11",
"version": "1.2.12",
"scripts": {
"serve": "vite --port 5193",
"build": "vite build",

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/viewer",
"version": "5.22.11",
"version": "5.22.12",
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
"contributors": [
"coyotte508",