Task #9: Workbench auto-grants after Night 1, destructible/repairable

Gate the Workbench to appear once Night 1 is survived instead of being
buildable: StructureSystem.grant_workbench() (an unvalidated, unpurchased
place() variant, grant()) adds a "workbench" structure record at the scene
node's position, reusing the existing damage/repair/targeting/save pipeline
end to end. The grant happens on CampaignController.night_ending (so it
lands in state before the morning snapshot, like #13's crop growth) and is
re-derived from FarmState.nights_survived on load/retry (sync_from_state).

The Workbench's view is the scene's own node (hidden until granted, shown
by StructureSystem._add_view) instead of a second built mesh, so it gets
the standard HP bar, damage tint, and wobble for free. It's repair-only:
damage() never removes its record at 0 HP ("broken" instead of destroyed),
and it can't be dismantled. Interactions refuses to open its shop before
it exists or while broken (and no longer treats it as focusable), and
coop_session.gd's "buy" request handler refuses a workbench-shop item
(Upgrades.shop_of) the same way for a co-op partner. review_panel.gd's
pre-grant summary line no longer promises the work area from night one.

No FarmState.VERSION bump: a "workbench" record is a new type string, not
a new field, and from_dict() already validates types generically.

Tests: a new test_structures.gd check covers absent/no-prompt/shop-refused
before Night 1 (including a co-op "buy" request), granted after, damaged
by an enemy (thief_behavior.gd's generic BREAK state), broken-not-destroyed
at 0 HP with its shop refused, repaired at the normal proportional cost,
and persistence through a save/retry round trip. test_cycle.gd and
test_nights.gd pre-grant the workbench in setup (grant_workbench()) so
their per-night structure-count invariants aren't thrown off by the
night-1 grant itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-05 16:27:55 -04:00
parent ff2ace9d3c
commit df10a1967c
10 changed files with 272 additions and 21 deletions

View file

@ -24,6 +24,8 @@ func run(r: GameTestRunner) -> void:
sim.waves.rng.seed = 1 # tonight's 11 arrival points, drawn the same every run
var player := farm.get_node("Player") as PlayerCharacter
player.global_position = AWAY
sim.structures.grant_workbench() # #9: granted up front so it doesn't shift the structure
# counts this test tracks across night 1 (it isn't about the Workbench itself)
var review := farm.get_node("Hud/ReviewPanel") as ReviewPanel
var hud := farm.get_node("Hud/PhaseHud") as PhaseHud
var assets := farm.get_node("Hud/AssetHud") as AssetHud