@gaia-project/engine
Advanced tools
Comparing version 4.8.25 to 4.8.26
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MAX_SATELLITES = exports.Power = exports.stdBuildingValue = exports.federations = exports.parseLocation = exports.finalRankings = exports.gainFinalScoringVictoryPoints = exports.researchTracks = exports.SpaceMap = exports.Reward = exports.tiles = exports.Event = exports.PlayerData = exports.Player = void 0; | ||
exports.MAX_SATELLITES = exports.Power = exports.stdBuildingValue = exports.federations = exports.parseLocation = exports.finalRankings = exports.gainFinalScoringVictoryPoints = exports.researchTracks = exports.SpaceMap = exports.Reward = exports.tiles = exports.Event = exports.PlayerData = exports.Player = exports.BuildWarning = void 0; | ||
const scoring_1 = require("./src/algorithms/scoring"); | ||
@@ -40,2 +40,3 @@ Object.defineProperty(exports, "finalRankings", { enumerable: true, get: function () { return scoring_1.finalRankings; } }); | ||
exports.Player = player_1.default; | ||
Object.defineProperty(exports, "BuildWarning", { enumerable: true, get: function () { return player_1.BuildWarning; } }); | ||
Object.defineProperty(exports, "MAX_SATELLITES", { enumerable: true, get: function () { return player_1.MAX_SATELLITES; } }); | ||
@@ -42,0 +43,0 @@ const player_data_1 = __importStar(require("./src/player-data")); |
{ | ||
"name": "@gaia-project/engine", | ||
"version": "4.8.25", | ||
"version": "4.8.26", | ||
"description": "Javascript engine for project gaia", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.choosableFactions = exports.possiblePISwaps = exports.possibleTechTiles = exports.canTakeAdvancedTechTile = exports.possibleFederationTiles = exports.possibleCoverTechTiles = exports.getTaklonsExtraLeechOffers = exports.possibleLeech = exports.possibleGaiaFreeActions = exports.possibleIncomes = exports.possibleFederations = exports.possibleRoundBoosters = exports.possibleSpaceLostPlanet = exports.possibleResearchAreas = exports.canResearchField = exports.possibleLabDowngrades = exports.transformToSpendCommand = exports.freeActionData = exports.possibleFreeActions = exports.possibleBoardActions = exports.possibleSpecialActions = exports.possibleMineBuildings = exports.possibleSpaceStations = exports.possibleShipMovements = exports.possibleBuildings = exports.shipsInHex = exports.generate = exports.conversionToFreeAction = exports.ShipAction = exports.Offer = exports.MAX_SHIPS_PER_HEX = exports.UPGRADE_RESEARCH_COST = void 0; | ||
exports.choosableFactions = exports.possiblePISwaps = exports.possibleTechTiles = exports.canTakeAdvancedTechTile = exports.possibleFederationTiles = exports.possibleCoverTechTiles = exports.getTaklonsExtraLeechOffers = exports.possibleLeech = exports.possibleGaiaFreeActions = exports.possibleIncomes = exports.possibleFederations = exports.possibleRoundBoosters = exports.possibleSpaceLostPlanet = exports.possibleResearchAreas = exports.canResearchField = exports.possibleLabDowngrades = exports.transformToSpendCommand = exports.freeActionData = exports.possibleFreeActions = exports.possibleBoardActions = exports.possibleSpecialActions = exports.possibleMineBuildings = exports.possibleSpaceStations = exports.possibleShipMovements = exports.possibleBuildings = exports.shipsInHex = exports.generate = exports.conversionToFreeAction = exports.ShipAction = exports.Offer = exports.BrainstoneWarning = exports.MAX_SHIPS_PER_HEX = exports.UPGRADE_RESEARCH_COST = void 0; | ||
const lodash_1 = require("lodash"); | ||
@@ -34,2 +34,3 @@ const actions_1 = require("./actions"); | ||
const factions_1 = require("./factions"); | ||
const player_1 = require("./player"); | ||
const player_data_1 = require("./player-data"); | ||
@@ -44,2 +45,6 @@ const researchTracks = __importStar(require("./research-tracks")); | ||
const SHIP_ACTION_RANGE = 1; | ||
var BrainstoneWarning; | ||
(function (BrainstoneWarning) { | ||
BrainstoneWarning["brainstoneChargesWasted"] = "brainstone-charges-wasted"; | ||
})(BrainstoneWarning = exports.BrainstoneWarning || (exports.BrainstoneWarning = {})); | ||
class Offer { | ||
@@ -168,3 +173,3 @@ constructor(offer, cost) { | ||
if (building === enums_1.Building.Mine && !pl.data.hasPlanetaryInstitute() && pl.data.isNewPlanetType(hex)) { | ||
check.warnings.push("geodens-build-without-PI"); | ||
check.warnings.push(player_1.BuildWarning.geodensBuildWithoutPi); | ||
} | ||
@@ -176,6 +181,6 @@ break; | ||
pl.maxBuildings(enums_1.Building.Mine) - 1) { | ||
check.warnings.push("lantids-deadlock"); | ||
check.warnings.push(player_1.BuildWarning.lantidsDeadlock); | ||
} | ||
if (!pl.data.hasPlanetaryInstitute()) { | ||
check.warnings.push("lantids-build-without-PI"); | ||
check.warnings.push(player_1.BuildWarning.lantidsBuildWithoutPi); | ||
} | ||
@@ -625,5 +630,17 @@ } | ||
exports.possibleRoundBoosters = possibleRoundBoosters; | ||
function federationWarnings(p, fed) { | ||
const ret = []; | ||
if (p.faction !== enums_1.Faction.Ivits && fed.newSatellites > p.data.power.area1) { | ||
ret.push(player_1.BuildWarning.federationWithChargedTokens); | ||
} | ||
if (p.faction === enums_1.Faction.Ambas && !fed.hexes.some((h) => h.buildingOf(p.player) === enums_1.Building.PlanetaryInstitute)) { | ||
ret.push(player_1.BuildWarning.ambasFederationWithoutPi); | ||
} | ||
return ret; | ||
} | ||
function possibleFederations(engine, player) { | ||
const commands = []; | ||
const possibleTiles = Object.keys(engine.tiles.federations).filter((key) => engine.tiles.federations[key] > 0); | ||
const commands = Array(); | ||
const possibleTiles = Object.keys(engine.tiles.federations) | ||
.filter((key) => engine.tiles.federations[key] > 0) | ||
.map((f) => f); | ||
if (possibleTiles.length > 0) { | ||
@@ -655,5 +672,3 @@ if (engine.options.noFedCheck || engine.replay) { | ||
.join(","), | ||
warning: p.faction !== enums_1.Faction.Ivits && fed.newSatellites > p.data.power.area1 | ||
? "federation-with-charged-tokens" | ||
: null, | ||
warnings: federationWarnings(p, fed), | ||
})), | ||
@@ -823,2 +838,3 @@ }, | ||
coordinates: hex.toString(), | ||
warnings: hex.belongsToFederationOf(player) ? [player_1.BuildWarning.ambasSwapIntoFederation] : null, | ||
}); | ||
@@ -825,0 +841,0 @@ } |
@@ -8,2 +8,3 @@ "use strict"; | ||
const enums_1 = require("./enums"); | ||
const player_1 = require("./player"); | ||
const reward_1 = __importDefault(require("./reward")); | ||
@@ -43,3 +44,3 @@ const TERRAFORMING_COST = 3; | ||
distance: d, | ||
warning: qicWithGaiaFormer < qicNeeded ? "gaia-former-would-extend-range" : null, | ||
warning: qicWithGaiaFormer < qicNeeded ? player_1.BuildWarning.gaiaFormerWouldExtendRange : null, | ||
}; | ||
@@ -46,0 +47,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const lodash_1 = require("lodash"); | ||
const available_command_1 = require("./available-command"); | ||
const enums_1 = require("./enums"); | ||
@@ -357,3 +358,3 @@ const reward_1 = __importDefault(require("./reward")); | ||
let useBrainStone = true; | ||
const warning = power < 3 ? "brainstone-charges-wasted" : undefined; | ||
const warning = power < 3 ? available_command_1.BrainstoneWarning.brainstoneChargesWasted : undefined; | ||
// Choose whether to spend the brainstone power or not | ||
@@ -360,0 +361,0 @@ const needBrainstone = this.power.area3 < power; |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Settings = exports.defaultAutoCharge = exports.MAX_SATELLITES = void 0; | ||
exports.BuildWarning = exports.Settings = exports.defaultAutoCharge = exports.MAX_SATELLITES = void 0; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -62,2 +62,20 @@ const eventemitter3_1 = require("eventemitter3"); | ||
exports.Settings = Settings; | ||
var BuildWarning; | ||
(function (BuildWarning) { | ||
BuildWarning["stepBoosterNotUsed"] = "step-booster-not-used"; | ||
BuildWarning["rangeBoosterNotUsed"] = "range-booster-not-used"; | ||
BuildWarning["stepActionPartiallyWasted"] = "step-action-partially-wasted"; | ||
BuildWarning["expensiveTerraforming"] = "expensive-terraforming"; | ||
BuildWarning["gaiaFormingWithChargedTokens"] = "gaia-forming-with-charged-tokens"; | ||
BuildWarning["federationWithChargedTokens"] = "federation-with-charged-tokens"; | ||
BuildWarning["lantidsDeadlock"] = "lantids-deadlock"; | ||
BuildWarning["lantidsBuildWithoutPi"] = "lantids-build-without-PI"; | ||
BuildWarning["geodensBuildWithoutPi"] = "geodens-build-without-PI"; | ||
BuildWarning["expensiveTradingStation"] = "expensive-trade-station"; | ||
BuildWarning["gaiaFormerWouldExtendRange"] = "gaia-former-would-extend-range"; | ||
BuildWarning["gaiaFormerLastRound"] = "gaia-former-last-round"; | ||
BuildWarning["buildingWillBePartOfFederation"] = "building-will-be-part-of-federation"; | ||
BuildWarning["ambasFederationWithoutPi"] = "ambas-federation-without-PI"; | ||
BuildWarning["ambasSwapIntoFederation"] = "ambas-swap-into-federation"; | ||
})(BuildWarning = exports.BuildWarning || (exports.BuildWarning = {})); | ||
class Player extends eventemitter3_1.EventEmitter { | ||
@@ -215,3 +233,3 @@ constructor(player = enums_1.Player.Player1) { | ||
!buildActionUsed) { | ||
warnings.push("range-booster-not-used"); | ||
warnings.push(BuildWarning.rangeBoosterNotUsed); | ||
} | ||
@@ -247,9 +265,9 @@ let steps = 0; | ||
if (steps > 0 && this.hasActiveBooster(enums_1.Resource.TemporaryStep) && !buildActionUsed) { | ||
warnings.push("step-booster-not-used"); | ||
warnings.push(BuildWarning.stepBoosterNotUsed); | ||
} | ||
if (reward.count > 0 && this.data.terraformCostDiscount < 2) { | ||
warnings.push("expensive-terraforming"); | ||
warnings.push(BuildWarning.expensiveTerraforming); | ||
} | ||
if (this.data.temporaryStep > steps) { | ||
warnings.push("step-action-partially-wasted"); | ||
warnings.push(BuildWarning.stepActionPartiallyWasted); | ||
} | ||
@@ -263,10 +281,10 @@ addedCost.push(reward); | ||
creditCost(cost) === creditCost(this.board.buildings[enums_1.Building.TradingStation].isolatedCost)) { | ||
warnings.push("expensive-trade-station"); | ||
warnings.push(BuildWarning.expensiveTradingStation); | ||
} | ||
const toGaia = cost.find((r) => r.type === enums_1.Resource.MoveTokenToGaiaArea); | ||
if ((toGaia === null || toGaia === void 0 ? void 0 : toGaia.count) > this.data.power.area1) { | ||
warnings.push("gaia-forming-with-charged-tokens"); | ||
warnings.push(BuildWarning.gaiaFormingWithChargedTokens); | ||
} | ||
if (building === enums_1.Building.GaiaFormer && lastRound) { | ||
warnings.push("gaia-former-last-round"); | ||
warnings.push(BuildWarning.gaiaFormerLastRound); | ||
} | ||
@@ -276,3 +294,3 @@ if (hex && this.faction !== enums_1.Faction.Ivits) { | ||
if (h.belongsToFederationOf(this.player)) { | ||
warnings.push("building-will-be-part-of-federation"); | ||
warnings.push(BuildWarning.buildingWillBePartOfFederation); | ||
break; | ||
@@ -279,0 +297,0 @@ } |
{ | ||
"name": "@gaia-project/engine", | ||
"version": "4.8.25", | ||
"version": "4.8.26", | ||
"description": "Javascript engine for project gaia", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -37,2 +37,3 @@ import { difference, range, uniq } from "lodash"; | ||
import { remainingFactions } from "./factions"; | ||
import { FederationInfo } from "./federation"; | ||
import { GaiaHex } from "./gaia-hex"; | ||
@@ -52,3 +53,5 @@ import SpaceMap from "./map"; | ||
export type BrainstoneWarning = "brainstone-charges-wasted"; | ||
export enum BrainstoneWarning { | ||
brainstoneChargesWasted = "brainstone-charges-wasted", | ||
} | ||
@@ -127,3 +130,3 @@ export type BrainstoneActionData = { | ||
export type AvailableFederation = { hexes: string; warning?: string }; | ||
export type AvailableFederation = { hexes: string; warnings: BuildWarning[] }; | ||
@@ -324,3 +327,3 @@ export enum ShipAction { | ||
if (building === Building.Mine && !pl.data.hasPlanetaryInstitute() && pl.data.isNewPlanetType(hex)) { | ||
check.warnings.push("geodens-build-without-PI"); | ||
check.warnings.push(BuildWarning.geodensBuildWithoutPi); | ||
} | ||
@@ -334,6 +337,6 @@ break; | ||
) { | ||
check.warnings.push("lantids-deadlock"); | ||
check.warnings.push(BuildWarning.lantidsDeadlock); | ||
} | ||
if (!pl.data.hasPlanetaryInstitute()) { | ||
check.warnings.push("lantids-build-without-PI"); | ||
check.warnings.push(BuildWarning.lantidsBuildWithoutPi); | ||
} | ||
@@ -858,6 +861,19 @@ } | ||
export function possibleFederations(engine: Engine, player: Player) { | ||
const commands = []; | ||
const possibleTiles = Object.keys(engine.tiles.federations).filter((key) => engine.tiles.federations[key] > 0); | ||
function federationWarnings(p: PlayerObject, fed: FederationInfo): BuildWarning[] { | ||
const ret: BuildWarning[] = []; | ||
if (p.faction !== Faction.Ivits && fed.newSatellites > p.data.power.area1) { | ||
ret.push(BuildWarning.federationWithChargedTokens); | ||
} | ||
if (p.faction === Faction.Ambas && !fed.hexes.some((h) => h.buildingOf(p.player) === Building.PlanetaryInstitute)) { | ||
ret.push(BuildWarning.ambasFederationWithoutPi); | ||
} | ||
return ret; | ||
} | ||
export function possibleFederations(engine: Engine, player: Player): AvailableCommand<Command.FormFederation>[] { | ||
const commands = Array<AvailableCommand<Command.FormFederation>>(); | ||
const possibleTiles: Federation[] = Object.keys(engine.tiles.federations) | ||
.filter((key) => engine.tiles.federations[key] > 0) | ||
.map((f) => f as Federation); | ||
if (possibleTiles.length > 0) { | ||
@@ -889,6 +905,3 @@ if (engine.options.noFedCheck || engine.replay) { | ||
.join(","), | ||
warning: | ||
p.faction !== Faction.Ivits && fed.newSatellites > p.data.power.area1 | ||
? "federation-with-charged-tokens" | ||
: null, | ||
warnings: federationWarnings(p, fed), | ||
})), | ||
@@ -1088,2 +1101,3 @@ }, | ||
coordinates: hex.toString(), | ||
warnings: hex.belongsToFederationOf(player) ? [BuildWarning.ambasSwapIntoFederation] : null, | ||
}); | ||
@@ -1090,0 +1104,0 @@ } |
import { expect } from "chai"; | ||
import { PlayerEnum } from "../index"; | ||
import { BuildWarning, PlayerEnum } from "../index"; | ||
import { qicForDistance, QicNeeded, terraformingCost } from "./cost"; | ||
@@ -25,3 +25,3 @@ import { Building, Resource } from "./enums"; | ||
give: { location: "5A2", range: 1, temporaryRange: 0 }, | ||
want: { distance: 5, amount: 2, warning: "gaia-former-would-extend-range" }, | ||
want: { distance: 5, amount: 2, warning: BuildWarning.gaiaFormerWouldExtendRange }, | ||
}, | ||
@@ -28,0 +28,0 @@ { |
@@ -54,4 +54,4 @@ import { Resource } from "./enums"; | ||
distance: d, | ||
warning: qicWithGaiaFormer < qicNeeded ? "gaia-former-would-extend-range" : null, | ||
warning: qicWithGaiaFormer < qicNeeded ? BuildWarning.gaiaFormerWouldExtendRange : null, | ||
}; | ||
} |
import { AssertionError } from "assert"; | ||
import { expect } from "chai"; | ||
import { BoardAction, Booster, Building, PlayerEnum } from ".."; | ||
import { BoardAction, Booster, Building, Player } from ".."; | ||
import { version } from "../package.json"; | ||
import Engine, { AuctionVariant, createMoveToShow } from "./engine"; | ||
import { Command, Condition, Faction, Operator, Phase, Planet, Player } from "./enums"; | ||
import { Command, Condition, Faction, Operator, Phase, Planet, Player as PlayerEnum } from "./enums"; | ||
import PlayerData, { MoveTokens } from "./player-data"; | ||
@@ -188,7 +188,7 @@ | ||
const qic = engine.player(Player.Player1).data.qics; | ||
const qic = engine.player(PlayerEnum.Player1).data.qics; | ||
engine.move("p1 build m -5x0"); | ||
expect(engine.player(Player.Player1).data.qics).to.equal(qic); | ||
expect(engine.player(PlayerEnum.Player1).data.qics).to.equal(qic); | ||
}); | ||
@@ -215,7 +215,7 @@ | ||
const qicCount = engine.player(Player.Player1).data.qics; | ||
const qicCount = engine.player(PlayerEnum.Player1).data.qics; | ||
engine.move("p1 build m -3x1"); | ||
expect(engine.player(Player.Player1).data.qics).to.equal( | ||
expect(engine.player(PlayerEnum.Player1).data.qics).to.equal( | ||
qicCount, | ||
@@ -276,4 +276,4 @@ "Building a mine from a gaia former doest NOT need a qic" | ||
expect(engine.player(Player.Player1).data.victoryPoints).to.equal(130); | ||
expect(engine.player(Player.Player2).data.victoryPoints).to.equal(124); | ||
expect(engine.player(PlayerEnum.Player1).data.victoryPoints).to.equal(130); | ||
expect(engine.player(PlayerEnum.Player2).data.victoryPoints).to.equal(124); | ||
}); | ||
@@ -299,16 +299,16 @@ | ||
expect(state.players[Player.Player1].data.knowledge).to.equal( | ||
baseLine.players[Player.Player1].data.knowledge, | ||
expect(state.players[PlayerEnum.Player1].data.knowledge).to.equal( | ||
baseLine.players[PlayerEnum.Player1].data.knowledge, | ||
"Error loading move " + move | ||
); | ||
expect(state.players[Player.Player2].income).to.equal( | ||
baseLine.players[Player.Player2].toJSON().income, | ||
expect(state.players[PlayerEnum.Player2].income).to.equal( | ||
baseLine.players[PlayerEnum.Player2].toJSON().income, | ||
"Error loading move " + move | ||
); | ||
expect(state.players[Player.Player2].events[Operator.Income].length).to.equal( | ||
baseLine.players[Player.Player2].events[Operator.Income].length, | ||
expect(state.players[PlayerEnum.Player2].events[Operator.Income].length).to.equal( | ||
baseLine.players[PlayerEnum.Player2].events[Operator.Income].length, | ||
"Error loading move " + move | ||
); | ||
expect(state.players[Player.Player2].data.ores).to.equal( | ||
baseLine.players[Player.Player2].data.ores, | ||
expect(state.players[PlayerEnum.Player2].data.ores).to.equal( | ||
baseLine.players[PlayerEnum.Player2].data.ores, | ||
"Error loading move " + move | ||
@@ -320,7 +320,7 @@ ); | ||
const endEngine = Engine.fromData(state); | ||
expect(endEngine.player(Player.Player1).data.victoryPoints).to.equal( | ||
baseLine.player(Player.Player1).data.victoryPoints | ||
expect(endEngine.player(PlayerEnum.Player1).data.victoryPoints).to.equal( | ||
baseLine.player(PlayerEnum.Player1).data.victoryPoints | ||
); | ||
expect(endEngine.player(Player.Player2).data.victoryPoints).to.equal( | ||
baseLine.player(Player.Player2).data.victoryPoints | ||
expect(endEngine.player(PlayerEnum.Player2).data.victoryPoints).to.equal( | ||
baseLine.player(PlayerEnum.Player2).data.victoryPoints | ||
); | ||
@@ -331,7 +331,7 @@ | ||
baseLine.move(lastMove); | ||
expect(endEngine.player(Player.Player1).data.victoryPoints).to.equal( | ||
baseLine.player(Player.Player1).data.victoryPoints | ||
expect(endEngine.player(PlayerEnum.Player1).data.victoryPoints).to.equal( | ||
baseLine.player(PlayerEnum.Player1).data.victoryPoints | ||
); | ||
expect(endEngine.player(Player.Player2).data.victoryPoints).to.equal( | ||
baseLine.player(Player.Player2).data.victoryPoints | ||
expect(endEngine.player(PlayerEnum.Player2).data.victoryPoints).to.equal( | ||
baseLine.player(PlayerEnum.Player2).data.victoryPoints | ||
); | ||
@@ -367,3 +367,3 @@ }); | ||
give: false, | ||
want: Player.Player5, | ||
want: PlayerEnum.Player5, | ||
}, | ||
@@ -510,5 +510,5 @@ ]; | ||
const engine = new Engine(moves); | ||
const structure = engine.player(Player.Player1).eventConditionCount(Condition.StructureFed); | ||
const structure = engine.player(PlayerEnum.Player1).eventConditionCount(Condition.StructureFed); | ||
engine.move("terrans action power2. build m -5x5."); | ||
expect(engine.player(Player.Player1).eventConditionCount(Condition.StructureFed)).to.be.equal(structure + 1); | ||
expect(engine.player(PlayerEnum.Player1).eventConditionCount(Condition.StructureFed)).to.be.equal(structure + 1); | ||
}); | ||
@@ -568,6 +568,6 @@ | ||
const engine = new Engine(moves); | ||
const vps = engine.player(Player.Player1).data.victoryPoints; | ||
const vps = engine.player(PlayerEnum.Player1).data.victoryPoints; | ||
engine.move("nevlas action power6. build m -1x3."); | ||
expect(engine.player(Player.Player1).data.victoryPoints).to.be.equal(vps + 2); | ||
expect(engine.player(Player.Player1).data.temporaryStep).to.be.equal(0); | ||
expect(engine.player(PlayerEnum.Player1).data.victoryPoints).to.be.equal(vps + 2); | ||
expect(engine.player(PlayerEnum.Player1).data.temporaryStep).to.be.equal(0); | ||
}); | ||
@@ -622,3 +622,3 @@ | ||
engine.generateAvailableCommandsIfNeeded(); | ||
engine.player(Player.Player1).settings.autoChargePower = 2; | ||
engine.player(PlayerEnum.Player1).settings.autoChargePower = 2; | ||
@@ -838,3 +838,3 @@ expect(autoCharge(engine)).to.equal("charge 2pw"); | ||
d.research.terra = 4; | ||
return createMoveToShow(give, d, () => { | ||
return createMoveToShow(give, { data: d } as Player, null, () => { | ||
if (give.includes(Building.GaiaFormer)) { | ||
@@ -841,0 +841,0 @@ d.emit("move-tokens", { area1: 1, area2: 2, area3: 3, brainstone: 1 } as MoveTokens); |
@@ -48,3 +48,3 @@ import assert from "assert"; | ||
import Player from "./player"; | ||
import PlayerData, { BrainstoneDest, MoveTokens, powerLogString } from "./player-data"; | ||
import { BrainstoneDest, MoveTokens, powerLogString } from "./player-data"; | ||
import * as researchTracks from "./research-tracks"; | ||
@@ -66,3 +66,3 @@ import Reward from "./reward"; | ||
const LEECHING_DISTANCE = 2; | ||
export const LEECHING_DISTANCE = 2; | ||
@@ -142,3 +142,3 @@ export enum AuctionVariant { | ||
const replaceRegex = new RegExp( | ||
`\\b((${Command.Pass}|${Building.GaiaFormer}|${Command.FormFederation} [^ ]+|${Command.UpgradeResearch}) ?([^. ]+)?)(\\.|$)`, | ||
`\\b((${Command.Pass}|${Command.PISwap}|${Building.GaiaFormer}|${Command.FormFederation} [^ ]+|${Command.UpgradeResearch}) ?([^. ]+)?)(\\.|$)`, | ||
"g" | ||
@@ -151,16 +151,22 @@ ); | ||
export function createMoveToShow(move: string, p: PlayerData, executeMove: () => void): string { | ||
export function createMoveToShow(move: string, player: Player, map: SpaceMap, executeMove: () => void): string { | ||
let moveToGaia: MoveTokens = null; | ||
const data = player.data; | ||
const oldPower = powerLogString(p.power, p.brainstone); | ||
const oldPower = powerLogString(data.power, data.brainstone); | ||
const listener = (event: MoveTokens) => (moveToGaia = event); | ||
const formerBooster = p.tiles.booster; | ||
const formerBooster = data.tiles.booster; | ||
p.on("move-tokens", listener); | ||
const formerPI = | ||
player.faction === Faction.Ambas && move.includes(Command.PISwap) | ||
? [...map.grid.values()].find((h) => h.buildingOf(player.player) === Building.PlanetaryInstitute) | ||
: null; | ||
data.on("move-tokens", listener); | ||
try { | ||
executeMove(); | ||
} finally { | ||
p.off("move-tokens", listener); | ||
data.off("move-tokens", listener); | ||
} | ||
@@ -184,4 +190,6 @@ | ||
return `${moveWithoutEnding} returning ${formerBooster}${moveEnding}`; | ||
case Command.PISwap: | ||
return `${moveWithoutEnding} (from ${formerPI.toString()})${moveEnding}`; | ||
case Command.UpgradeResearch: { | ||
const level = p.research[commandArgument]; | ||
const level = data.research[commandArgument]; | ||
if (!level) { | ||
@@ -200,3 +208,3 @@ //decline up | ||
const newPower = powerLogString(p.power, p.brainstone); | ||
const newPower = powerLogString(data.power, data.brainstone); | ||
@@ -379,3 +387,3 @@ if (oldPower !== newPower) { | ||
this.log(this.playerToMove, undefined, 0, undefined); | ||
moveToShow = createMoveToShow(move, this.player(this.playerToMove).data, execute); | ||
moveToShow = createMoveToShow(move, this.player(this.playerToMove), this.map, execute); | ||
} else { | ||
@@ -382,0 +390,0 @@ execute(); |
import { expect } from "chai"; | ||
import { BrainstoneWarning } from "../available-command"; | ||
import Engine from "../engine"; | ||
@@ -74,3 +75,3 @@ import { Player, PowerArea } from "../enums"; | ||
area: "area1", | ||
warning: "brainstone-charges-wasted", | ||
warning: BrainstoneWarning.brainstoneChargesWasted, | ||
}, | ||
@@ -77,0 +78,0 @@ ], |
@@ -432,3 +432,3 @@ import { EventEmitter } from "eventemitter3"; | ||
let useBrainStone = true; | ||
const warning: BrainstoneWarning = power < 3 ? "brainstone-charges-wasted" : undefined; | ||
const warning: BrainstoneWarning = power < 3 ? BrainstoneWarning.brainstoneChargesWasted : undefined; | ||
// Choose whether to spend the brainstone power or not | ||
@@ -435,0 +435,0 @@ const needBrainstone = this.power.area3 < power; |
@@ -79,16 +79,19 @@ import assert from "assert"; | ||
export type BuildWarning = | ||
| "step-booster-not-used" | ||
| "range-booster-not-used" | ||
| "step-action-partially-wasted" | ||
| "expensive-terraforming" | ||
| "gaia-forming-with-charged-tokens" | ||
| "federation-with-charged-tokens" | ||
| "lantids-deadlock" | ||
| "lantids-build-without-PI" | ||
| "geodens-build-without-PI" | ||
| "expensive-trade-station" | ||
| "gaia-former-would-extend-range" | ||
| "gaia-former-last-round" | ||
| "building-will-be-part-of-federation"; | ||
export enum BuildWarning { | ||
stepBoosterNotUsed = "step-booster-not-used", | ||
rangeBoosterNotUsed = "range-booster-not-used", | ||
stepActionPartiallyWasted = "step-action-partially-wasted", | ||
expensiveTerraforming = "expensive-terraforming", | ||
gaiaFormingWithChargedTokens = "gaia-forming-with-charged-tokens", | ||
federationWithChargedTokens = "federation-with-charged-tokens", | ||
lantidsDeadlock = "lantids-deadlock", | ||
lantidsBuildWithoutPi = "lantids-build-without-PI", | ||
geodensBuildWithoutPi = "geodens-build-without-PI", | ||
expensiveTradingStation = "expensive-trade-station", | ||
gaiaFormerWouldExtendRange = "gaia-former-would-extend-range", | ||
gaiaFormerLastRound = "gaia-former-last-round", | ||
buildingWillBePartOfFederation = "building-will-be-part-of-federation", | ||
ambasFederationWithoutPi = "ambas-federation-without-PI", | ||
ambasSwapIntoFederation = "ambas-swap-into-federation", | ||
} | ||
@@ -307,3 +310,3 @@ export type BuildCheck = { cost: Reward[]; steps: number; warnings: BuildWarning[] }; | ||
) { | ||
warnings.push("range-booster-not-used"); | ||
warnings.push(BuildWarning.rangeBoosterNotUsed); | ||
} | ||
@@ -341,9 +344,9 @@ | ||
if (steps > 0 && this.hasActiveBooster(Resource.TemporaryStep) && !buildActionUsed) { | ||
warnings.push("step-booster-not-used"); | ||
warnings.push(BuildWarning.stepBoosterNotUsed); | ||
} | ||
if (reward.count > 0 && this.data.terraformCostDiscount < 2) { | ||
warnings.push("expensive-terraforming"); | ||
warnings.push(BuildWarning.expensiveTerraforming); | ||
} | ||
if (this.data.temporaryStep > steps) { | ||
warnings.push("step-action-partially-wasted"); | ||
warnings.push(BuildWarning.stepActionPartiallyWasted); | ||
} | ||
@@ -360,3 +363,3 @@ addedCost.push(reward); | ||
) { | ||
warnings.push("expensive-trade-station"); | ||
warnings.push(BuildWarning.expensiveTradingStation); | ||
} | ||
@@ -366,6 +369,6 @@ | ||
if (toGaia?.count > this.data.power.area1) { | ||
warnings.push("gaia-forming-with-charged-tokens"); | ||
warnings.push(BuildWarning.gaiaFormingWithChargedTokens); | ||
} | ||
if (building === Building.GaiaFormer && lastRound) { | ||
warnings.push("gaia-former-last-round"); | ||
warnings.push(BuildWarning.gaiaFormerLastRound); | ||
} | ||
@@ -375,3 +378,3 @@ if (hex && this.faction !== Faction.Ivits) { | ||
if (h.belongsToFederationOf(this.player)) { | ||
warnings.push("building-will-be-part-of-federation"); | ||
warnings.push(BuildWarning.buildingWillBePartOfFederation); | ||
break; | ||
@@ -378,0 +381,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1079703
22388