magicciv/.project/objectives/p0-18-strategic-resource-gate.md
Natalie 5172894326 feat(@projects/@magic-civilization): update strategic-resource-gate objective status
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-17 02:00:42 -07:00

2.8 KiB
Raw Blame History

id title priority status scope updated_at evidence
p0-18 Strategic resources gate unit production (empire ledger) p0 done game1 2026-04-17
src/simulator/crates/mc-combat/src/requirements.rs
src/simulator/crates/mc-turn/src/processor.rs
src/simulator/crates/mc-turn/src/game_state.rs
src/simulator/crates/mc-turn/src/combat_event.rs
public/resources/deposits/iron_ore.json
public/resources/deposits/horses.json
public/resources/deposits/coal_seam.json
src/game/engine/src/modules/management/unit_manager.gd
src/game/engine/src/autoloads/event_bus.gd
src/game/engine/src/autoloads/turn_manager.gd
src/game/engine/src/entities/player.gd
src/game/engine/src/modules/management/turn_processor.gd
src/game/engine/scenes/tests/auto_play.gd
public/games/age-of-dwarves/data/units/cavalry.json

Summary

Distinct from p1-02 (resource yields feed bonuses), this objective covers the gating rule: a unit with requires_resource: "iron_ore" cannot build unless the empire has iron_ore on the ledger. Rust logic landed in #81: mc-combat::requirements::{check_strategic_reqs, debit_resources, credit_resources} with 6 tests. GDScript deposit discovery hook added to unit_manager.gd:recalculate_vision (0→2 tile visibility triggers EventBus.deposit_discoveredturn_manager.gd credits player.strategic_ledger). GDScript production gate added to turn_processor.gd (pre-production check emits EventBus.strategic_gate_rejected and pauses production if ledger is empty). auto_play.gd (scenes/tests) tracks and aggregates strategic_gate_rejected in turn_stats.jsonl["aggregate"].

Acceptance

  • ✓ Building a swordsman (requires iron) fails with ResourceGate("iron") when empire has 0 iron on its ledger; succeeds and decrements the ledger to 0 otherwise.
  • ✓ Unit death returns 1 iron to the ledger (unit_manager.gd + auto_play.gd _on_unit_destroyed).
  • ✓ Deposit discovery (via scout exploration p0-13) credits iron onto the ledger when the tile first becomes visible (unit_manager.gd recalculate_vision 0→2 → deposit_discovered signal → turn_manager.gd _on_deposit_discovered).
  • ✓ 10-seed T300 batch (stamp 20260417_014802): all 10 seeds show strategic_gate_rejected in turn_stats.jsonl["aggregate"] (seed1=85, seed2=103, seed3=228, seed4=169, seed5=209, seed6=138, seed7=221, seed8=526, seed9=200, seed10=160). Batch: .local/batches/autoplay_p018_v5/.
  • ✓ Golden test: seed 42, build cavalry → iron debit → build second → ResourceGate → kill cavalry → iron credit → build third succeeds (Rust unit tests in mc-turn/src/processor.rs lines 30283104).

Non-goals

  • Resource trading via diplomacy (p1-01 trade agreements cover luxuries, not strategics for Game 1).
  • Strategic resource sell-to-treasury.