Files

87 lines
6.7 KiB
GDScript
Raw Permalink Normal View History

extends RefCounted
var failures=0
var checks=0
func check(ok,label):
checks+=1
if not ok:failures+=1;push_error("WORKFLOW QA: "+label)
func clear(g):
g.reset_shift();g.game_started=true;g.paused=false;g.coins=1000;g.set_process(false)
func soul(g,recipe):
g.workshop.spawn();var s=g.souls.back();s.entering=false;s.entry_time=1;s.required=recipe;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 d=w.add_station(4,Vector3(3,0,0));var s=soul(g,[4]);var start=s.node.position
check(w.attach(s,0),"attach starts particle transfer")
check(d.placement==.5 and s.node.position==d.device.position and d.transfer.sparks.size()==36,"half-second assembly at final pose, no body flight")
w.step_station(d,.25,true)
check(is_equal_approx(d.placement,.25) and d.elapsed==0,"work blocked during transfer")
check(d.transfer.sparks.all(func(spark):return spark.node.scale.length()<.12),"transfer uses tiny sparks rather than large glowing spheres")
g.paused=true;var clock=d.transfer.clock;w.update(5)
check(d.transfer.clock==clock,"assembly freezes during pause")
g.paused=false;w.step_station(d,.25,false)
check(d.placement==0 and d.transfer==null and d.idle_time==0,"assembly completes after exactly half a second")
w.step_station(d,9.99,false);check(d.soul==s.id and g.coins==1000,"station waits full ten seconds")
w.step_station(d,.01,false)
check(d.soul==-1 and g.souls.is_empty() and g.coins==950 and g.done==0 and g.development.xp==0 and g.essence==0,"idle soul burns, fine exactly 50, no rewards")
w.step_station(d,20,false);check(g.coins==950,"failed soul cannot charge twice")
clear(g);d=w.add_station(2,Vector3(3,0,0));s=soul(g,[2]);w.attach(s,0);w.step_station(d,.5,false)
w.step_station(d,9,false);w.step_station(d,.1,true);check(d.idle_time==0,"real work resets idle countdown")
w.step_station(d,9.99,false);check(d.soul==s.id,"ten consecutive idle seconds required")
w.step_station(d,.01,false);check(d.soul==-1 and g.coins==950,"interrupted wheel work expires once")
clear(g);d=w.add_station(0,Vector3(3,0,0));s=soul(g,[0,4]);w.attach(s,0);w.step_station(d,.5,false)
for i in range(5):w.step_station(d,.5,true)
check(d.ready and s.state=="ready","intermediate stage waits on apparatus")
w.step_station(d,10,false);check(d.soul==-1 and g.coins==950,"forgotten completed intermediate stage also burns")
clear(g);d=w.add_station(0,Vector3(3,0,0));var a=soul(g,[0]);var b=soul(g,[0]);w.add_helper();w.update_helpers(.001)
check(d.reserved==0,"queue head may be reserved for helper")
check(g.wisps.is_empty() and not w.helpers[0].root.get_children().any(func(node):return node is MeshInstance3D and node.mesh is TorusMesh),"blue orbiting markers and floor halos removed")
w.losses.queue_step(9.99);check(g.souls.size()==2 and g.coins==1000,"queue head gets ten seconds")
w.losses.queue_step(.01)
check(g.index_of(a.id)<0 and g.index_of(b.id)>=0 and g.coins==950 and w.losses.departures.size()==1,"one FIFO soul leaves and costs 50")
check(w.helpers[0].soul==-1 and d.reserved==-1,"expired queue reservation releases helper and apparatus")
w.losses.queue_step(.01);check(g.souls.size()==1 and g.coins==950,"next head starts its own countdown")
w.losses.queue_step(9.99);check(g.souls.is_empty() and g.coins==900,"one departure per ten seconds, not entire queue")
var z=w.losses.departures[0].node.position.z;w.losses.update_departures(.25)
check(w.losses.departures[0].node.position.z>z,"departed soul flies toward opposite gate")
g.paused=true;z=w.losses.departures[0].node.position.z;w.update(10)
check(w.losses.departures[0].node.position.z==z,"conveyor freezes on pause")
g.paused=false;w.losses.update_departures(10);check(w.losses.departures.is_empty() and g.coins==900,"departure cleanup has no second fine")
clear(g);g.coins=1500;w.toggle_build();var width=w.build_area().x
for i in range(3):
if i==0:
await g.get_tree().process_frame
await preload("res://workshop_tests.gd").new().click(g,w.expansion_button)
check(w.expansion_level==1,"buy first expansion with real mouse input")
else:check(w.purchase_expansion(),"buy expansion %d"%i)
check(is_equal_approx(w.build_area().x,width*1.2),"each purchase adds twenty percent of current area");width=w.build_area().x
check(g.coins==0 and w.expansion_level==3 and not w.purchase_expansion(),"three purchases cost 1500, fourth rejected")
check(g.architecture.growth.smog.size.x>28 and g.architecture.growth.smog.size.y<1.5,"knee-high fog covers entire expanded room")
check(w.valid_position(Vector3(16,0,0),0),"construction allowed in new right-hand area")
check(preload("res://room_growth.gd").neighbour_x(1)-7.9-g.architecture.growth.right_edge()>4,"full growth leaves over four metres clear of neighbouring floor")
d=w.add_station(0,Vector3(16,0,0));w.rebuild_nav();check(w.accessible(),"helper navigation reaches expanded area")
var saved=w.snapshot();w.reset();w.restore(saved)
check(w.expansion_level==3 and w.stations.size()==1 and is_equal_approx(w.stations[0].device.position.x,16),"expansion restored before extended apparatus placement")
w.reset();check(w.expansion_level==0 and is_equal_approx(g.architecture.growth.right_edge(),12),"new game restores original room bounds")
g.paused=false;d=w.add_station(4,Vector3(3,0,0))
for speaker in d.special.speaker_roots:
var target=(Vector3(0,1.75,-.12)-speaker.position).normalized()
check(speaker.basis.z.dot(target)>.99,"speaker faces seated soul")
for kind in range(10):
var actor=g.make_person(false,kind);g.add_child(actor);actor.mount_station(4);actor.update_torture(0,false)
for side in ["L","R"]:
var hip=actor.bone_local("upperleg01."+side);var knee=actor.bone_local("lowerleg01."+side)
if side=="L":print("SEAT_POINTS ",kind," hip=",hip," knee=",knee)
for t in [.2,.4,.6]:
var point=hip.lerp(knee,t)
check(point.z>d.special.seat.position.z+d.special.seat.mesh.get_aabb().end.z+.075 or point.y>d.special.seat.position.y+d.special.seat.mesh.get_aabb().end.y+.07,"thigh clears seat %d %s %.1f"%[kind,side,t])
actor.queue_free()
check(d.special.players.size()==2,"sound comes from both speakers")
g.test_mode=false;g.muted=false;g.whip_volume=.6;w.EXTRA.animate(g,d,.1,true)
await g.get_tree().create_timer(.15).timeout
check(d.special.players.all(func(player):return player.playing),"both speaker loops play")
g.muted=true;w.EXTRA.animate(g,d,.1,true);check(d.special.players.all(func(player):return not player.playing),"master mute stops both speaker loops")
g.test_mode=true;g.muted=false
if failures==0:print("ALL WORKFLOW TESTS PASSED (%d): transfer, idle losses, FIFO conveyor, helper cleanup, growth/save/clearance, ten seated skeletons, inward stereo speakers"%checks)
g.get_tree().quit(1 if failures else 0)