Files
Diabolo/Demon_v0.19/sentence_tests.gd
T

93 lines
4.4 KiB
GDScript
Raw Normal View History

extends RefCounted
var checks=0
func check(value):
checks+=1
if not value:push_error("SENTENCE QA failed #%d" % checks);Engine.get_main_loop().quit(1)
func clear(g):
for soul in g.souls:soul.node.queue_free()
g.souls.clear();g.held=-1
g.workshop.reset()
g.paused=false;g.game_started=true
func new_soul(g,required):
g.workshop.spawn()
var s=g.souls.back();s.entering=false;s.entry_time=1
s.required=required;s.served=[];g.set_soul_reveal(s.visual,1)
g.workshop.sentences.update_label(s)
return s
func finish(g,d):
g.workshop.step_station(d,1,false)
for i in range(600):g.time+=1.0/60;g.workshop.step_station(d,1.0/60,true)
func run(g):
g.start_game();var w=g.workshop
check(g.get_meta("level_area_scale")==1.25 and g.get_meta("main_floor_tiles")==1120)
check(w.AREA==Vector2i(12,9) and w.TITLES.size()==6)
clear(g)
var a=w.add_station(0,Vector3(-1,0,3))
var wheel=w.add_station(2,Vector3(1,0,-1.5))
var chair=w.add_station(4,Vector3(4.5,0,1.5))
var kettle=w.add_station(5,Vector3(8,0,-1))
w.rebuild_nav();check(w.accessible())
check(chair.special.music.stream.loop_mode==AudioStreamWAV.LOOP_FORWARD and chair.special.music.stream.get_length()>7.9)
check(kettle.special.bubbles.size()==16 and kettle.special.liquid!=null)
g.development.xp=0
w.spawn();check(g.souls.back().required.size()==1)
g.development.xp=210;g.uid=3
w.spawn();check(g.souls.back().required.size()==1)
g.development.xp=570;g.uid=8
w.spawn();check(g.souls.back().required.size()==1)
g.uid=8;w.spawn();check(g.souls.back().required.size()==1)
for soul in g.souls:
for kind in soul.required:check(kind in [0,2,4,5])
for soul in g.souls:soul.node.queue_free()
g.souls.clear()
g.development.xp=0
var s=new_soul(g,[0,2]);var gold=g.coins;var done=g.done
check(not w.attach(s,2))
check(w.attach(s,0));finish(g,a)
check(s.state=="ready" and s.served==[0] and g.coins==gold and g.done==done and g.life.burns.is_empty())
check(s.label.text.is_empty() and not s.label.visible)
check(s.task_icon_nodes.size()==2 and s.task_icon_nodes[0].completed and not s.task_icon_nodes[1].completed)
check(s.task_icon_nodes[0].kind==w.Icon.APPARATUS[0] and s.task_icon_nodes[1].kind==w.Icon.APPARATUS[2])
check(a.ready and a.soul==s.id)
w.sentences.pickup(s);check(s.state=="held" and not s.queue_reserved)
w.drop_held();check(s.state=="ready" and a.soul==s.id)
w.sentences.pickup(s);check(w.attach(s,1));g.held=-1
check(a.soul==-1 and not a.ready)
finish(g,wheel)
check(g.index_of(s.id)==-1 and g.done==done+1 and g.coins==gold+27 and g.life.burns.size()==1)
check(not w.attach(new_soul(g,[4,5]),0))
var t=g.souls.back();check(w.attach(t,2));finish(g,chair)
check(t.state=="ready" and t.served==[4] and not chair.special.music.playing)
check(w.attach(t,3));finish(g,kettle)
check(g.index_of(t.id)==-1 and g.done==done+2 and g.coins==gold+68)
print("PASS: expanded level +25%, six apparatus, progressive 1/2/3 sentences, wrong-tool rejection, intermediate transfer, final-only rewards and burn, chair and cauldron")
# Three-stage route entirely operated by an assistant, with no manual carrying.
clear(g);g.development.xp=0
a=w.add_station(0,Vector3(-1,0,3));chair=w.add_station(4,Vector3(4.5,0,1.5));kettle=w.add_station(5,Vector3(8,0,-1));w.rebuild_nav()
w.add_helper();w.automation=true;w.helper_speed=3
s=new_soul(g,[0,4,5]);s.node.position=Vector3(-5.3,0,3.4)
var target_done=g.done+1
for frame in range(6000):
g.time+=1.0/60;w.update_helpers(1.0/60)
for d in w.stations:w.step_station(d,1.0/60,d.operator>=0)
if g.done==target_done:break
check(g.done==target_done and g.souls.is_empty())
check(w.helpers[0].model.get_meta("helper_tint")==Color("779fff"))
var helper_mesh=w.helpers[0].model.find_children("*","MeshInstance3D",true,false)[0]
var hero_mesh=g.avatar.find_children("*","MeshInstance3D",true,false)[0]
check(helper_mesh.get_active_material(0)!=hero_mesh.get_active_material(0))
check(not g.avatar.has_meta("helper_tint"))
s=new_soul(g,[0]);w.dialogue_clock=w.DIALOGUE_INTERVAL;w.update_soul_dialogue(.01)
check(not is_instance_valid(g.development.bubble))
var serial=g.dialogue.serial;g.dialogue.speak(s.kind)
check(g.dialogue.serial==serial and g.dialogue.pending.is_empty())
g.paused=true;w.update(.1);g.paused=false;w.update(.1)
check(not is_instance_valid(g.development.bubble))
print("PASS: assistant routes a soul through three matching devices; blue materials preserve heroine; soul dialogue stays disabled across pause")
print("ALL SENTENCE TESTS PASSED — DEMON 0.19")
g.get_tree().quit()