120 lines
6.7 KiB
GDScript
120 lines
6.7 KiB
GDScript
|
|
extends RefCounted
|
||
|
|
var checks = 0
|
||
|
|
var failures = 0
|
||
|
|
func check(ok, message):
|
||
|
|
checks += 1
|
||
|
|
if not ok: failures += 1; push_error("ARCADE QA: " + message)
|
||
|
|
|
||
|
|
func clear(g):
|
||
|
|
g.reset_shift(); g.game_started = true; g.paused = false; g.set_process(false)
|
||
|
|
|
||
|
|
func soul(g, kind):
|
||
|
|
g.workshop.spawn()
|
||
|
|
var s = g.souls.back(); s.entering = false; s.entry_time = 1
|
||
|
|
s.required = [kind]; s.served = []; g.set_soul_reveal(s.visual, 1)
|
||
|
|
return s
|
||
|
|
|
||
|
|
func run(g):
|
||
|
|
await g.get_tree().create_timer(.3).timeout
|
||
|
|
g.start_game(); clear(g)
|
||
|
|
var w = g.workshop; var a = w.arcade
|
||
|
|
var d = w.add_station(4, Vector3(3,0,0)); var s = soul(g,4)
|
||
|
|
w.attach(s,0); w.step_station(d,.5,false); g.player.position = w.approach(d)
|
||
|
|
# The actual workshop loop runs unattended, without holding any button.
|
||
|
|
w.update(.1)
|
||
|
|
check(d.elapsed > 0, "occupied apparatus works unattended")
|
||
|
|
check(is_equal_approx(a.production(d), .6), "unattended baseline is 60 percent")
|
||
|
|
check(a.tap(0), "nearby occupied station accepts pulse")
|
||
|
|
check(not a.tap(0), "duplicate same-frame event ignored")
|
||
|
|
var slow = a.tempo(d)
|
||
|
|
for i in range(6): a.update(1.0/6.0); a.tap(0)
|
||
|
|
check(a.tempo(d) > slow and a.tempo(d) > 2.7 and a.tempo(d) <= 3.0, "six clicks per second ramp to bounded boost")
|
||
|
|
var charge = a.charge
|
||
|
|
g.paused = true; var time = a.clock; w.update(2)
|
||
|
|
check(a.clock == time and a.charge == charge and not a.tap(0), "pause freezes abilities and rejects clicks")
|
||
|
|
g.paused = false; a.update(1.3)
|
||
|
|
check(is_equal_approx(a.tempo(d),1), "pulse decays fully after stopping")
|
||
|
|
g.player.position = Vector3(-6,0,4)
|
||
|
|
check(not a.tap(0), "remote station cannot be boosted")
|
||
|
|
g.player.position = w.approach(d)
|
||
|
|
var event = InputEventMouseButton.new(); event.button_index = MOUSE_BUTTON_RIGHT; event.pressed = true
|
||
|
|
check(w.input(event) and a.tempo(d)>1, "right-click routes to pulse")
|
||
|
|
a.update(1.3); event.pressed = false; w.input(event)
|
||
|
|
check(a.tempo(d)==1, "button release never adds a pulse")
|
||
|
|
a.charge = 99; check(not a.activate(), "incomplete frenzy cannot activate")
|
||
|
|
a.add_charge(50); check(a.charge==100 and a.activate(), "full meter activates once")
|
||
|
|
check(not a.activate() and a.charge==0 and a.frenzy==10, "frenzy cannot stack")
|
||
|
|
check(is_equal_approx(a.production(d),1.2), "frenzy doubles passive production")
|
||
|
|
a.add_charge(20); check(a.charge==0, "frenzy cannot charge itself")
|
||
|
|
g.paused=true; w.update(20); check(a.frenzy==10, "pause preserves frenzy duration")
|
||
|
|
g.paused=false; a.update(10); check(a.frenzy==0, "frenzy expires")
|
||
|
|
w.automation=true; w.add_helper(); d.operator=0
|
||
|
|
check(is_equal_approx(a.production(d),1), "staffed automatic station retains full speed")
|
||
|
|
clear(g); d=w.add_station(0,Vector3(3,0,0))
|
||
|
|
g.player.position=Vector3(-5,0,0)
|
||
|
|
for i in range(7):
|
||
|
|
s=soul(g,0); s.node.position=Vector3(-5,0,float(i)*.1)
|
||
|
|
a.charm()
|
||
|
|
check(a.followers.size()==3 and w.queued().size()==4, "charm collects three free souls")
|
||
|
|
check(not w.sentences.pickup(w.queued()[0]) and g.held<0, "manual pickup cannot exceed charm capacity")
|
||
|
|
check(w.queue_load()==7 and not w.spawn(), "charmed souls retain queue slots")
|
||
|
|
a.charm(); check(a.followers.size()==3, "repeated charm respects capacity")
|
||
|
|
w.add_helper(); w.update_helpers(.01)
|
||
|
|
check(not w.helpers[0].soul in a.followers, "helpers do not steal charmed souls")
|
||
|
|
a.release()
|
||
|
|
check(a.followers.is_empty() and w.queue_load()==7, "release restores queue without overflow")
|
||
|
|
clear(g); d=w.add_station(4,Vector3(3,0,0)); s=soul(g,4)
|
||
|
|
g.player.position=Vector3(-5,0,0); s.node.position=g.player.position
|
||
|
|
a.charm(); var before=s.node.position
|
||
|
|
g.player.position=Vector3(-4,0,1); a.follow(.2)
|
||
|
|
check(s.node.position!=before and s.state=="charmed", "charmed soul follows moving hero")
|
||
|
|
g.player.position=w.approach(d); a.follow(.1)
|
||
|
|
check(s.state=="mounted" and d.soul==s.id and a.followers.is_empty() and a.charge==10, "nearby matching station receives soul once")
|
||
|
|
a.follow(.1); check(a.charge==10, "delivery charge not repeated")
|
||
|
|
w.step_station(d,.5,false)
|
||
|
|
for i in range(200): w.step_station(d,.05,true,a.production(d),true)
|
||
|
|
check(g.done==1 and g.souls.is_empty(), "autonomous cycle yields exactly one reward")
|
||
|
|
check(a.charge==15, "completion adds charge once")
|
||
|
|
clear(g); d=w.add_station(0,Vector3(3,0,0)); s=soul(g,0); s.required=[0,4]
|
||
|
|
w.attach(s,0); w.step_station(d,.5,false)
|
||
|
|
for i in range(5): w.step_station(d,.5,true)
|
||
|
|
g.player.position=w.approach(d); a.charm()
|
||
|
|
check(s.state=="charmed" and a.followers.size()==1, "charm can collect intermediate completed soul")
|
||
|
|
w.step_station(d,20,false)
|
||
|
|
check(g.index_of(s.id)>=0, "carried intermediate soul is not burned at origin")
|
||
|
|
a.release(); check(s.state=="ready" and d.soul==s.id, "release restores intermediate station pose")
|
||
|
|
a.charge=100; a.activate(); clear(g)
|
||
|
|
check(a.charge==0 and a.frenzy==0 and a.followers.is_empty(), "new shift clears all transient abilities")
|
||
|
|
d=w.add_station(4,Vector3(3,0,0)); w.rebuild_nav()
|
||
|
|
for i in range(3):w.add_helper()
|
||
|
|
check(w.helpers.all(func(h):return h.root.position.distance_to(g.GATE_EXIT)<3), "helpers spawn near entrance")
|
||
|
|
check(w.helpers[0].root.position.distance_to(w.helpers[1].root.position)>=.85, "helper spawn positions do not overlap")
|
||
|
|
var starts=w.helpers.map(func(h):return h.root.position)
|
||
|
|
await g.get_tree().physics_frame
|
||
|
|
for i in range(80):w.update_helpers(.05)
|
||
|
|
check(w.helpers.all(func(h):return h.root.position.distance_to(starts[w.helpers.find(h)])>.5), "all idle helpers stroll")
|
||
|
|
check(w.helpers.all(func(h):return not w.mesh_walking.blocked(Vector2(h.root.position.x,h.root.position.z),.28)), "roaming avoids apparatus geometry")
|
||
|
|
var before_pause=w.helpers[0].root.position
|
||
|
|
g.paused=true; w.update(3)
|
||
|
|
check(w.helpers[0].root.position==before_pause, "pause freezes roaming")
|
||
|
|
g.paused=false; s=soul(g,4); s.node.position=Vector3(-5,0,0)
|
||
|
|
w.update_helpers(.01)
|
||
|
|
check(w.helpers.any(func(h):return h.state in ["collect","deliver"] and h.get("roam_target")==null), "work interrupts roaming immediately")
|
||
|
|
var worker=w.helpers.filter(func(h):return h.state in ["collect","deliver"])[0]
|
||
|
|
for i in range(400):w.update_helpers(.05)
|
||
|
|
check(s.state=="mounted" and d.soul==s.id, "roaming helper completes delivery")
|
||
|
|
w.rebuild_nav(); w.update_helpers(.05)
|
||
|
|
check(w.helpers.filter(func(h):return h.state=="idle").all(func(h):return h.roam_revision==w.revision), "roaming replans after layout changes")
|
||
|
|
clear(g)
|
||
|
|
# Capture the actual in-game HUD with occupied apparatus and active boost.
|
||
|
|
d=w.add_station(4,Vector3(3,0,0)); s=soul(g,4); w.attach(s,0); w.step_station(d,.5,false)
|
||
|
|
g.player.position=w.approach(d); g.orbit.update(10)
|
||
|
|
a.charge=100; a.activate()
|
||
|
|
for i in range(6):a.update(1.0/6.0);a.tap(0)
|
||
|
|
w.sentences.update_icons(); g.hud.show(); a.refresh()
|
||
|
|
await g.get_tree().process_frame
|
||
|
|
await g.get_tree().process_frame
|
||
|
|
g.save_capture("idle-arcade")
|
||
|
|
if failures==0: print("ALL IDLE ARCADE TESTS PASSED (%d)"%checks)
|
||
|
|
g.get_tree().quit(1 if failures else 0)
|