Claude Claude Opus 4.8 commited on
Commit
e46bcce
·
unverified ·
1 Parent(s): f13e05b

Odyssey Tier-1 "make it playable": fix the threat curve + cheap wins

Browse files

A gameplay review (instrumented headless runs + a critique team) found Odyssey's
threat curve and win curve ~6x out of sync: war reliably began at ~minute 4 (two
economies mine the shared world to the old 23%-depletion war threshold that fast,
and "peace" only gated the AI's ATTACKING, not its arming), so a turtling economy
player was dead by minute 6-12 — while the Antimatter Gate win needs ~25-35 min.
The whole economy was, in practice, unreachable.

- engine/diplomacy.js (#1, the critical fix): a 7-minute GRACE window floors the
scarcity target at cordial so a fresh economy can establish, and a much gentler
souring curve (war at ~47% depletion, full hostility only near total depletion,
slower drift) moves the war into the mid/late game. Empirically: war onset moves
from ~min 4 to ~min 8-21, and a base with a reasonable defensive core now SURVIVES
the full 35-min win window across seeds (previously the CC fell by min 6-12). #2
("pressure, not exterminate") falls out for free — the existing gentle-early/
heavy-late wave ramp works once the timing is fixed; no AI-logic change needed.
- engine/techtree.js + hud.js (#3): research is a QUEUE now, not one node at a time
— line up a whole prereq chain at once (a prereq queued ahead counts as met) and
stop babysitting. The Datacenter panel shows "Researching X (+N queued)".
- engine/wonder.js + industry.js + entities.js (#4): a charging Antimatter Gate
draws Power, so it TAXES your factories (they throttle while it charges — more
Reactors / Fusion Containment relieve it, so that node is no longer dead). The
charge itself isn't power-gated, so a sniped Reactor can't stall a colony Gate.
- boot.js + style.css (#7): research completion and Gate-charge milestones were
silent (events nothing consumed) — now they toast + chime.
- overlays.js (#9): the Odyssey onboarding said "no victory screen" (wrong since the
Gate shipped) and never named the loop — rewritten to state the chain, research,
the defence warning, the Gate win, and the M galaxy-map key.
- Tests updated for the research queue + the grace window; 442 pass.

Odyssey-only and deterministic; the byte-identical skirmish path is untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEQUVetLk31Jj7niDQAsXL

boot.js CHANGED
@@ -27,6 +27,7 @@ import { showObjectives, hideObjectives, showSeedChip, showFactionChip, showGame
27
  import { renderMapSelect, setup } from "./setup.js";
28
  import { setupEscort, setupRaider, setupBounty } from "./engine/scenarios.js";
29
  import { createGalaxy, activeState, jumpCapital, sweepColonies, stepGalaxy } from "./engine/galaxy.js";
 
30
  import { planetName } from "./data.js";
31
  import * as sound from "./sound.js";
32
 
@@ -44,6 +45,9 @@ const DIFFICULTY = {
44
  // Runtime bookkeeping — module-local because only the loop / frame-event pump
45
  // touch them (state + input live on the shared session instead).
46
  let loop, announced, lastHud, lastUnderAttackAt, underAttackTimer;
 
 
 
47
  // Where the last under-attack alert fired — clicking the banner jumps there, so a
48
  // raid on the far side of a big map is one click away instead of a frantic scroll.
49
  let lastAttackAt = null;
@@ -189,6 +193,7 @@ export function bootState(newState, { intro }) {
189
  resetFacing();
190
  announced = false;
191
  lastHud = 0;
 
192
  resetPanelSignature();
193
  lastUnderAttackAt = -Infinity;
194
  game.supplyBlockedUntil = 0;
@@ -287,6 +292,22 @@ function processFrameEvents() {
287
  game.supplyBlockedUntil = performance.now() + 800;
288
  }
289
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
291
  }
292
  state.events.length = 0;
 
27
  import { renderMapSelect, setup } from "./setup.js";
28
  import { setupEscort, setupRaider, setupBounty } from "./engine/scenarios.js";
29
  import { createGalaxy, activeState, jumpCapital, sweepColonies, stepGalaxy } from "./engine/galaxy.js";
30
+ import { TECHS } from "./engine/techtree.js";
31
  import { planetName } from "./data.js";
32
  import * as sound from "./sound.js";
33
 
 
45
  // Runtime bookkeeping — module-local because only the loop / frame-event pump
46
  // touch them (state + input live on the shared session instead).
47
  let loop, announced, lastHud, lastUnderAttackAt, underAttackTimer;
48
+ // Highest Antimatter Gate charge milestone (25/50/75/100%) already announced, so the
49
+ // wonderCharging event (which fires every tick) toasts once per threshold, not per frame.
50
+ let gateMilestone = 0;
51
  // Where the last under-attack alert fired — clicking the banner jumps there, so a
52
  // raid on the far side of a big map is one click away instead of a frantic scroll.
53
  let lastAttackAt = null;
 
193
  resetFacing();
194
  announced = false;
195
  lastHud = 0;
196
+ gateMilestone = 0;
197
  resetPanelSignature();
198
  lastUnderAttackAt = -Infinity;
199
  game.supplyBlockedUntil = 0;
 
292
  game.supplyBlockedUntil = performance.now() + 800;
293
  }
294
  break;
295
+ // Odyssey research finishing was previously silent — announce the unlock so
296
+ // the player connects the wait to the reward (and notices new build options).
297
+ case "researchComplete":
298
+ sound.playBuildingComplete(pan);
299
+ showGalaxyToast(`Researched ${TECHS[ev.techId]?.name || ev.techId}`, "good");
300
+ break;
301
+ // The Antimatter Gate charge (fires every tick) — toast once per 25% so the
302
+ // multi-minute climb to the galaxy win is visible without selecting the Gate.
303
+ case "wonderCharging": {
304
+ const pct = Math.floor((ev.charge || 0) * 4) * 25;
305
+ if (pct >= 25 && pct > gateMilestone) {
306
+ gateMilestone = pct;
307
+ showGalaxyToast(`Antimatter Gate charging — ${pct}%`, pct >= 75 ? "bad" : "warn");
308
+ }
309
+ break;
310
+ }
311
  }
312
  }
313
  state.events.length = 0;
engine/diplomacy.js CHANGED
@@ -22,9 +22,18 @@
22
  export const PEACE_THRESHOLD = -0.15;
23
 
24
  const START_STANCE = 0.35; // a new neighbour starts Cordial
25
- const DRIFT_RATE = 0.06; // how fast stance chases its scarcity target (per second)
26
  const GRIEVANCE_PER_KILL = 0.04; // stance lost per enemy ship you destroy on this world
27
 
 
 
 
 
 
 
 
 
 
28
  function clamp(v, lo, hi) { return v < lo ? lo : v > hi ? hi : v; }
29
 
30
  export function createDiplomacy() {
@@ -53,7 +62,12 @@ export function updateDiplomacy(state, dt) {
53
  }
54
  dip.lastAiUnits = ai;
55
 
56
- const target = 0.45 - dip.depletion * 2.6;
 
 
 
 
 
57
  dip.stance = clamp(dip.stance + (target - dip.stance) * Math.min(1, dt * DRIFT_RATE), -1, 1);
58
  }
59
 
 
22
  export const PEACE_THRESHOLD = -0.15;
23
 
24
  const START_STANCE = 0.35; // a new neighbour starts Cordial
25
+ const DRIFT_RATE = 0.05; // how fast stance chases its scarcity target (per second)
26
  const GRIEVANCE_PER_KILL = 0.04; // stance lost per enemy ship you destroy on this world
27
 
28
+ // Odyssey is an economy-builder: the win path is ~25–35 minutes, so the neighbour
29
+ // must give you room to establish before it can turn. A GRACE window floors the
30
+ // scarcity target at cordial for the opening (empirically, two economies sharing a
31
+ // world mine it to the old ~23%-depletion war threshold in ~4 minutes — far too
32
+ // soon), and the target slope below is much gentler, so war arrives in the mid-game
33
+ // and escalates toward the endgame instead of ending the run before it starts.
34
+ const GRACE_TIME = 420; // 7 minutes of guaranteed cordiality to establish an economy + defence
35
+ const GRACE_FLOOR = 0.2; // the stance target can't fall below this during grace
36
+
37
  function clamp(v, lo, hi) { return v < lo ? lo : v > hi ? hi : v; }
38
 
39
  export function createDiplomacy() {
 
62
  }
63
  dip.lastAiUnits = ai;
64
 
65
+ // Scarcity target: full deposits → +0.6 (cordial); war (below PEACE_THRESHOLD)
66
+ // only once the world is ~47% mined out, and full hostility only near total
67
+ // depletion — a gentle mid-to-late-game slide, not a minute-4 cliff. Floored to
68
+ // cordial during the opening grace window regardless of how fast you strip-mine.
69
+ let target = 0.6 - dip.depletion * 1.6;
70
+ if (state.time < GRACE_TIME) target = Math.max(target, GRACE_FLOOR);
71
  dip.stance = clamp(dip.stance + (target - dip.stance) * Math.min(1, dt * DRIFT_RATE), -1, 1);
72
  }
73
 
engine/entities.js CHANGED
@@ -189,6 +189,7 @@ export const BUILDINGS = {
189
  // lost with it. The Leviathan (below) draws on the same strategic goods — feed
190
  // the Gate or build the fleet.
191
  wonder: true, feed: { ai: 0.2, antimatter: 0.3, plasmatorp: 0.1 }, chargeTime: 150,
 
192
  },
193
  };
194
 
 
189
  // lost with it. The Leviathan (below) draws on the same strategic goods — feed
190
  // the Gate or build the fleet.
191
  wonder: true, feed: { ai: 0.2, antimatter: 0.3, plasmatorp: 0.1 }, chargeTime: 150,
192
+ powerDraw: 8, // a charging Gate loads the grid — it competes with your factories for Reactor Power
193
  },
194
  };
195
 
engine/industry.js CHANGED
@@ -67,6 +67,10 @@ export function powerDraw(state, owner) {
67
  const def = BUILDINGS[b.type];
68
  const r = def.recipe ? RECIPE_BY_ID[def.recipe] : null;
69
  if (r) draw += (r.in.energy || 0) * (def.prodRate || 1);
 
 
 
 
70
  }
71
  return draw;
72
  }
 
67
  const def = BUILDINGS[b.type];
68
  const r = def.recipe ? RECIPE_BY_ID[def.recipe] : null;
69
  if (r) draw += (r.in.energy || 0) * (def.prodRate || 1);
70
+ // A wonder still charging loads the grid too, so the Antimatter Gate competes
71
+ // with the factories for Reactor Power (engine/wonder.js) — making the finale a
72
+ // real "feed the factories vs charge the Gate" call, and Fusion Containment worth it.
73
+ else if (def.wonder && (b.charge || 0) < 1) draw += def.powerDraw || 0;
74
  }
75
  return draw;
76
  }
engine/techtree.js CHANGED
@@ -72,39 +72,49 @@ export function techMult(upgrades, field) {
72
  return m;
73
  }
74
 
75
- // Advance a Datacenter's in-progress research by dt — a no-op for anything that
76
- // isn't a completed Datacenter with an active job. On completion the node lands in
77
- // player.upgrades (where prereqsMet/techMult read it) and the job clears. Same
78
- // dt-driven float pattern as buildProgress — deterministic, engine-pure.
 
79
  export function updateResearch(state, building, dt) {
80
  if (building.constructing || building.type !== "datacenter") return;
81
- const job = building.research;
82
- if (!job) return;
 
83
  const def = TECHS[job.techId];
84
- if (!def) { building.research = null; return; }
85
  job.progress += dt / (def.time * researchTimeScale(state));
86
  if (job.progress >= 1) {
87
  state.players[building.owner].upgrades[job.techId] = true;
88
- building.research = null;
89
  state.events.push({ type: "researchComplete", techId: def.id, x: building.x, y: building.y, owner: building.owner });
90
  }
91
  }
92
 
93
- // Begin researching a node at a Datacenter: needs an IDLE completed Datacenter,
94
- // the node not already owned, prereqs met, and affordability — then pay (gathered
95
- // commodities) and start the timer. Mirrors production.js researchUpgrade, but
96
- // timed rather than instant, and one project at a time.
 
 
97
  export function researchTech(state, buildingId, techId) {
98
  const building = state.buildings.get(buildingId);
99
  if (!building || building.type !== "datacenter" || building.constructing) return false;
100
- if (building.research) return false; // one project at a time
101
  const player = state.players[building.owner];
102
- if (player.upgrades[techId]) return false; // already researched
 
 
103
  const def = TECHS[techId];
104
  if (!def) return false;
105
- if (!prereqsMet(state, building.owner, def)) return false;
 
 
 
 
 
106
  if (!canAfford(player.resources, def.cost)) return false;
107
  payCost(player.resources, def.cost);
108
- building.research = { techId, progress: 0 };
109
  return true;
110
  }
 
72
  return m;
73
  }
74
 
75
+ // Advance a Datacenter's research QUEUE by dt — a no-op for anything that isn't a
76
+ // completed Datacenter with a queued job. Develops the head of the queue; on
77
+ // completion the node lands in player.upgrades (where prereqsMet/techMult read it),
78
+ // the job is dropped, and the next queued node begins. Same dt-driven float pattern
79
+ // as buildProgress — deterministic, engine-pure.
80
  export function updateResearch(state, building, dt) {
81
  if (building.constructing || building.type !== "datacenter") return;
82
+ const queue = building.researchQueue;
83
+ if (!queue || queue.length === 0) return;
84
+ const job = queue[0];
85
  const def = TECHS[job.techId];
86
+ if (!def) { queue.shift(); return; }
87
  job.progress += dt / (def.time * researchTimeScale(state));
88
  if (job.progress >= 1) {
89
  state.players[building.owner].upgrades[job.techId] = true;
90
+ queue.shift();
91
  state.events.push({ type: "researchComplete", techId: def.id, x: building.x, y: building.y, owner: building.owner });
92
  }
93
  }
94
 
95
+ // Queue a node for research at a Datacenter: needs a completed Datacenter, the node
96
+ // not already owned or queued, its prereqs met OR already queued AHEAD of it (so a
97
+ // whole path can be lined up at once and stop being babysat one node at a time),
98
+ // and affordability — then pay (gathered commodities, on enqueue like the
99
+ // production queue) and append it. Mirrors production.js researchUpgrade, but timed
100
+ // and queued rather than instant and single.
101
  export function researchTech(state, buildingId, techId) {
102
  const building = state.buildings.get(buildingId);
103
  if (!building || building.type !== "datacenter" || building.constructing) return false;
 
104
  const player = state.players[building.owner];
105
+ if (player.upgrades[techId]) return false; // already researched
106
+ const queue = building.researchQueue || (building.researchQueue = []);
107
+ if (queue.some(j => j.techId === techId)) return false; // already queued
108
  const def = TECHS[techId];
109
  if (!def) return false;
110
+ // A prereq counts as met if it's researched, a completed building, OR queued
111
+ // ahead on this same Datacenter (it'll finish first). prereqsMet covers the first
112
+ // two; filter out the queued-ahead tokens before delegating to it.
113
+ const queuedAhead = new Set(queue.map(j => j.techId));
114
+ const remaining = (def.requires || []).filter(r => !queuedAhead.has(r));
115
+ if (!prereqsMet(state, building.owner, { requires: remaining })) return false;
116
  if (!canAfford(player.resources, def.cost)) return false;
117
  payCost(player.resources, def.cost);
118
+ queue.push({ techId, progress: 0 });
119
  return true;
120
  }
engine/wonder.js CHANGED
@@ -5,12 +5,15 @@
5
  endless Odyssey sandbox its first WIN condition — until now it could only be
6
  lost (checkEndlessLoss).
7
 
8
- Charging is a structural twin of industry.js updateProduction: throttled by the
9
- player's spare Power (so a Gate charging while your factories run competes with
10
- them for the grid) and clamped to the strategic goods actually in stock (so a
11
- starved Gate stalls and waits rather than charging on nothing, and the stockpile
12
- never goes negative). Goods are spent as they're fed, so a Gate razed mid-charge
13
- costs the whole investment — a fat, defendable objective, not a fire-and-forget.
 
 
 
14
 
15
  Odyssey-only and inert-by-construction: the Gate is `odysseyOnly`, the skirmish
16
  AI never builds it, and updateWonder is a no-op for any building without the
@@ -21,7 +24,6 @@
21
  "use strict";
22
 
23
  import { BUILDINGS } from "./entities.js";
24
- import { powerThrottle } from "./industry.js";
25
 
26
  // Advance a charging wonder by dt — a no-op for any building that isn't a completed
27
  // wonder. `charge` is a 0..1 float on the building (persists for free — serPlanet
@@ -34,9 +36,11 @@ export function updateWonder(state, building, dt) {
34
  const feed = def.feed || {};
35
  const res = state.players[building.owner].resources;
36
 
37
- // Charge fraction this tick: the power-throttled target, clamped by the scarcest
38
- // fed good in stock (measured in "full charges' worth", so we never overspend).
39
- let p = (dt * powerThrottle(state, building.owner)) / def.chargeTime;
 
 
40
  for (const com in feed) {
41
  const perCharge = feed[com] * def.chargeTime;
42
  if (perCharge > 0) p = Math.min(p, (res[com] || 0) / perCharge);
 
5
  endless Odyssey sandbox its first WIN condition — until now it could only be
6
  lost (checkEndlessLoss).
7
 
8
+ Charging draws Power while it runs (industry.js powerDraw), so it TAXES the grid
9
+ — your factories throttle down while the Gate charges, a real "charging costs you
10
+ production" tension that more Reactors / Fusion Containment relieve. The charge
11
+ itself isn't power-gated, though: it proceeds even if a Reactor is sniped (so a
12
+ colony Gate can't be trivially stalled by killing one building). It IS clamped to
13
+ the strategic goods in stock — a starved Gate waits rather than charging on
14
+ nothing, and the stockpile never goes negative. Goods are spent as they're fed,
15
+ so a Gate razed mid-charge costs the whole investment — a fat, defendable
16
+ objective, not a fire-and-forget.
17
 
18
  Odyssey-only and inert-by-construction: the Gate is `odysseyOnly`, the skirmish
19
  AI never builds it, and updateWonder is a no-op for any building without the
 
24
  "use strict";
25
 
26
  import { BUILDINGS } from "./entities.js";
 
27
 
28
  // Advance a charging wonder by dt — a no-op for any building that isn't a completed
29
  // wonder. `charge` is a 0..1 float on the building (persists for free — serPlanet
 
36
  const feed = def.feed || {};
37
  const res = state.players[building.owner].resources;
38
 
39
+ // Charge fraction this tick — full rate (the Gate's own draw taxes the factories
40
+ // via powerDraw, but the charge itself isn't power-gated, so a sniped Reactor
41
+ // can't stall it), clamped by the scarcest fed good in stock (measured in "full
42
+ // charges' worth", so we never overspend).
43
+ let p = dt / def.chargeTime;
44
  for (const com in feed) {
45
  const perCharge = feed[com] * def.chargeTime;
46
  if (perCharge > 0) p = Math.min(p, (res[com] || 0) / perCharge);
hud.js CHANGED
@@ -454,14 +454,16 @@ function rebuildSelectionPanel(sel) {
454
  const datacenter = sel.find(e => e.kind === "building" && e.type === "datacenter" && !e.constructing);
455
  if (datacenter) {
456
  const upgrades = state.players.player.upgrades;
457
- if (datacenter.research) {
458
- const def = TECHS[datacenter.research.techId];
 
 
459
  const row = document.createElement("div");
460
  row.className = "sel-row";
461
- row.textContent = `Researching ${def.name} — ${Math.round(datacenter.research.progress * 100)}%`;
 
462
  panelEl.appendChild(row);
463
  }
464
- const busy = !!datacenter.research;
465
  Object.values(TECHS).forEach(t => {
466
  if (upgrades[t.id]) {
467
  const row = document.createElement("div");
@@ -470,11 +472,12 @@ function rebuildSelectionPanel(sel) {
470
  panelEl.appendChild(row);
471
  return;
472
  }
473
- const prereqLocked = !prereqsMet(state, "player", t);
 
 
474
  panelEl.appendChild(makeButton(`Research ${t.name} (${costText(t.cost)})`,
475
  () => researchTech(state, datacenter.id, t.id),
476
- { cost: t.cost, tip: t.desc, locked: prereqLocked || busy,
477
- lockTip: prereqLocked ? lockTipFor(t) : busy ? "A research project is already in progress" : null }));
478
  });
479
  }
480
 
 
454
  const datacenter = sel.find(e => e.kind === "building" && e.type === "datacenter" && !e.constructing);
455
  if (datacenter) {
456
  const upgrades = state.players.player.upgrades;
457
+ const queue = datacenter.researchQueue || [];
458
+ const queued = new Set(queue.map(j => j.techId));
459
+ if (queue.length) {
460
+ const head = TECHS[queue[0].techId];
461
  const row = document.createElement("div");
462
  row.className = "sel-row";
463
+ row.textContent = `Researching ${head.name} — ${Math.round(queue[0].progress * 100)}%`
464
+ + (queue.length > 1 ? ` (+${queue.length - 1} queued)` : "");
465
  panelEl.appendChild(row);
466
  }
 
467
  Object.values(TECHS).forEach(t => {
468
  if (upgrades[t.id]) {
469
  const row = document.createElement("div");
 
472
  panelEl.appendChild(row);
473
  return;
474
  }
475
+ if (queued.has(t.id)) return; // already lined up — reflected in the header's "+N queued"
476
+ // Available if every prereq is researched, a completed building, or queued ahead.
477
+ const ready = (t.requires || []).every(r => queued.has(r) || prereqsMet(state, "player", { requires: [r] }));
478
  panelEl.appendChild(makeButton(`Research ${t.name} (${costText(t.cost)})`,
479
  () => researchTech(state, datacenter.id, t.id),
480
+ { cost: t.cost, tip: t.desc, locked: !ready, lockTip: !ready ? lockTipFor(t) : null }));
 
481
  });
482
  }
483
 
overlays.js CHANGED
@@ -46,8 +46,8 @@ seedChipEl.addEventListener("click", () => {
46
  let objectivesTimer;
47
  export function showObjectives(endless = false) {
48
  objectivesEl.innerHTML = (endless
49
- ? `<span class="obj-goal">Odyssey — settle this world and grow your economy.</span>`
50
- + `<span class="obj-tip">You have one Command Center — your capital. Gather, then <b>trade at the Command Center</b> for credits and build a <b>Spaceport</b> to relocate to new worlds. No clock, no victory screen. Press <b>?</b> for all controls.</span>`
51
  : `<span class="obj-goal">Objective — destroy every enemy Command Center.</span>`
52
  + `<span class="obj-tip">Workers gather ore → build a Barracks → train an army → <b>A</b> then click to attack-move it in. Press <b>?</b> for all controls.</span>`)
53
  + `<button class="obj-close" title="Dismiss" aria-label="Dismiss">×</button>`;
@@ -87,6 +87,7 @@ const HELP_ROWS = [
87
  ["Q · E · X", "Select army · Ranger scout mode · stop"],
88
  ["H", "Hold position — fire in range, don't chase"],
89
  ["`", "Jump to the next idle worker"],
 
90
  ["Right-click a node", "(building selected) rally new workers to mine it"],
91
  ["Minimap", "Left-click to jump · right-click to order"],
92
  ["Wheel · arrows · edge", "Zoom · pan the camera"],
 
46
  let objectivesTimer;
47
  export function showObjectives(endless = false) {
48
  objectivesEl.innerHTML = (endless
49
+ ? `<span class="obj-goal">Odyssey — build an economy and win the galaxy.</span>`
50
+ + `<span class="obj-tip">Gather ore to raise a production chain (<b>Reactor → Smelter → factories</b>), then a <b>Datacenter</b> to research deeper tech. The neighbour shares this world and turns hostile as it mines out, so keep some <b>defence</b>. Manufacture the Strategic tier and build an <b>Antimatter Gate</b> to win — or a <b>Spaceport</b> to jump between worlds. Press <b>M</b> for the galaxy map, <b>?</b> for controls.</span>`
51
  : `<span class="obj-goal">Objective — destroy every enemy Command Center.</span>`
52
  + `<span class="obj-tip">Workers gather ore → build a Barracks → train an army → <b>A</b> then click to attack-move it in. Press <b>?</b> for all controls.</span>`)
53
  + `<button class="obj-close" title="Dismiss" aria-label="Dismiss">×</button>`;
 
87
  ["Q · E · X", "Select army · Ranger scout mode · stop"],
88
  ["H", "Hold position — fire in range, don't chase"],
89
  ["`", "Jump to the next idle worker"],
90
+ ["M", "Odyssey — open the galaxy map"],
91
  ["Right-click a node", "(building selected) rally new workers to mine it"],
92
  ["Minimap", "Left-click to jump · right-click to order"],
93
  ["Wheel · arrows · edge", "Zoom · pan the camera"],
style.css CHANGED
@@ -90,6 +90,7 @@ html, body {
90
  }
91
  .galaxy-toast.warn { border-color: var(--warn); color: var(--warn); }
92
  .galaxy-toast.bad { border-color: var(--bad); color: var(--bad); }
 
93
 
94
  /* Starmap overlay (starmap.js): a full-screen galaxy map with world nodes on a
95
  ring, coloured by your relationship to each. */
 
90
  }
91
  .galaxy-toast.warn { border-color: var(--warn); color: var(--warn); }
92
  .galaxy-toast.bad { border-color: var(--bad); color: var(--bad); }
93
+ .galaxy-toast.good { border-color: var(--good, #4ade80); color: var(--good, #4ade80); }
94
 
95
  /* Starmap overlay (starmap.js): a full-screen galaxy map with world nodes on a
96
  ring, coloured by your relationship to each. */
test/diplomacy.test.js CHANGED
@@ -20,6 +20,7 @@ test("a new neighbour starts cordial and at peace", () => {
20
  test("scarcity turns the neighbour hostile; abundance keeps the peace", () => {
21
  const scarce = createGameState({ planetId: "ferros", seed: 3, endless: true });
22
  scarce.diplomacy = createDiplomacy();
 
23
  drainNodes(scarce, 0.05); // world almost mined out
24
  for (let i = 0; i < 4000; i++) updateDiplomacy(scarce, 0.1);
25
  assert.equal(atPeace(scarce), false, "a mined-out world's neighbour turns on you");
 
20
  test("scarcity turns the neighbour hostile; abundance keeps the peace", () => {
21
  const scarce = createGameState({ planetId: "ferros", seed: 3, endless: true });
22
  scarce.diplomacy = createDiplomacy();
23
+ scarce.time = 1000; // past the opening grace window (war can't start during grace)
24
  drainNodes(scarce, 0.05); // world almost mined out
25
  for (let i = 0; i < 4000; i++) updateDiplomacy(scarce, 0.1);
26
  assert.equal(atPeace(scarce), false, "a mined-out world's neighbour turns on you");
test/galaxy-persist.test.js CHANGED
@@ -100,14 +100,15 @@ test("researched tech and an in-progress Datacenter project survive a save/load"
100
  const s = activeState(g);
101
  s.players.player.upgrades.metallurgy = true; // a completed research node
102
  const dc = makeBuilding("datacenter", "player", 600, 500);
103
- dc.research = { techId: "electronics", progress: 0.4 }; // a project mid-flight
104
  s.buildings.set(dc.id, dc);
105
  const restored = deserializeGalaxy(JSON.parse(JSON.stringify(serializeGalaxy(g))));
106
  const rs = activeState(restored);
107
  assert.equal(rs.players.player.upgrades.metallurgy, true, "the researched node persists (rides in player.upgrades)");
108
  const rdc = [...rs.buildings.values()].find(b => b.type === "datacenter");
109
- assert.ok(rdc && rdc.research && rdc.research.techId === "electronics", "the in-progress project persists on the building");
110
- assert.ok(Math.abs(rdc.research.progress - 0.4) < 1e-9, "…with its progress intact");
 
111
  });
112
 
113
  test("the galaxy save is seed+delta (no terrain), and guards its version", () => {
 
100
  const s = activeState(g);
101
  s.players.player.upgrades.metallurgy = true; // a completed research node
102
  const dc = makeBuilding("datacenter", "player", 600, 500);
103
+ dc.researchQueue = [{ techId: "electronics", progress: 0.4 }, { techId: "machining", progress: 0 }]; // mid-flight + a queued node
104
  s.buildings.set(dc.id, dc);
105
  const restored = deserializeGalaxy(JSON.parse(JSON.stringify(serializeGalaxy(g))));
106
  const rs = activeState(restored);
107
  assert.equal(rs.players.player.upgrades.metallurgy, true, "the researched node persists (rides in player.upgrades)");
108
  const rdc = [...rs.buildings.values()].find(b => b.type === "datacenter");
109
+ assert.ok(rdc && rdc.researchQueue && rdc.researchQueue[0].techId === "electronics", "the in-progress project persists on the building");
110
+ assert.ok(Math.abs(rdc.researchQueue[0].progress - 0.4) < 1e-9, "…with its progress intact");
111
+ assert.equal(rdc.researchQueue.length, 2, "…and the rest of the queue survives too");
112
  });
113
 
114
  test("the galaxy save is seed+delta (no terrain), and guards its version", () => {
test/techtree.test.js CHANGED
@@ -26,13 +26,23 @@ test("every TECH node is well-formed: a commodity cost (no separate currency), a
26
  }
27
  });
28
 
29
- test("researchTech starts a project: pays the commodity cost, one project at a time", () => {
30
  const { state, dc } = odysseyWithDatacenter();
31
  const before = state.players.player.resources.crystals;
32
  assert.equal(researchTech(state, dc.id, "metallurgy"), true);
33
- assert.equal(state.players.player.resources.crystals, before - TECHS.metallurgy.cost.crystals, "paid on start");
34
- assert.ok(dc.research && dc.research.techId === "metallurgy", "the project is in progress");
35
- assert.equal(researchTech(state, dc.id, "reactors"), false, "a Datacenter researches one node at a time");
 
 
 
 
 
 
 
 
 
 
36
  });
37
 
38
  test("research is prereq-gated and afford-gated", () => {
@@ -46,24 +56,34 @@ test("research is prereq-gated and afford-gated", () => {
46
  assert.equal(researchTech(poor.state, poor.dc.id, "metallurgy"), false, "can't afford → refused");
47
  });
48
 
49
- test("updateResearch develops the node over time and banks it into player.upgrades", () => {
50
  const { state, dc } = odysseyWithDatacenter();
51
  researchTech(state, dc.id, "metallurgy");
52
  const need = TECHS.metallurgy.time * researchTimeScale(state);
53
  for (let t = 0; t < need + 1; t += 0.5) updateResearch(state, dc, 0.5);
54
  assert.equal(state.players.player.upgrades.metallurgy, true, "the node completes and lands in upgrades");
55
- assert.equal(dc.research, null, "the project clears on completion");
56
  assert.ok(state.events.some(e => e.type === "researchComplete" && e.techId === "metallurgy"), "an event fires for the HUD/sound");
57
  });
58
 
 
 
 
 
 
 
 
 
 
 
59
  test("updateResearch is a no-op for a non-Datacenter and for an idle Datacenter", () => {
60
  const { state, dc } = odysseyWithDatacenter();
61
  const smelter = makeBuilding("smelter", "player", 700, 500);
62
- smelter.research = { techId: "metallurgy", progress: 0 }; // even if mis-set, a non-datacenter ignores it
63
  state.buildings.set(smelter.id, smelter);
64
  updateResearch(state, smelter, 100);
65
  assert.ok(!state.players.player.upgrades.metallurgy, "a Smelter never researches");
66
- updateResearch(state, dc, 100); // dc has no research job
67
  assert.ok(!state.players.player.upgrades.metallurgy, "an idle Datacenter accrues nothing");
68
  });
69
 
 
26
  }
27
  });
28
 
29
+ test("researchTech queues a project and pays its commodity cost on enqueue", () => {
30
  const { state, dc } = odysseyWithDatacenter();
31
  const before = state.players.player.resources.crystals;
32
  assert.equal(researchTech(state, dc.id, "metallurgy"), true);
33
+ assert.equal(state.players.player.resources.crystals, before - TECHS.metallurgy.cost.crystals, "paid on enqueue");
34
+ assert.equal(dc.researchQueue[0].techId, "metallurgy", "the project heads the queue");
35
+ assert.equal(researchTech(state, dc.id, "metallurgy"), false, "the same node can't be queued twice");
36
+ assert.equal(researchTech(state, dc.id, "reactors"), true, "but a second node queues behind the first");
37
+ assert.equal(dc.researchQueue.length, 2, "both are lined up — no more one-at-a-time babysitting");
38
+ });
39
+
40
+ test("a whole prereq chain can be queued at once — a prereq queued ahead counts as met", () => {
41
+ const { state, dc } = odysseyWithDatacenter();
42
+ assert.equal(researchTech(state, dc.id, "metallurgy"), true);
43
+ assert.equal(researchTech(state, dc.id, "electronics"), true, "electronics queues though metallurgy isn't done — it's ahead");
44
+ assert.equal(researchTech(state, dc.id, "machining"), true, "…and machining behind electronics");
45
+ assert.deepEqual(dc.researchQueue.map(j => j.techId), ["metallurgy", "electronics", "machining"]);
46
  });
47
 
48
  test("research is prereq-gated and afford-gated", () => {
 
56
  assert.equal(researchTech(poor.state, poor.dc.id, "metallurgy"), false, "can't afford → refused");
57
  });
58
 
59
+ test("updateResearch develops the head of the queue and banks it into player.upgrades", () => {
60
  const { state, dc } = odysseyWithDatacenter();
61
  researchTech(state, dc.id, "metallurgy");
62
  const need = TECHS.metallurgy.time * researchTimeScale(state);
63
  for (let t = 0; t < need + 1; t += 0.5) updateResearch(state, dc, 0.5);
64
  assert.equal(state.players.player.upgrades.metallurgy, true, "the node completes and lands in upgrades");
65
+ assert.equal(dc.researchQueue.length, 0, "the job leaves the queue on completion");
66
  assert.ok(state.events.some(e => e.type === "researchComplete" && e.techId === "metallurgy"), "an event fires for the HUD/sound");
67
  });
68
 
69
+ test("the queue auto-advances: a lined-up chain researches without babysitting", () => {
70
+ const { state, dc } = odysseyWithDatacenter();
71
+ researchTech(state, dc.id, "metallurgy");
72
+ researchTech(state, dc.id, "electronics");
73
+ for (let i = 0; i < 4000; i++) updateResearch(state, dc, 0.1); // long enough for both
74
+ assert.equal(state.players.player.upgrades.metallurgy, true);
75
+ assert.equal(state.players.player.upgrades.electronics, true, "the second node researched on its own after the first");
76
+ assert.equal(dc.researchQueue.length, 0);
77
+ });
78
+
79
  test("updateResearch is a no-op for a non-Datacenter and for an idle Datacenter", () => {
80
  const { state, dc } = odysseyWithDatacenter();
81
  const smelter = makeBuilding("smelter", "player", 700, 500);
82
+ smelter.researchQueue = [{ techId: "metallurgy", progress: 0 }]; // even if mis-set, a non-datacenter ignores it
83
  state.buildings.set(smelter.id, smelter);
84
  updateResearch(state, smelter, 100);
85
  assert.ok(!state.players.player.upgrades.metallurgy, "a Smelter never researches");
86
+ updateResearch(state, dc, 100); // dc has no queue
87
  assert.ok(!state.players.player.upgrades.metallurgy, "an idle Datacenter accrues nothing");
88
  });
89