#46: sprint becomes a permanent speed upgrade

Owning the Sprint upgrade now multiplies the scarecrow's speed by
sprint_speed_mult (1.25) all the time, walking and running, on every
platform; the run clip speeds up to match. The hold-to-sprint burst is
gone: sprint_time, sprint_cooldown, the stamina state in PlayerCharacter
(can_sprint is now has_sprint), and the HUD's stamina bar. The upgrade
keeps its id, cost, and name; its text is "Run 25% faster, always".
The sprint input action stays in project.godot, unused.

Tests: test_scarecrow's sprint checks cover 1x without it, x1.25 with it
(run and walk, clip speed, network strength), 30 s with no time limit,
no cooldown, the next morning, and no platform dependence; test_nights
checks it after the retry and a loaded save; test_economy checks the
text matches the multiplier, the menu row, and that an old save's
{"sprint": 1} still owns it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-14 14:32:39 -04:00
parent f0291133fd
commit 962c7b0b93
9 changed files with 138 additions and 149 deletions

View file

@ -263,7 +263,8 @@ func _hidden_items(r: GameTestRunner) -> void:
## multipliers multiply). upgrades_bought counts every level. The menu names the next level
## ("Heavy seeds II") with its text and cost, says when it opens, and shows "Max" at the end.
## Levels survive a save, the next morning, and a retry, and an old save's {"rapid_fire": 1}
## loads as level 1.
## loads as level 1. Sprint (#46) is a speed upgrade now: its text names sprint_speed_mult, the
## menu offers it as that, and an old save's {"sprint": 1} still owns it (the id is unchanged).
func _tiers(r: GameTestRunner) -> void:
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
var cfg := c.config
@ -275,6 +276,11 @@ func _tiers(r: GameTestRunner) -> void:
r.check(tiered == 9 and Upgrades.max_level(cfg, "sprint") == 1 and Upgrades.max_level(cfg, "corn_shooter") == 1
and Upgrades.max_level(cfg, "alien_ray") == 1 and Upgrades.max_level(cfg, "radar") == 1,
"the nine stat upgrades have 3 levels; Sprint, the weapons, and Radar one (%d with 3)" % tiered)
var defaults := GameConfig.new()
var says := "Run %d%% faster, always"
r.check(Upgrades.text_at(cfg, "sprint", 1) == says % roundi((cfg.sprint_speed_mult - 1.0) * 100.0)
and Upgrades.text_at(defaults, "sprint", 1) == says % roundi((defaults.sprint_speed_mult - 1.0) * 100.0),
"Sprint says what it does: '%s' (x%.2f; game_config.gd's defaults agree)" % [Upgrades.text_at(cfg, "sprint", 1), cfg.sprint_speed_mult])
# Costs grow.
var grows := true
for id: String in cfg.upgrades:
@ -304,6 +310,9 @@ func _tiers(r: GameTestRunner) -> void:
var row := panel._rows["heavy_seeds"] as Button
r.check(row.text == "Heavy seeds I — Each kernel does 2 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 1)) and not row.disabled,
"the menu offers level I: '%s'" % row.text)
var sprint_row := panel._rows["sprint"] as Button
r.check(sprint_row.text == "Sprint — %s (%s)" % [Upgrades.text_at(cfg, "sprint", 1), ResourceStore.describe(Upgrades.cost(cfg, "sprint", 1))]
and not sprint_row.disabled, "the menu offers Sprint as the speed upgrade: '%s'" % sprint_row.text)
var damage := cfg.shot_damage
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 1
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 1, "level 1 on day 1: kernels do %d damage" % (damage + 1))
@ -373,13 +382,15 @@ func _tiers(r: GameTestRunner) -> void:
"and a retry from that morning keeps them")
# A save from before levels: {"rapid_fire": 1} is level 1.
var old := c.state.to_dict()
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1}
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1, "sprint": 1}
var was := SaveGame.read(TIERS_SAVE).state if SaveGame.write(old, TIERS_SAVE) == OK else null
SaveGame.delete(TIERS_SAVE)
r.check(was != null and Upgrades.level(was, "rapid_fire") == 1 and Upgrades.owned(was, "rapid_fire")
and is_equal_approx(Upgrades.value(cfg, was, "fire_rate"), cfg.fire_rate * Upgrades.per_level(mult, 1))
and Upgrades.next_cost(cfg, was, "rapid_fire") == Upgrades.cost(cfg, "rapid_fire", 2),
"an old save's {\"rapid_fire\": 1} loads as level 1, with level 2 next")
r.check(was != null and Upgrades.owned(was, "sprint") and Upgrades.level(was, "sprint") == 1,
"and its {\"sprint\": 1} still owns Sprint, now the speed upgrade (same id)")
c.queue_free()