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
|
|
@ -188,6 +188,10 @@ extends Resource
|
|||
@export_range(1, 500) var gate_hp: int = 30
|
||||
@export_range(1, 500) var trap_triggers: int = 10
|
||||
@export_range(1, 500) var turret_hp: int = 25
|
||||
## The Workbench (#9): not built by the player (it's granted once Night 1 is survived --
|
||||
## StructureSystem.grant_workbench()), but it has HP, can be damaged, and is repaired like any
|
||||
## other structure (repair-only: it stays, broken, at 0 HP instead of being destroyed).
|
||||
@export_range(1, 500) var workbench_hp: int = 50
|
||||
## A ground enemy crossing a slowing trap moves at this share of its speed for this long.
|
||||
@export_range(0.05, 1.0) var trap_slow_factor: float = 0.5
|
||||
@export var trap_slow_time: float = 2.0
|
||||
|
|
@ -379,6 +383,8 @@ func structure_hp(type: String) -> int:
|
|||
return gate_hp
|
||||
"slowing_trap":
|
||||
return trap_triggers
|
||||
"workbench":
|
||||
return workbench_hp
|
||||
return turret_hp
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue