Commit Graph

11 Commits

Author SHA1 Message Date
Brian Fertig 4b8ddae8d9 Halve trade margins: distance bands -> x0.75/x1.15/x1.85/x2.75/x3.75
f' = 0.25 + f/2 on every band (x1.0/1.8/3.2/5.0/7.0): with the origin buy
fixed at x0.5, per-unit profit lands at exactly ~half the original in every
band (30->17, 67->35, 130->66, 218->110, 382->192 cr for the average
product) while distance stays the dominant term and the curve's shape is
preserved. Data-only change (economy.json); docs/ECONOMY.md table + example
updated. All invariants re-verified (anti-loop, monotone distance, far pays
more than buy, 1-hop viable) and the economy/cargo/shop-UI/scout suites
pass. dev/economics-report.mjs gains an ECON_BANDS=... A/B override and
dev/economy-bands-audit.mjs sweeps the band invariants on any band set.
2026-09-15 11:38:57 -06:00
Brian Fertig 15eaf26c03 Change cargo bay builds to cost credits + minerals
- Rebalance the three cargo hold upgrades (8/12/16) from a credits-only sink to a mixed cost of credits and minerals, so expanding the hold draws on both trade income and the mining economy.
- Update research descriptions, build data, tests, docs, and code comments to reflect the new two-resource costs.
2026-09-14 19:27:55 -06:00
Brian Fertig 828a5b8c38 Implement economy model v2: one world, one good with daily batch stock
- Replace producer/demand class pricing with strict 1:1 origin assignment;
  each settled system sells exactly its signature good at a discounted origin
  price, and the catalog remainder becomes a hub pool resold by stations/capitals
- Make banded hop distance the dominant sell-price factor (x1.0 to x7.0),
  with planet-type demand as a secondary +10% modifier, and cap every shop's
  sell price at its own buy price to eliminate the v1 infinite-credit loop
- Add Stock.js for the time-gated daily batch (6 units per origin per wall-clock
  day) — the economy's only stateful piece; wire it through GameScene,
  SaveData capture/restore/reset, and the shop UI stepper clamp + SOLD OUT strip
- Update Economy.js with assignOrigins pass, new buyPrice/sellPrice/shopFor
  logic, tradePreview stock-cap backstop (buyback exempt), and distanceFactor
- Rework shop UI: BuyList shows "N left"/"SOLD OUT" per batch-limited row and
  clamps the stepper; ScoutPanel shows MADE IN (origin system) instead of GROWN ON;
  ShopView wires stockRemaining/stockCapsFor/spendStock into preview and confirm
- Update all dev tests (economy, cargo, shop-ui, saves) to assert model v2
  invariants including the anti-loop sweep, batch clamp/backstop, and save round-trip
2026-09-14 18:22:21 -06:00
Brian Fertig c3d5e7fe74 Span the trade panel to the screen edges: SELL flush with the planet text, BUY out to the same right padding
The panel was centered as a group; now the SELL grid's left edge sits at
the surface HUD's planet-text left edge (landing.hud.marginX, 24px —
same key the HUD name/line use) so the cargo grid lines up vertically
with the planet name above it, and the BUY list stretches from just
past the grid all the way to the right edge minus that same padding
(1280px window: BUY list 560 -> 770px wide; the 440px floor stays as
the narrow-window fallback). The 16px gap between the panels is
unchanged, and the sub-bar still anchors to the deck's Shop button.
shopui.json's buyList.w is now only the headless fallback width.
2026-09-12 00:06:17 -06:00
Brian Fertig cc4a15cafd Widen the BUY list right up against the SELL grid; the row description drops to 11px and wraps to two lines without touching the price/stepper
The center column is gone: Confirm + Clear move onto the tab sub-bar
([tabs] | [Clear][Confirm] | NET value), serving both the trade and
buyback tabs, so the two panels sit side by side with just a bit of
padding between (grid.centerW 208 -> 16). The row description keeps the
smaller font, word-wraps inside the text column (wrap width stops
before the price), and the char-count budget now spans two lines so the
headless path stays bounded; rowH grows 64 -> 72 to fit both lines.
The buttons persist across tab switches (they were content before and
died with it), Confirm stays grayed while the trade is invalid, and the
stub gains setX/setY so the bar layout is testable.
2026-09-11 23:47:43 -06:00
Brian Fertig 3fdd825570 Lock the deck while the shop is up: only LEAVE SHOP stays live
While the shop clip is on screen (the SHOP slot reads LEAVE SHOP), the
command deck's other slots — Build, Ship, Quests, Take Off, Menu — go
standby: dim, no hover, no press, clicks swallowed — the same inert
language as the 'ack' comm's deck hold. The press that opened the shop
is the only way out; the slots re-arm on LEAVE SHOP (and if the shop
clip fails to load).

  js/ui/ActionBar.js     setSlotEnabled(id, on) — per-slot lock: arms/
                         disarms one slot (input off, standby paint);
                         setEnabled (deck-wide standby) keeps each slot's
                         flag in sync and still owns input over a
                         per-slot unlock; setHover/press guard on it;
                         setLabel no longer repaints a locked slot live
  js/scenes/SurfaceScene setDeckLocked(locked) — lock everything but
                         SHOP on enter (toggleShop), release on leave
                         (leaveShop) + the broken-clip fallback
  dev/actionbar.test.mjs new — slot lock / deck lock / standby-priority /
                         label-kept-locked, headless
  docs/ECONOMY.md §12    the deck-lock bullet

All headless suites that passed before still pass (the five pre-existing
failures — music/quest-tracker/system-hud/galaxy-labels/jumpgate —
import SurfaceScene, which extends Phaser.Scene that the headless stub
doesn't provide; they fail identically without this change).
2026-09-11 23:31:54 -06:00
Brian Fertig a2d211a981 Rework the BUY side: a scrollable list of wide rows (icon + name +
description + price + stepper) instead of the 4×4 icon grid

Each stock good is now ONE WIDE ROW — the good's icon, its name + a
one-line description (the good's flavor), and the price + a −/qty/+
stepper on the right — the way the user wanted the shop list to read.
The stock (12–16 goods) outgrows the panel, so the list SCROLLS:
drag on the row area or the mouse wheel; rows outside the window are
clipped (row-based alpha clipping — this Phaser build has no
ScrollContainer/camera clip), and hidden rows' steppers are
non-interactive. The selection is data (goodId→qty), so stepping a
good works whether its row is on screen or not.

  js/ui/shop/BuyList.js   new — the scrollable BUY list (rows, drag +
                          wheel scroll, per-row steppers, flavor text)
  js/ui/shop/TradeGrid.js SELL-only now — the BUY mode (steppers, stock
                          rendering, buy-selection data) is stripped;
                          one grid, one purpose
  js/ui/shop/ShopView.js  composes TradeGrid (SELL) + BuyList (BUY);
                          the BUY panel sizes itself to the SELL grid's
                          height (top- AND bottom-aligned)
  data/shopui.json        buyList row/typography knobs (name, desc,
                          price, row bg/border, selection accent)
  dev/shop-ui.test.mjs    BUY assertions rewritten for the list + a new
                          SCROLL section (scroll clamps, row clipping,
                          stepping off-screen rows)
  dev/shop-shot.mjs       BUY probe → the row's inline text (no tooltip)
  docs/ECONOMY.md §12     the BUY bullet + mockup now describe the list

The BUY side's name + price used to live in a hover tooltip because a
grid cell is too small for text; a wide row carries them inline, so the
tooltip stays on the SELL side only. All headless suites green
(shop-ui, economy, cargo, builds, ship-behavior).
2026-09-11 23:23:15 -06:00
Brian Fertig 2b860cc899 Move the live NET readout from the panel center onto the tab sub-bar
The pending trade's credit delta now sits at the right end of the
Buy/Sell + Buyback sub-bar, past a hairline divider — tabs AND the
credit math on one console, one glance apart (entry state dims it to
0 cr). The center column keeps Confirm/Clear (re-centered); the
buyback panel's Confirm moves up to sit just below its rows.

Knobs: data/shopui.json → preview (bar sizing, zeroColor, divider).
Docs: docs/ECONOMY.md §12 mockups + bullets follow the new layout.
Tests: dev/shop-ui.test.mjs asserts the bar's NET readout mirrors the
pending trade (+N cr while picking, 0 cr after Confirm).
2026-09-11 22:09:49 -06:00
Brian Fertig 77d649276c Rework shop UI to cyberpunk sub-bar + entry state, fix panel geometry
- Shop now opens on the tab sub-bar only (shop video plays); clicking Buy/Sell reveals the trade panel — showcases the clip before the UI takes over.
- Tab bar and Confirm/Clear are now MenuButtons in a console-blue sub-bar that rests above the command deck, anchored to the deck's Shop button (MenuSubBar recipe), replacing the old top-of-screen custom buttons.
- Fix trade panel vertical placement: a Container's (x,y) is a pure translation of local space (verified via dev/cbox-test.html), so the grid position IS the panel top-left; setting it to topY + h/2 treated it as a centered origin and clipped bottom rows. Panel now anchors just under the HUD planet text via SurfaceScene.shopTopY().
- Parent TradeGrid plate/title to the grid container so they render above the shop video (scene-level depth-0 objects drew behind it in this build).
- Add dev probes (dev/cbox-test.html, dev/shop-shot.{html,mjs}) and update phaser-stub/test stubs for setSize/setBlendMode/rectangle; document entry state + sub-bar in docs/ECONOMY.md.
2026-09-11 21:19:32 -06:00
Brian Fertig 1b4cba9f4f Add shop buy/sell UI, cargo hold, and cargo bay upgrades
- Introduce CargoHold (pure class) as the ship's trade-goods carrier: fixed bays, one good each, capacity = unlocked bays, save/restore round-trip. Ship.cargo + setCargoHold/cargoRoom wired into stats.
- Add three credit-costed cargo builds (cargo-bay-8/12/16) that expand the hold 4→8→12→16 (MAX wins). BuildWindow affordability now covers both minerals and credits; GameScene.beginBuild debits credit lines and _applyCargoUpgrade expands the hold on completion.
- Add tradePreview/resultingCargo to Economy.js as the shop's pure calculator: sell/buy pricing, net credits, the two caps (can't go negative, end hold fits capacity), and atomic sell-to-free-room-for-buy.
- New ShopView + TradeGrid compose the buy/sell screen over the shop clip: SELL grid of cargo bays (tap to check), BUY grid with quantity steppers, live NET preview, Confirm/Clear, and a session-local Buyback tab (neutral undo at the sale price, locked until a sale). Wired into SurfaceScene's SHOP button.
- data/shopui.json drives the shop layout/animation knobs; economy.json gains cargo.maxSlots (16-slot grid); ship.json base cargoHold drops to 4 unlocked bays.
- Headless tests: dev/cargo.test.mjs (hold rules + trade preview caps), dev/shop-ui.test.mjs (construct, sell, buy, caps, buyback, clear), plus updated builds/ship-behavior suites; phaser-stub gains Geom.Rectangle for the hitArea path.
2026-09-11 20:11:34 -06:00
Brian Fertig 5f54cc327e Add trade economy engine, credits currency, and goods catalog
- New Economy.js price/stock engine: deterministic buy/sell prices based on
  producer/demand classes and hop distance (regional availability model)
- Goods catalog (114 goods, 9 categories) with spritesheet mapping and
  per-class producer/demand roles
- Credits state on Ship (add/spend/set/canAfford), save/restore support,
  and upper-right HUD stacked above the minerals readout
- Quest reward payout now supports credits alongside minerals
- cargoHold reduced to 4 units for initial play balance
- Economy generation pass in Galaxy.js computes classBySystem and
  producerHops via multi-source BFS over the jump network
- dev/economy.test.mjs validates determinism, fixed prices, trade loop
  profitability, distance scaling, shop floor composition, and icon mapping
- docs/ECONOMY.md: full design doc covering pricing model, gemstone system,
  and locked decisions
2026-09-11 18:36:30 -06:00