Replace ore/gas fields with generic inventory containers #33

Closed
opened 2026-08-14 11:53:08 +00:00 by metaheavens · 1 comment
Owner

Problem

The resource catalog is data-driven, but GameState still stores rocks, gas, fleet_cargo, fleet_gas_cargo, stock, and gas_stock as separate fields. Generic-looking methods then switch on resource type throughout bank, fleet, building, logistics, and transfer code. Every new resource would require another field and edits across those paths.

Direction

Introduce a reusable Inventory container keyed by resource identifier. The mothership bank, fleet cargo, and building stock each own an Inventory and use generic deposit, withdraw, capacity, and transfer operations. Keep resource display metadata in ResourceDefinition entries so UI glyphs, names, colors, and formatting come from the same catalog.

Provide save/state migration or compatibility loading for current ore and gas values.

Acceptance criteria

  • Bank, fleet, and building storage use the same Inventory API.
  • Transfer and logistics code does not branch on ore versus gas.
  • No separate gas_stock, fleet_gas_cargo, or equivalent per-resource storage fields are needed.
  • Resource UI rows and glyphs are generated from ResourceDefinition metadata rather than a match statement.
  • Capacity rules can be expressed per inventory and, when necessary, per resource without hard-coded resource names.
  • A third-resource test fixture can be banked, carried, stored in a building, and transferred without changing GameState transfer code.
  • Existing saved ore/gas amounts are preserved by a tested migration or compatibility path.
## Problem The resource catalog is data-driven, but GameState still stores rocks, gas, fleet_cargo, fleet_gas_cargo, stock, and gas_stock as separate fields. Generic-looking methods then switch on resource type throughout bank, fleet, building, logistics, and transfer code. Every new resource would require another field and edits across those paths. ## Direction Introduce a reusable Inventory container keyed by resource identifier. The mothership bank, fleet cargo, and building stock each own an Inventory and use generic deposit, withdraw, capacity, and transfer operations. Keep resource display metadata in ResourceDefinition entries so UI glyphs, names, colors, and formatting come from the same catalog. Provide save/state migration or compatibility loading for current ore and gas values. ## Acceptance criteria - Bank, fleet, and building storage use the same Inventory API. - Transfer and logistics code does not branch on ore versus gas. - No separate gas_stock, fleet_gas_cargo, or equivalent per-resource storage fields are needed. - Resource UI rows and glyphs are generated from ResourceDefinition metadata rather than a match statement. - Capacity rules can be expressed per inventory and, when necessary, per resource without hard-coded resource names. - A third-resource test fixture can be banked, carried, stored in a building, and transferred without changing GameState transfer code. - Existing saved ore/gas amounts are preserved by a tested migration or compatibility path.
Author
Owner

Implemented in commit 1721edd.

Changes:

  • Added one reusable Inventory container with total and per-resource capacities.
  • Bank, fleet, buildings, and extractors now use Inventory rather than per-resource storage fields.
  • Manual transfer and logistics move arbitrary resource IDs through the generic API.
  • Existing rocks/gas cargo names are computed compatibility accessors, not storage.
  • Legacy building and extractor stock is absorbed and removed on first access.
  • Added ResourceDefinition entries with composed glyph scenes; menus enumerate the definition catalog.
  • Removed ore/gas matches from GameState transfer/storage and ResourceGlyph.

Verification:

  • New test_generic_inventory.gd proves an unrecognized third material moves bank → fleet → building → fleet, is conserved, respects capacities, and migrates legacy state.
  • Ore/gas transfer, resource UI, manual supply, transporter supply, production stock, extractor income, fleet cargo, lab resources, and general resource/building tests pass.
  • Transfer menu screenshot verified at 720x1280.
Implemented in commit 1721edd. Changes: - Added one reusable Inventory container with total and per-resource capacities. - Bank, fleet, buildings, and extractors now use Inventory rather than per-resource storage fields. - Manual transfer and logistics move arbitrary resource IDs through the generic API. - Existing rocks/gas cargo names are computed compatibility accessors, not storage. - Legacy building and extractor stock is absorbed and removed on first access. - Added ResourceDefinition entries with composed glyph scenes; menus enumerate the definition catalog. - Removed ore/gas matches from GameState transfer/storage and ResourceGlyph. Verification: - New test_generic_inventory.gd proves an unrecognized third material moves bank → fleet → building → fleet, is conserved, respects capacities, and migrates legacy state. - Ore/gas transfer, resource UI, manual supply, transporter supply, production stock, extractor income, fleet cargo, lab resources, and general resource/building tests pass. - Transfer menu screenshot verified at 720x1280.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#33
No description provided.