Task #24: nights by count, per-night enemy speed and HP

- Plans load by count: FarmSim.night_plan_path(n) ("res://game/resources/nights/night_%d.tres")
  for n in 1..campaign_nights (FarmSim.load_night_plans). A missing file is a push_error and
  that night plays the last plan that loaded. FarmSim.NIGHT_PLANS is gone. campaign_nights
  stays 5.
- NightPlan.enemy_speed_scale / enemy_hp_scale (default 1; problems() flags non-positive ones).
  At nightfall WaveDirector._on_phase_changed hands tonight's plan (or the F2 debug plan) to
  EnemySystem.night_speed_scale / night_hp_scale, and the morning puts them back to 1.
  EnemySystem.full_hp(type) = maxi(t_hp, floori(t_hp * night_hp_scale)) at spawn; steering
  and max_speed() use t_speed * night_speed_scale (fleeing and carrying are shares of it).
  Enemies have no HP bar (only structures do), and the co-op replica never simulates enemy HP,
  so the wire format and CoopSession.PROTOCOL (5) are unchanged.
- Debug F3 / Shift+F3 (CampaignDebug.jump_morning; debug builds, morning review only, not on
  a co-op partner's machine): next / previous day's morning with the farm as it is and
  nights_survived = night - 1. It grants the Workbench and grows crops_total as a night's end
  does, then re-enters the morning through CampaignController.load_state with save_path
  blanked, so there's no autosave.
- test_nights: plan paths load in order (and a missing one repeats the last), spawn HP and
  speed at default and 1.6 scales, and the F3 / Shift+F3 jump.
- RULES.md (The enemies: per-night scales), PLAYTEST.md (NIGHT_PLANS note), GameConfig
  campaign_nights comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 16:05:12 -04:00
parent 6a9575dfe4
commit 192a89770a
9 changed files with 259 additions and 22 deletions

View file

@ -190,7 +190,11 @@ func step(dt: float) -> void:
_next += 1
## Nightfall: tonight's arrivals are queued and its enemy scales (NightPlan.enemy_speed_scale and
## enemy_hp_scale; the debug plan's when set) go to EnemySystem, until the morning (then 1 again).
func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignController.Phase) -> void:
if phase == CampaignController.Phase.MORNING:
_set_enemy_scales(null)
if phase != CampaignController.Phase.NIGHT:
return
night_time = 0.0
@ -199,9 +203,16 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
_queue.clear()
_next = 0
var plan := tonight()
_set_enemy_scales(plan)
if plan != null:
for g in plan.groups:
var every := NightPlan.scaled_every(g, plan.spacing_scale_in(config))
for k in NightPlan.scaled_count(g, plan.count_scale_in(config)):
_queue.append([float(g.get("time", 0.0)) + k * every, want_of(g), type_of(g)])
_queue.sort_custom(func(a: Array, b: Array) -> bool: return float(a[0]) < float(b[0]))
## A plan's enemy scales on EnemySystem (1 and 1 without a plan, or for a scale that isn't positive).
func _set_enemy_scales(plan: NightPlan) -> void:
enemies.night_speed_scale = plan.enemy_speed_scale if plan != null and plan.enemy_speed_scale > 0.0 else 1.0
enemies.night_hp_scale = plan.enemy_hp_scale if plan != null and plan.enemy_hp_scale > 0.0 else 1.0