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:
parent
ff2ace9d3c
commit
df10a1967c
10 changed files with 272 additions and 21 deletions
|
|
@ -206,6 +206,9 @@ func _five_nights(r: GameTestRunner, farm: Node3D, sim: FarmSim, player: PlayerC
|
|||
var hud := farm.get_node("Hud/PhaseHud") as PhaseHud
|
||||
c.new_campaign()
|
||||
_step(sim, 1)
|
||||
sim.structures.grant_workbench() # #9: granted once, up front, so the per-night structure
|
||||
# count below (broken aside) doesn't trip over the night-1 grant itself
|
||||
c._morning_snapshot = c.state.to_dict() # ...and this morning's snapshot (the loop checks it) agrees
|
||||
sim.waves.enabled = true
|
||||
player.global_position = AWAY
|
||||
var arrivals := {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue