fix(stats): replay Lost Fleet resource income and bowl selections
This commit is contained in:
parent
8b07831dfe
commit
94db0ae68f
5 changed files with 66 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.2.32",
|
||||
"version": "1.2.33",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.22.32",
|
||||
"version": "5.22.33",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ export function balanceSheetEventSources(expansion: Expansion): BalanceSheetSour
|
|||
label: "Base",
|
||||
costResources: [],
|
||||
incomeResources: balanceSheetResources,
|
||||
eventSources: [Command.ChooseIncome],
|
||||
eventSources: [Command.ChooseIncome, ...(expansion & Expansion.LostFleet ? [Phase.RoundGaia] : [])],
|
||||
color: "--res-credit",
|
||||
},
|
||||
{
|
||||
label: "Faction abilities",
|
||||
costResources: [],
|
||||
incomeResources: [Resource.Knowledge],
|
||||
incomeResources: expansion & Expansion.LostFleet ? balanceSheetResources : [Resource.Knowledge],
|
||||
eventSources: Faction.values(expansion),
|
||||
color: "--volcanic",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import Engine, {
|
|||
Phase,
|
||||
Planet,
|
||||
PlayerEnum,
|
||||
PowerArea,
|
||||
Resource,
|
||||
Spaceship,
|
||||
SpaceshipTechTile,
|
||||
|
|
@ -65,6 +66,49 @@ function fixture() {
|
|||
const style = { type: "table" as const, label: "Table", compact: false };
|
||||
|
||||
describe("Lost Fleet board-action statistics", () => {
|
||||
it("replays explicit federation bowl choices without consuming other bowls or the brainstone", () => {
|
||||
const engine = fixture();
|
||||
engine.players[0].faction = Faction.Taklons;
|
||||
const simulator = newResourceSimulator(engine.players[0], engine.expansions);
|
||||
simulator.playerData.power = new Power(2, 2, 0, 0);
|
||||
simulator.playerData.brainstone = PowerArea.Area1;
|
||||
const commands = parseCommands("taklons federation 0x0 ship-fed-vp using area2: 2");
|
||||
simulator.simulateResources({
|
||||
cmd: commands[0],
|
||||
cmdIndex: 0,
|
||||
allCommands: commands,
|
||||
log: { player: PlayerEnum.Player1, changes: { [Command.FormFederation]: { [Resource.GainToken]: -2 } } },
|
||||
data: engine,
|
||||
source: null,
|
||||
});
|
||||
expect(simulator.playerData.power.area1).to.equal(2);
|
||||
expect(simulator.playerData.power.area2).to.equal(0);
|
||||
expect(simulator.playerData.brainstone).to.equal("area1");
|
||||
});
|
||||
|
||||
it("maps Lost Fleet faction income and Gaia-phase token returns in resource breakdowns", () => {
|
||||
const engine = fixture();
|
||||
engine.addAdvancedLog({
|
||||
round: 1,
|
||||
player: PlayerEnum.Player1,
|
||||
changes: {
|
||||
[Faction.Darkanians]: { [Resource.Credit]: 2, [Resource.Knowledge]: 1 },
|
||||
[Phase.RoundGaia]: { [Resource.GainToken]: 1 },
|
||||
},
|
||||
});
|
||||
const setup = new ChartSetup(engine);
|
||||
for (const resource of balanceSheetResources) {
|
||||
const factory = setup.factory(ChartGroup.resources, balanceSheetResourceName(resource));
|
||||
const result = setup.newBarChart(style, factory, engine, (c) => c);
|
||||
const dataset = result.chart.data.datasets.find((d) => d.label.startsWith("Terrans"));
|
||||
if (resource === Resource.Credit) {
|
||||
expect(dataset.data[result.chart.data.labels.indexOf("Faction abilities income")]).to.equal(2);
|
||||
}
|
||||
if (resource === Resource.GainToken) {
|
||||
expect(dataset.data[result.chart.data.labels.indexOf("Base income")]).to.equal(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
it("keeps base-game rows unchanged and gives all twelve ship actions distinct names and keys", () => {
|
||||
const base = boardActionSourceFactory(Expansion.None);
|
||||
const expanded = boardActionSourceFactory(Expansion.LostFleet);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
LogEntryChanges,
|
||||
Player,
|
||||
PlayerData,
|
||||
PowerArea,
|
||||
Resource,
|
||||
Reward,
|
||||
TechPos,
|
||||
|
|
@ -164,7 +165,23 @@ export function newResourceSimulator(want: Player, expansions: Expansion): Resou
|
|||
const powerUsage = parsePowerUsage(cmd);
|
||||
if (powerUsage) {
|
||||
const r = [new Reward(-sum(Object.values(powerUsage)), type)];
|
||||
gainRewards(source, r);
|
||||
if (expansions & Expansion.LostFleet) {
|
||||
// Replay the recorded bowl selection rather than discarding from the
|
||||
// lowest bowl again. Otherwise later ship costs and Taklons' brainstone
|
||||
// decisions diverge from the actual game.
|
||||
for (const area of [PowerArea.Area1, PowerArea.Area2, PowerArea.Area3]) {
|
||||
playerData.power[area] -= powerUsage[area];
|
||||
}
|
||||
if (type === Resource.MoveTokenToGaiaArea) {
|
||||
playerData.power.gaia += powerUsage.area1 + powerUsage.area2 + powerUsage.area3;
|
||||
}
|
||||
if (powerUsage.brainstone) {
|
||||
playerData.brainstone = type === Resource.MoveTokenToGaiaArea ? PowerArea.Gaia : null;
|
||||
}
|
||||
commandChanges[source] = Reward.merge(r.concat(commandChanges[source] ?? []));
|
||||
} else {
|
||||
gainRewards(source, r);
|
||||
}
|
||||
if (source) {
|
||||
addProcessedChange(r, source);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue