Merge task #7: Potato Cannon, Shurikens, Propane Torch, Alien Ray (shed weapons)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-05 15:40:51 -04:00
commit 72e84f14e2
9 changed files with 399 additions and 62 deletions

View file

@ -114,7 +114,8 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
var es := sim.enemies
var st := sim.structures
c.begin_day()
s.resources.shed = {"wood": 200, "scrap": 200, "straw": 200}
s.resources.shed = {"wood": 200, "scrap": 200, "straw": 200, "alien_goop": 200}
s.night_events["gathered_alien_goop"] = cfg.hidden_reveal_goop # so the Alien Ray (#7, hidden) buys below
var fence := st.place("fence", 8.0, -8.0, 0)
_settle(sim)
var before := {

View file

@ -38,6 +38,7 @@ func run(r: GameTestRunner) -> void:
_offhand(r, sim)
_bombs(r, sim)
_hud(r, farm, sim)
_shed_weapons(r, farm, sim)
sim.enemies.behavior = keep
farm.queue_free()
await r.process_frame
@ -48,7 +49,10 @@ func _start(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
r.check(c.weapon == W.PITCHFORK and c.owns(W.PITCHFORK) and not c.owns(W.CORN_SHOOTER) and not c.owns(W.PUMPKIN_BOMB)
and c.offhand == -1, "a new vacation: the pitchfork in hand, and nothing else (the off-hand empty)")
var pivots := c.models._pivots
r.check(pivots.size() == 3 and pivots[0].visible and not pivots[1].visible and not pivots[2].visible, "only the pitchfork shows on the scarecrow")
var only_pitchfork := pivots[0].visible
for i in range(1, pivots.size()):
only_pitchfork = only_pitchfork and not pivots[i].visible
r.check(pivots.size() == ScarecrowCombat.WEAPON_IDS.size() and only_pitchfork, "only the pitchfork shows on the scarecrow")
var near := true
for p in pivots:
near = near and p.global_position.distance_to(player.global_position) < 3.0
@ -313,7 +317,9 @@ func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
hud._process(0.0)
var rows: Array = hud._weapon_rows.map(func(l: Label) -> String: return l.text)
var off: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
r.check(rows == ["1 Pitchfork", "2 Corn shooter (supply shed)"], "the HUD lists the main weapons by number: %s" % [rows])
r.check(rows == ["1 Pitchfork", "2 Corn shooter (supply shed)", "Potato cannon (supply shed)",
"Shurikens (supply shed)", "Propane torch (supply shed)", "Alien ray (supply shed)"],
"the HUD lists the main weapons, the first two by number (no more number keys): %s" % [rows])
r.check(charged == ["Pumpkin bombs"] and off == ["Pumpkin bombs %.0f s" % ceilf(cfg.bomb_cooldown)],
"and the off-hand's bombs, with their recharge: %s, %s" % [charged, off])
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab") and hud._offhand_title.text.contains("right mouse"),
@ -324,6 +330,75 @@ func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
_step(sim, 1)
## Task #7's four shed weapons (Potato Cannon, Shurikens, Propane Torch, Alien Ray): each
## purchasable at the supply shed, equippable, and deals damage. The Alien Ray stays hidden until
## enough Alien Goop is collected (Upgrades.revealed), then buys and works like the others.
func _shed_weapons(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
var c := sim.combat
var cfg := sim.config
var s := sim.campaign.state
var panel := farm.get_node("Hud/ShedPanel") as UpgradePanel
s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999, "alien_goop": 999}
c.equip(W.PITCHFORK)
c.ready_for_morning()
_step(sim, 1)
# The Alien Ray is hidden until enough Alien Goop is collected (Decision 11 / #5's pattern).
s.night_events.erase("gathered_alien_goop")
panel.refresh()
r.check(not Upgrades.revealed(s, cfg, "alien_ray") and (panel._rows["alien_ray"] as Button).text == "?",
"the Alien Ray stays a \"?\" in the shop until enough Alien Goop is collected")
r.check(not Upgrades.buy(sim.campaign, "alien_ray").contains("done:") and not Upgrades.owned(s, "alien_ray"),
"and can't be bought yet")
s.night_events["gathered_alien_goop"] = cfg.hidden_reveal_goop
r.check(Upgrades.revealed(s, cfg, "alien_ray"), "revealed once hidden_reveal_goop is collected")
_buy_equip_hit(r, farm, sim, "potato_cannon", W.POTATO_CANNON, cfg.potato_cannon_speed)
_buy_equip_hit(r, farm, sim, "shurikens", W.SHURIKENS, cfg.shuriken_speed)
_buy_equip_hit(r, farm, sim, "alien_ray", W.ALIEN_RAY, cfg.alien_ray_speed)
# Propane Torch: a sustained cone, not a projectile, so its tick lands the same step.
var es := sim.enemies
r.check(not c.owns(W.PROPANE_TORCH), "the propane torch isn't owned yet")
panel._buy("propane_torch")
r.check(Upgrades.owned(s, "propane_torch") and c.owns(W.PROPANE_TORCH), "it's purchasable at the supply shed")
r.check(c.equip(W.PROPANE_TORCH) and c.weapon == W.PROPANE_TORCH, "and equippable")
var target := es.spawn(THIEF, AT.x + cfg.torch_range - 0.5, AT.y, Vector2.LEFT)
_step(sim, 1)
var hp := _hp(es, target)
var ticks := c.torch_ticks
r.check(c.attack_toward(AT + Vector2(cfg.torch_range + 1.0, 0.0)) and c.torch_ticks == ticks + 1, "it fires its first tick")
var d := es.resolve_handle(target)
r.check(d < 0 or es.health[d] < hp, "and burns the nearest enemy in its cone for torch_damage")
_clear(sim)
c.equip(W.PITCHFORK)
## Buys id at the supply shed, equips w, and checks that a shot fired at a thief some meters off
## damages it once it arrives (speed m/s: how long to wait).
func _buy_equip_hit(r: GameTestRunner, farm: Node3D, sim: FarmSim, id: String, w: int, speed: float) -> void:
var c := sim.combat
var s := sim.campaign.state
var es := sim.enemies
var panel := farm.get_node("Hud/ShedPanel") as UpgradePanel
r.check(not c.owns(w), "%s isn't owned yet" % id)
panel._buy(id)
r.check(Upgrades.owned(s, id) and c.owns(w), "%s is purchasable at the supply shed" % id)
r.check(c.equip(w) and c.weapon == w, "and equippable")
var dist := 4.0
var target := es.spawn(THIEF, AT.x + dist, AT.y, Vector2.LEFT)
_step(sim, 1)
var hp := _hp(es, target)
r.check(c.attack_toward(AT + Vector2(dist + 2.0, 0.0)), "%s fires" % id)
var ticks := ceili(dist / speed * Engine.physics_ticks_per_second) + 15
var dropped := false
for i in ticks:
_step(sim, 1)
var d := es.resolve_handle(target)
if d < 0 or es.health[d] < hp:
dropped = true
break
r.check(dropped, "%s deals damage once its shot arrives" % id)
_clear(sim)
func _tap(sim: FarmSim, action: String) -> void:
Input.action_press(action)
_step(sim, 1)