✨ (viewer) show implicit research from tech tiles
This commit is contained in:
parent
4793afa464
commit
67d2abcdd4
9 changed files with 79 additions and 58 deletions
|
|
@ -31,7 +31,7 @@ export function generate(engine: Engine, subPhase: SubPhase = null, data?: any):
|
|||
case SubPhase.CoverTechTile:
|
||||
return possibleCoverTechTiles(engine, player);
|
||||
case SubPhase.UpgradeResearch:
|
||||
return possibleResearchAreas(engine, player, "", data);
|
||||
return possibleResearchAreas(engine, player, null, data);
|
||||
case SubPhase.PlaceLostPlanet:
|
||||
return possibleSpaceLostPlanet(engine, player);
|
||||
case SubPhase.ChooseFederationTile:
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ export function canResearchField(engine: Engine, player: PlayerObject, field: Re
|
|||
return player.canUpgradeResearch(field);
|
||||
}
|
||||
|
||||
export function possibleResearchAreas(engine: Engine, player: Player, cost?: string, data?: any) {
|
||||
export function possibleResearchAreas(engine: Engine, player: Player, cost: Reward | null, data?: any) {
|
||||
const commands = [];
|
||||
const tracks: AvailableResearchTrack[] = [];
|
||||
const pl = engine.player(player);
|
||||
const fields = ResearchField.values(engine.expansions);
|
||||
|
||||
if (pl.data.canPay(Reward.parse(cost))) {
|
||||
if (cost === null || pl.data.canPay([cost])) {
|
||||
let avFields: ResearchField[] = fields;
|
||||
|
||||
if (data) {
|
||||
|
|
@ -39,7 +39,7 @@ export function possibleResearchAreas(engine: Engine, player: Player, cost?: str
|
|||
tracks.push({
|
||||
field,
|
||||
to: pl.data.research[field] + 1,
|
||||
cost,
|
||||
cost: cost?.toString() ?? "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,18 @@ import {
|
|||
Faction,
|
||||
Federation,
|
||||
ResearchField,
|
||||
Resource,
|
||||
SubPhase,
|
||||
TechTile,
|
||||
TechTilePos,
|
||||
} from "../enums";
|
||||
import { BuildWarning } from "../player";
|
||||
import { BrainstoneDest } from "../player-data";
|
||||
import Reward from "../reward";
|
||||
import { AvailableSetupOption } from "../setup";
|
||||
|
||||
export const ISOLATED_DISTANCE = 3;
|
||||
export const UPGRADE_RESEARCH_COST = "4k";
|
||||
export const UPGRADE_RESEARCH_COST = new Reward(4, Resource.Knowledge);
|
||||
|
||||
export enum BrainstoneWarning {
|
||||
brainstoneChargesWasted = "brainstone-charges-wasted",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
TechPos,
|
||||
TechTile,
|
||||
} from "@gaia-project/engine";
|
||||
import { UPGRADE_RESEARCH_COST } from "@gaia-project/engine/src/available/types";
|
||||
import { tradeCostSource, tradeSource } from "@gaia-project/engine/src/events";
|
||||
import { boosterEvents } from "@gaia-project/engine/src/tiles/boosters";
|
||||
import { federationRewards } from "@gaia-project/engine/src/tiles/federations";
|
||||
|
|
@ -99,6 +100,7 @@ export function balanceSheetEventSources(expansion: Expansion): BalanceSheetSour
|
|||
},
|
||||
{
|
||||
label: "Tech Tiles",
|
||||
description: "Tech Tiles income, including the free 4k for the free research step when gained",
|
||||
costResources: [],
|
||||
incomeResources: rewardTypes(
|
||||
(TechTile.values(expansion) as (TechTile | AdvTechTile)[])
|
||||
|
|
@ -236,13 +238,14 @@ function resourceChanges<Source>(
|
|||
wantResource: Resource,
|
||||
faction: Faction,
|
||||
eventSources: BalanceSheetSourceType[],
|
||||
matchesEventSource: (s: Source, e: EventSource, reward: Reward) => number
|
||||
matchesEventSource: (s: Source, e: BalanceSheetSourceType, reward: Reward) => number
|
||||
): number {
|
||||
return sum(
|
||||
Object.entries(changes).flatMap((c) => {
|
||||
const eventSource = c[0] as EventSource;
|
||||
return c[1].map((reward) => {
|
||||
const r = effectiveAmount(reward, wantResource, faction);
|
||||
|
||||
if (r == null || Math.abs(r.count) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -303,7 +306,7 @@ function currentAmount(data: PlayerData, wantResource: Resource): number {
|
|||
export function balanceSheetExtractLog<Source>(
|
||||
getWantResource: (s: Source) => Resource,
|
||||
getSources: (s: Source) => BalanceSheetSourceType[],
|
||||
matchesEventSource: (s: Source, e: EventSource, reward: Reward) => number
|
||||
matchesEventSource: (s: Source, e: BalanceSheetSourceType, reward: Reward) => number
|
||||
): ExtractLog<any> {
|
||||
return resourceCounter((want, a, data, simulateResources) => {
|
||||
const wantResource = getWantResource(a.source);
|
||||
|
|
@ -337,6 +340,18 @@ export function balanceSheetExtractLog<Source>(
|
|||
old += leverage;
|
||||
}
|
||||
|
||||
const implicitResearchCost =
|
||||
wantResource == Resource.Knowledge &&
|
||||
a.cmd?.command == Command.ChooseTechTile &&
|
||||
(matchesEventSource(a.source, `tech-${a.cmd.args[0]}` as TechPos, UPGRADE_RESEARCH_COST) ||
|
||||
matchesEventSource(
|
||||
a.source,
|
||||
a.allCommands.some((c) => c.command == Command.Decline) ? waste : Command.UpgradeResearch,
|
||||
Reward.negative([UPGRADE_RESEARCH_COST])[0]
|
||||
))
|
||||
? UPGRADE_RESEARCH_COST.count
|
||||
: 0;
|
||||
|
||||
const faction = want.faction;
|
||||
const isTerranCharge = faction == Faction.Terrans && a.cmd != null && isGaiaMove([a.cmd]);
|
||||
if (eventSources.includes(waste) && !isTerranCharge) {
|
||||
|
|
@ -349,6 +364,7 @@ export function balanceSheetExtractLog<Source>(
|
|||
) * (payPower ? 2 : 1);
|
||||
|
||||
const waste = gain - diff;
|
||||
|
||||
if (waste < 0) {
|
||||
throw Error(
|
||||
`negative waste in ${JSON.stringify(a.log)}: cmd=${JSON.stringify(
|
||||
|
|
@ -358,9 +374,11 @@ export function balanceSheetExtractLog<Source>(
|
|||
)}`
|
||||
);
|
||||
}
|
||||
return waste;
|
||||
return waste + implicitResearchCost;
|
||||
}
|
||||
return resourceChanges(changes, a.source, wantResource, faction, eventSources, matchesEventSource);
|
||||
return (
|
||||
resourceChanges(changes, a.source, wantResource, faction, eventSources, matchesEventSource) + implicitResearchCost
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@ describe("Chart", () => {
|
|||
},
|
||||
setup.factory(i > 0 ? fullType.substring(0, i) : fullType, i > 1 ? fullType.substring(i + 1) : null),
|
||||
engine,
|
||||
null
|
||||
(c) => c
|
||||
);
|
||||
delete config.table.descriptions;
|
||||
return {
|
||||
tableMeta: config.table,
|
||||
labels: config.chart.data.labels,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
"--res-qic"
|
||||
],
|
||||
"datasetMeta": {
|
||||
"Itars (10)": {
|
||||
"Itars (18)": {
|
||||
"label": "Itars",
|
||||
"income": 10,
|
||||
"cost": -8,
|
||||
"income": 18,
|
||||
"cost": -16,
|
||||
"balance": 2
|
||||
},
|
||||
"Geoden (12)": {
|
||||
|
|
@ -29,10 +29,10 @@
|
|||
"cost": -4,
|
||||
"balance": 8
|
||||
},
|
||||
"Taklons (8)": {
|
||||
"Taklons (16)": {
|
||||
"label": "Taklons",
|
||||
"income": 8,
|
||||
"cost": -4,
|
||||
"income": 16,
|
||||
"cost": -12,
|
||||
"balance": 4
|
||||
},
|
||||
"Lantids (13)": {
|
||||
|
|
@ -59,21 +59,21 @@
|
|||
"Waste cost"
|
||||
],
|
||||
"datasets": [
|
||||
{
|
||||
"label": "Itars (18)",
|
||||
"data": [3, 5, 0, 9, 1, 0, 0, 0, 0, 16, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (16)",
|
||||
"data": [3, 5, 0, 8, 0, 0, 0, 0, 0, 12, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"label": "Lantids (13)",
|
||||
"data": [3, 2, 6, 0, 0, 0, 0, 2, 0, 8, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"label": "Itars (10)",
|
||||
"data": [3, 5, 0, 1, 1, 0, 0, 0, 0, 8, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"label": "Geoden (12)",
|
||||
"data": [3, 2, 3, 0, 0, 0, 0, 2, 2, 4, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (8)",
|
||||
"data": [3, 5, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@
|
|||
"weights": [1, 3, 4, 4, 0, 0],
|
||||
"colors": ["--res-credit", "--res-ore", "--res-knowledge", "--res-qic", "--res-power", "--recent"],
|
||||
"datasetMeta": {
|
||||
"Itars (116)": {
|
||||
"Itars (148)": {
|
||||
"label": "Itars",
|
||||
"total": 67,
|
||||
"weightedTotal": 116
|
||||
"total": 75,
|
||||
"weightedTotal": 148
|
||||
},
|
||||
"Geoden (126)": {
|
||||
"label": "Geoden",
|
||||
"total": 82,
|
||||
"weightedTotal": 126
|
||||
},
|
||||
"Taklons (123)": {
|
||||
"Taklons (155)": {
|
||||
"label": "Taklons",
|
||||
"total": 118,
|
||||
"weightedTotal": 123
|
||||
"total": 126,
|
||||
"weightedTotal": 155
|
||||
},
|
||||
"Lantids (124)": {
|
||||
"label": "Lantids",
|
||||
|
|
@ -28,20 +28,20 @@
|
|||
"labels": ["Credits", "Ores", "Knowledge", "QICs", "Power Charges", "Gained Tokens"],
|
||||
"datasets": [
|
||||
{
|
||||
"label": "Taklons (123)",
|
||||
"data": [32, 17, 8, 2, 50, 9]
|
||||
"label": "Taklons (155)",
|
||||
"data": [32, 17, 16, 2, 50, 9]
|
||||
},
|
||||
{
|
||||
"label": "Geoden (126)",
|
||||
"data": [28, 14, 12, 2, 19, 7]
|
||||
},
|
||||
{
|
||||
"label": "Lantids (124)",
|
||||
"data": [22, 14, 13, 2, 18, 4]
|
||||
"label": "Itars (148)",
|
||||
"data": [20, 16, 18, 2, 7, 12]
|
||||
},
|
||||
{
|
||||
"label": "Itars (116)",
|
||||
"data": [20, 16, 10, 2, 7, 12]
|
||||
"label": "Lantids (124)",
|
||||
"data": [22, 14, 13, 2, 18, 4]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
"Itars (14)": {
|
||||
"label": "Itars",
|
||||
"income": 14,
|
||||
"cost": -32,
|
||||
"balance": -18
|
||||
"cost": -64,
|
||||
"balance": -50
|
||||
},
|
||||
"Geoden (6)": {
|
||||
"label": "Geoden",
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
"Taklons (4)": {
|
||||
"label": "Taklons",
|
||||
"income": 4,
|
||||
"cost": -16,
|
||||
"balance": -12
|
||||
"cost": -48,
|
||||
"balance": -44
|
||||
},
|
||||
"Lantids (5)": {
|
||||
"label": "Lantids",
|
||||
|
|
@ -47,21 +47,21 @@
|
|||
"Knowledge cost"
|
||||
],
|
||||
"datasets": [
|
||||
{
|
||||
"label": "Itars (14)",
|
||||
"data": [0, 2, 1, 1, 0, 0, 16]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (4)",
|
||||
"data": [0, 0, 0, 1, 0, 0, 12]
|
||||
},
|
||||
{
|
||||
"label": "Lantids (5)",
|
||||
"data": [2, 1, 0, 0, 2, 0, 8]
|
||||
},
|
||||
{
|
||||
"label": "Itars (14)",
|
||||
"data": [0, 2, 1, 1, 0, 0, 8]
|
||||
},
|
||||
{
|
||||
"label": "Geoden (6)",
|
||||
"data": [0, 2, 0, 0, 0, 0, 4]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (4)",
|
||||
"data": [0, 0, 0, 1, 0, 0, 4]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
"weights": [3, 4, 4, 0, 1],
|
||||
"colors": ["--res-ore", "--res-qic", "--res-knowledge", "--res-power", "--res-credit"],
|
||||
"datasetMeta": {
|
||||
"Itars (9)": {
|
||||
"Itars (41)": {
|
||||
"label": "Itars",
|
||||
"income": 9,
|
||||
"income": 41,
|
||||
"cost": 0,
|
||||
"balance": 9
|
||||
"balance": 41
|
||||
},
|
||||
"Geoden (0)": {
|
||||
"label": "Geoden",
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
"cost": 0,
|
||||
"balance": 0
|
||||
},
|
||||
"Taklons (0)": {
|
||||
"Taklons (32)": {
|
||||
"label": "Taklons",
|
||||
"income": 0,
|
||||
"income": 32,
|
||||
"cost": 0,
|
||||
"balance": 0
|
||||
"balance": 32
|
||||
},
|
||||
"Lantids (0)": {
|
||||
"label": "Lantids",
|
||||
|
|
@ -32,12 +32,12 @@
|
|||
"labels": ["Ores income", "QICs income", "Knowledge income", "Power Charges income", "Credits income"],
|
||||
"datasets": [
|
||||
{
|
||||
"label": "Itars (9)",
|
||||
"data": [0, 0, 1, 0, 5]
|
||||
"label": "Itars (41)",
|
||||
"data": [0, 0, 9, 0, 5]
|
||||
},
|
||||
{
|
||||
"label": "Taklons (0)",
|
||||
"data": [0, 0, 0, 4, 0]
|
||||
"label": "Taklons (32)",
|
||||
"data": [0, 0, 8, 4, 0]
|
||||
},
|
||||
{
|
||||
"label": "Geoden (0)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue