This commit is contained in:
Forrest 2026-10-04 17:30:48 -04:00
parent 4298caf5cb
commit 2e6638b744
19 changed files with 484 additions and 185 deletions

View file

@ -4,7 +4,7 @@ extends RefCounted
## by hand, tick by tick. Covers the join (the welcome, both scarecrows on both farms, names,
## co-op health), requests from the partner (start the day, build, buy), the partner's scarecrow
## moving, gathering, and shooting on the host (and its pick of weapon), the weapons' stabs and
## pumpkin bombs reaching the replica (drawn there, doing no damage of their own), enemies, loot,
## pumpkin bombs (thrown from the off-hand, not with the right click leaving build mode) reaching the replica (drawn there, doing no damage of their own), enemies, loot,
## and shots reaching the replica,
## the co-op fall rule (one down is out until morning, both down is Game Over) and Retry, message
## sizes with a crowd, dropped unreliable messages, and either side leaving.
@ -228,19 +228,36 @@ func _weapons_shown() -> void:
host.combat.equip(ScarecrowCombat.Weapon.PUMPKIN_BOMB)
host.combat.ready_for_morning()
var bursts := client.bombs.bursts
host.combat.attack_toward(Vector2(host.player.global_position.x + 6.0, host.player.global_position.z))
host.combat.offhand_toward(Vector2(host.player.global_position.x + 6.0, host.player.global_position.z))
_pump(3)
r.check(p1.weapon == ScarecrowCombat.Weapon.PUMPKIN_BOMB and client.bombs.flying() == 1, "P1's pumpkin bomb flies on the partner's farm too")
r.check(p1.weapon == ScarecrowCombat.Weapon.PITCHFORK and client.bombs.flying() == 1,
"P1's pumpkin bomb flies on the partner's farm too (from the off-hand: the pitchfork stays in hand there)")
_pump(90)
r.check(client.bombs.bursts == bursts + 1 and client.bombs.enemies_hit == 0 and host.bombs.flying() == 0,
"and bursts there, harmless (the host's burst does the damage)")
r.check(client.combat.equip(ScarecrowCombat.Weapon.PUMPKIN_BOMB), "the partner can take bombs up too (bought for both)")
r.check(client.combat.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB and host.partner.combat.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB,
"the partner has bombs in its off-hand too (bought for both)")
var thrown := host.partner.combat.bombs_thrown
Input.action_press("fire")
var attacks := host.partner.combat.attacks()
Input.action_press("offhand")
_pump(10)
Input.action_release("fire")
Input.action_release("offhand")
_pump(4)
r.check(host.partner.combat.bombs_thrown == thrown + 1 and client.combat.bomb_left > 0.0, "P2's throw happens on the host, and its recharge shows on the partner's HUD")
r.check(host.partner.combat.bombs_thrown == thrown + 1 and host.partner.combat.attacks() == attacks + 1 and client.combat.bomb_left > 0.0,
"the partner's right click throws on the host (and nothing else), and its recharge shows on the partner's HUD")
_pump(roundi(host.config.bomb_cooldown * 60.0) + 10)
client.build.set_active(true)
_pump(4)
thrown = host.partner.combat.bombs_thrown
Input.action_press("cancel") # the right mouse button: both actions
Input.action_press("offhand")
_pump(10)
var left := not client.build.active
Input.action_release("cancel")
Input.action_release("offhand")
_pump(4)
r.check(left and host.partner.combat.bombs_thrown == thrown,
"the partner's right click that leaves build mode throws nothing on the host, even held")
_pump(90)
for c: ScarecrowCombat in [host.combat, client.combat]:
c.equip(ScarecrowCombat.Weapon.PITCHFORK)

View file

@ -3,8 +3,9 @@ extends RefCounted
## main menu over the paused farm; New vacation, Continue, and their questions; pausing freezes
## the simulation tick; settings apply and persist from the pause menu; Restart the night and
## Save & quit to menu put the farm back at the saved morning without touching the save; a
## damaged save can't be continued; the failure screen and Retry; the farmers' return and the
## final assessment; the first day's and night's tips; and the sounds hooked to the game.
## damaged save can't be continued; quitting a hosted co-op game from the pause menu leaves the
## scarecrow unfrozen; the failure screen and Retry; the farmers' return and the final
## assessment; the first day's and night's tips; and the sounds hooked to the game.
const P := CampaignController.Phase
const SAVE := "user://test_flow_save.json"
@ -33,6 +34,7 @@ func run(p_r: GameTestRunner) -> void:
await _settings()
await _restart_and_quit_to_menu()
await _continue_and_new()
await _coop_quit_to_menu()
await _tutorial()
await _failure()
await _ending()
@ -196,6 +198,25 @@ func _continue_and_new() -> void:
"New vacation doesn't ask about a damaged save and replaces it")
## Hosting co-op, the pause menu freezes only this scarecrow; quitting to the menu from it must
## unfreeze it, or the next game (hosting again, or joining a friend's) has no aim or buttons.
func _coop_quit_to_menu() -> void:
var links := CoopLink.pair()
sim.coop.start_host(sim, links[0], "Ana", "Ben")
main.pause()
r.check(sim.local_frozen and not r.paused and sim.combat.remote != null, "hosting co-op, the pause menu freezes the scarecrow, not the farm")
main.pause_menu.menu_button.pressed.emit()
r.check(main.screen == Main.Screen.MENU and not sim.coop.is_active() and not sim.local_frozen and sim.combat.remote == null
and sim.scarecrow.remote == null and sim.interactions.remote == null and sim.player.input_enabled,
"quitting co-op to the menu unfreezes it")
links[1].close()
main.main_menu.continue_button.pressed.emit()
sim.combat.aim_point = Vector3.ZERO
await r.physics_frame
await r.physics_frame
r.check(main.screen == Main.Screen.PLAYING and sim.combat.aim_point != Vector3.ZERO, "and in the next game the aim follows the mouse again")
func _tutorial() -> void:
var t := sim.tutorial
t.done = {}

View file

@ -3,11 +3,13 @@ extends RefCounted
## pitchfork to start; its stab (in reach and in the arc of the aim only, the nearest few, its
## damage, once per interval, again and again while fire is held, not through a wall); the corn
## shooter and pumpkin bombs bought at the workbench (rapid fire and heavy seeds need the corn
## shooter first; a weapon bought goes into the hand); switching (Tab / 1-3, owned ones only, not
## in build mode; one no longer owned falls back to the pitchfork); a bomb's throw (at the aim,
## its range clamped), flight, and burst (everything in its radius, crows too, nothing beyond,
## not the scarecrow), its recharge and the morning refill; the models on the scarecrow; and the
## HUD's weapon panel.
## shooter first; a weapon bought goes into its hand, bombs into the off-hand); switching the main
## weapon (Tab / 1-2, owned ones only, not in build mode, never the bombs; one no longer owned
## falls back to the pitchfork); the off-hand on its own button (right mouse / LT: with the main
## weapon in hand, both at once, held, not with the right click that leaves build mode); a bomb's
## throw (at the aim, its range clamped), flight, and burst (everything in its radius, crows too,
## nothing beyond, not the scarecrow), its recharge and the morning refill; the models on the
## scarecrow; and the HUD's weapon panel.
const DT := 1.0 / 60.0
const AT := Vector2(0.0, 6.0) # open ground south-west of the pen
@ -32,6 +34,7 @@ func run(r: GameTestRunner) -> void:
await _wall(r, sim, farm)
_unlocks(r, farm, sim)
_switching(r, sim)
_offhand(r, sim)
_bombs(r, sim)
_hud(r, farm, sim)
sim.enemies.behavior = keep
@ -41,8 +44,8 @@ func run(r: GameTestRunner) -> void:
func _start(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
var c := sim.combat
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),
"a new vacation: the pitchfork in hand, and nothing else")
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 near := true
@ -132,8 +135,14 @@ func _unlocks(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
"the corn shooter is bought at the workbench; then rapid fire can be")
var panel := farm.get_node("Hud/UpgradePanel") as UpgradePanel
panel._buy("pumpkin_bomb")
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.weapon == W.PUMPKIN_BOMB, "a weapon bought from the menu goes into the hand")
r.check(combat.models._pivots[2].visible and not combat.models._pivots[0].visible, "and shows on the scarecrow")
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.offhand == W.PUMPKIN_BOMB and combat.weapon == W.PITCHFORK,
"pumpkin bombs bought from the menu go into the off-hand, the pitchfork staying in hand")
var pivots := combat.models._pivots
r.check(pivots[2].visible and pivots[0].visible and not pivots[1].visible, "both show on the scarecrow")
r.check(pivots[0].position.x > 0.0 and pivots[2].position.x < 0.0, "the pitchfork in the right hand, the pumpkin in the left")
s.upgrades.erase("corn_shooter")
panel._buy("corn_shooter")
r.check(combat.weapon == W.CORN_SHOOTER and combat.offhand == W.PUMPKIN_BOMB, "the corn shooter bought from the menu goes into the hand")
func _switching(r: GameTestRunner, sim: FarmSim) -> void:
@ -144,11 +153,15 @@ func _switching(r: GameTestRunner, sim: FarmSim) -> void:
for k in 3:
_tap(sim, "weapon_next")
seen.append(c.weapon)
r.check(seen == [W.CORN_SHOOTER, W.PUMPKIN_BOMB, W.PITCHFORK], "Tab / d-pad down cycles through them: %s" % [seen])
_tap(sim, "weapon_3")
var third := c.weapon
r.check(seen == [W.CORN_SHOOTER, W.PITCHFORK, W.CORN_SHOOTER] and c.offhand == W.PUMPKIN_BOMB,
"Tab / d-pad down cycles through the main weapons, the bombs staying in the off-hand: %s" % [seen])
_tap(sim, "weapon_1")
r.check(third == W.PUMPKIN_BOMB and c.weapon == W.PITCHFORK, "1-3 pick one")
var first := c.weapon
_tap(sim, "weapon_2")
r.check(first == W.PITCHFORK and c.weapon == W.CORN_SHOOTER, "1-2 pick one")
r.check(c.equip(W.PUMPKIN_BOMB) and c.weapon == W.CORN_SHOOTER and not InputMap.has_action("weapon_3"),
"the bombs never take the main hand (and there's no third weapon key)")
c.equip(W.PITCHFORK)
var east := AT + Vector2(5.0, 0.0)
_step(sim, c.stab_ticks())
c.attack_toward(east)
@ -162,18 +175,79 @@ func _switching(r: GameTestRunner, sim: FarmSim) -> void:
var building := c.weapon
sim.build.set_active(false)
r.check(building == W.PITCHFORK, "not in build mode (those keys pick structures there)")
s.upgrades.erase("pumpkin_bomb")
c.equip(W.CORN_SHOOTER)
_tap(sim, "weapon_next")
var skipped := c.weapon
_tap(sim, "weapon_3")
r.check(skipped == W.PITCHFORK and c.weapon == W.PITCHFORK, "only weapons owned: no pumpkin bombs without the upgrade")
c.equip(W.CORN_SHOOTER)
s.upgrades.erase("corn_shooter")
_step(sim, 1)
r.check(c.weapon == W.PITCHFORK, "one no longer owned (a retry from before it was bought) goes back to the pitchfork")
_tap(sim, "weapon_next")
var skipped := c.weapon
_tap(sim, "weapon_2")
r.check(skipped == W.PITCHFORK and c.weapon == W.PITCHFORK, "only weapons owned: no corn shooter without the upgrade")
s.upgrades.erase("pumpkin_bomb")
_step(sim, 1)
r.check(c.offhand == -1 and not c.models._pivots[2].visible and not c.use_offhand(), "bombs no longer owned leave the off-hand")
s.upgrades["corn_shooter"] = 1
s.upgrades["pumpkin_bomb"] = 1
_step(sim, 1)
r.check(c.offhand == W.PUMPKIN_BOMB, "and come back to it once owned")
## The off-hand's own button, with the corn shooter in hand.
func _offhand(r: GameTestRunner, sim: FarmSim) -> void:
var c := sim.combat
var cfg := sim.config
var recharge := roundi(cfg.bomb_cooldown * 60.0) + 2
c.equip(W.CORN_SHOOTER)
c.device = ScarecrowCombat.Device.GAMEPAD # keeps the aim it's given, and build mode's cursor in the open
c.aim = Vector2(1.0, 0.0)
c.ready_for_morning()
_step(sim, 1)
var thrown := c.bombs_thrown
var shots := c.shots_fired
_tap(sim, "offhand")
r.check(c.bombs_thrown == thrown + 1 and c.shots_fired == shots and c.weapon == W.CORN_SHOOTER,
"right mouse / LT throws a pumpkin bomb from the off-hand, the corn shooter staying in hand")
_step(sim, recharge)
Input.action_press("fire")
Input.action_press("offhand")
_step(sim, 1)
Input.action_release("fire")
Input.action_release("offhand")
_step(sim, 1)
r.check(c.bombs_thrown == thrown + 2 and c.shots_fired == shots + 1, "both at once: a shot and a throw")
_step(sim, recharge)
thrown = c.bombs_thrown
Input.action_press("offhand")
_step(sim, recharge + 2)
Input.action_release("offhand")
_step(sim, 1)
r.check(c.bombs_thrown == thrown + 2, "holding it throws the next one as soon as it's back in hand (%d)" % (c.bombs_thrown - thrown))
_step(sim, recharge)
# The right mouse button also leaves build mode (cancel): that click throws nothing.
sim.build.set_active(true)
_step(sim, 2)
thrown = c.bombs_thrown
Input.action_press("cancel")
Input.action_press("offhand")
_step(sim, 1)
var left := not sim.build.active
_step(sim, 30)
Input.action_release("cancel")
Input.action_release("offhand")
_step(sim, 1)
r.check(left and c.bombs_thrown == thrown, "the right click that leaves build mode throws no bomb, even held")
_tap(sim, "offhand")
r.check(c.bombs_thrown == thrown + 1, "the next click does")
c.ready_for_morning()
thrown = c.bombs_thrown
Input.action_press("offhand")
_step(sim, 3)
Input.action_release("offhand")
_step(sim, 1)
r.check(c.bombs_thrown == thrown, "a new morning needs a fresh press (held from the night before: nothing)")
sim.bombs.clear()
c.equip(W.PITCHFORK)
c.device = ScarecrowCombat.Device.MOUSE
func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
@ -181,7 +255,6 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
var cfg := sim.config
var es := sim.enemies
var kit := sim.scarecrow
c.equip(W.PUMPKIN_BOMB)
c.ready_for_morning()
var target := AT + Vector2(6.0, 0.0)
var on := es.spawn(THIEF, target.x, target.y, Vector2.LEFT)
@ -190,9 +263,10 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
var out := es.spawn(THIEF, target.x + cfg.bomb_radius + 2.0, target.y, Vector2.LEFT)
_step(sim, 1)
var hp := kit.hp()
r.check(c.attack_toward(target) and sim.bombs.flying() == 1 and is_equal_approx(c.bomb_left, cfg.bomb_cooldown),
var bursts := sim.bombs.bursts
r.check(c.offhand_toward(target) and sim.bombs.flying() == 1 and is_equal_approx(c.bomb_left, cfg.bomb_cooldown),
"a pumpkin bomb is thrown at the aim point")
r.check(not c.attack_toward(target), "only one every %.0f s" % cfg.bomb_cooldown)
r.check(not c.offhand_toward(target), "only one every %.0f s" % cfg.bomb_cooldown)
r.check(c.models._pivots[2].scale.x < 0.05, "it's gone from the hand")
var ticks := 0
while sim.bombs.flying() > 0 and ticks < 200:
@ -202,7 +276,7 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
r.check(ticks * DT >= PumpkinBombs.MIN_FLIGHT - DT and ticks * DT <= PumpkinBombs.MAX_FLIGHT + DT, "it flies %.2f s" % (ticks * DT))
r.check(es.resolve_handle(on) < 0 and es.resolve_handle(near) < 0 and es.resolve_handle(crow) < 0,
"its burst stops everything within %.0f m (%d damage), crows too" % [cfg.bomb_radius, cfg.bomb_damage])
r.check(_hp(es, out) == es.t_hp[THIEF] and kit.hp() == hp and sim.bombs.bursts == 1, "nothing beyond, and not the scarecrow")
r.check(_hp(es, out) == es.t_hp[THIEF] and kit.hp() == hp and sim.bombs.bursts == bursts + 1, "nothing beyond, and not the scarecrow")
_clear(sim)
c.device = ScarecrowCombat.Device.MOUSE
var me := Vector2(sim.player.global_position.x, sim.player.global_position.z)
@ -214,7 +288,7 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
"it lands %.0f .. %.0f m away (%.1f, %.1f)" % [cfg.bomb_min_range, cfg.bomb_range, short, long])
_step(sim, roundi(cfg.bomb_cooldown * 60.0) + 2)
r.check(c.bomb_left == 0.0 and c.models._pivots[2].scale.x > 0.99, "after %.0f s another one is in hand" % cfg.bomb_cooldown)
c.attack_toward(target)
c.offhand_toward(target)
c.ready_for_morning()
r.check(c.bomb_left == 0.0, "a new morning puts one in hand")
sim.bombs.clear()
@ -223,15 +297,22 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
var hud := farm.get_node("Hud/ScarecrowHud") as ScarecrowHud
var c := sim.combat
var cfg := sim.config
var s := sim.campaign.state
s.upgrades.erase("corn_shooter")
c.equip(W.PUMPKIN_BOMB)
c.attack_toward(AT + Vector2(6.0, 0.0))
c.ready_for_morning()
_step(sim, 1)
hud._process(0.0)
var rows := hud._weapon_rows.map(func(l: Label) -> String: return l.text)
r.check(rows[0] == "1 Pitchfork" and rows[1] == "2 Corn shooter (workbench)" and rows[2] == "3 Pumpkin bombs 4 s",
"the HUD lists the weapons: %s" % [rows])
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab"), "with how to switch")
var charged: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
c.offhand_toward(AT + Vector2(6.0, 0.0))
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 (workbench)"], "the HUD lists the main weapons by number: %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"),
"with how to switch, and the off-hand's button")
s.upgrades.erase("pumpkin_bomb")
_step(sim, 1)
sim.bombs.clear()