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
|
|
@ -131,7 +131,10 @@ func refresh() -> void:
|
|||
lines.append("In the shed: %s. In the pouch: %s." % [_or_none(ResourceStore.describe(r.shed)), _or_none(ResourceStore.describe(r.pouch))])
|
||||
var plan := waves.tonight() if waves != null else null
|
||||
if plan != null and plan.title != "":
|
||||
lines.append("Tonight: %s. Upgrades at the work area: %d of %d done." % [plan.title, _upgrades_done(), Upgrades.ORDER.size()])
|
||||
if structures != null and structures.has_workbench():
|
||||
lines.append("Tonight: %s. Upgrades at the work area: %d of %d done." % [plan.title, _upgrades_done(), Upgrades.ORDER.size()])
|
||||
else: # #9: the Workbench hasn't been granted yet -- it arrives once Night 1 is survived
|
||||
lines.append("Tonight: %s. The work area will be set up once you survive tonight." % plan.title)
|
||||
_body.text = "\n".join(lines)
|
||||
_start.grab_focus.call_deferred()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue