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

@ -3,8 +3,9 @@ extends Resource
## One night (the plan's NightDefinition): its title, the hint shown at dusk, an optional length,
## and groups of enemies, each arriving at a time into the night. Where is not planned: every
## enemy arrives at its own random point along the farm's edge (WaveDirector).
## game/resources/nights/night_1..5.tres are the vacation's nights; game/resources/scenarios/
## holds debug plans.
## game/resources/nights/night_<n>.tres, for n in 1..GameConfig.campaign_nights
## (FarmSim.night_plan_path), are the vacation's nights; game/resources/scenarios/ holds debug
## plans.
## time seconds after nightfall when the group's first enemy arrives
## count how many arrive
## every seconds between them
@ -13,7 +14,9 @@ extends Resource
## The plans are the nights' designs; GameConfig.wave_count_scale and wave_spacing_scale scale
## every group when the night is played (count_scale x the enemies, spacing_scale x the time
## between them), so the whole vacation's pressure is tuned in one place. A plan can set its own
## scales instead (night 1 plays as designed, at 1 and 1).
## scales instead (night 1 plays as designed, at 1 and 1). enemy_speed_scale and enemy_hp_scale
## make tonight's enemies faster and tougher than GameConfig.enemy_types says (WaveDirector hands
## them to EnemySystem at nightfall).
@export var title: String = ""
## What the HUD tells the player at dusk about tonight.
@ -23,6 +26,10 @@ extends Resource
## This night's own scales; 0 uses GameConfig.wave_count_scale / wave_spacing_scale.
@export var count_scale: float = 0.0
@export var spacing_scale: float = 0.0
## Tonight's enemies move at speed x this (fleeing and carrying too, as shares of it), and arrive
## with HP x this, rounded down but never below the type's own (a 1 HP crow stays one hit).
@export var enemy_speed_scale: float = 1.0
@export var enemy_hp_scale: float = 1.0
@export var groups: Array[Dictionary] = []
@ -52,11 +59,13 @@ func total(count_scale: float = 1.0) -> int:
## What's wrong with the plan (empty when it's fine): unknown enemy types, a target the type
## doesn't take, or arrivals outside the night (as scaled).
## doesn't take, arrivals outside the night (as scaled), or an enemy scale that isn't positive.
func problems(length: float, count_scale: float = 1.0, spacing_scale: float = 1.0) -> PackedStringArray:
var out := PackedStringArray()
if groups.is_empty():
out.append("no groups")
if enemy_speed_scale <= 0.0 or enemy_hp_scale <= 0.0:
out.append("enemy scales must be positive")
for k in groups.size():
var g: Dictionary = groups[k]
var where := "group %d" % (k + 1)