883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
46 lines
2.8 KiB
Python
46 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
import copy
|
|
from pathlib import Path
|
|
import sys
|
|
import unittest
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import quest_poi_60141_geometry as g
|
|
|
|
|
|
def fixture():
|
|
raw={'guid':42,'entries':[524,0,0,0],'map':0,'x':-100.5,'y':20.25,'z':35.5,'wander':5.0,'spawn_flags':0,'visibility_mod':0.0}
|
|
point={'guid':42,'source_map':0,'x':-100.5,'y':20.25,'z':35.5,'wander_radius':5.0,
|
|
'spawn_pools':[],'template_pools':[],'events':[],'spawn_flags':0,'visibility_mod':0.0,'spawn_template_choices':[524,0,0,0]}
|
|
s={'schema':'tortoise-quest-location-snapshot-v2','quests':[{'id':60141,'creature_or_go':[0]*4,'required_spells':[0]*4,
|
|
'items':[51868,0,0,0],'item_count':[8,0,0,0]}],'spawns':[raw],
|
|
'templates':[{'creature':524,'loot_id':524,'phase_quest_id':0}],
|
|
'direct_loot_rows':[{'creature':524,'item':51868,'loot_id':524,'condition':0,'min_or_ref':1}],
|
|
'spawn_pools':[],'template_pools':[],'events':[]}
|
|
objective={'kind':'item','target':51868,'required_count':8,'native_storage_index':4,'presentation_index':0,'candidate_presentation_id':481128,
|
|
'supported_sources':[{'creature':524,'phase_quest_id':0,'condition_id':0,'evidence':'direct_creature_loot'}],
|
|
'clusters':[{'source_map':0,'cell':[-1,0],'cell_size_world_units':128.0,'point_count':1,'points':[point]}]}
|
|
d={'schema':'source-quest-objective-locations-v2','quests':[{'quest_id':60141,'holds':[],'objectives':[objective]}]}
|
|
return d,s
|
|
|
|
class GeometryTest(unittest.TestCase):
|
|
def test_exact_outward_envelope(self):
|
|
d,s=fixture();out=g.generate(d,s);r=out['regions'][0]
|
|
self.assertEqual([r[k] for k in ('x_min','y_min','x_max','y_max','z')],[-106,15,-95,26,36])
|
|
self.assertEqual(r['source_spawn_guids'],[42])
|
|
self.assertIn('not Source-authored',out['limitations'][0])
|
|
def test_unverified_sources_fail_closed(self):
|
|
for mode in ('spell','loot_condition','pool','event','phase','point_mismatch','cell','missing_spawn','alternate'):
|
|
d,s=fixture();o=d['quests'][0]['objectives'][0];p=o['clusters'][0]['points'][0]
|
|
if mode=='spell':s['quests'][0]['required_spells'][0]=99
|
|
elif mode=='loot_condition':s['direct_loot_rows'][0]['condition']=1
|
|
elif mode=='pool':s['spawn_pools']=[{'guid':42,'pool':7}]
|
|
elif mode=='event':s['events']=[{'guid':42,'event':7}]
|
|
elif mode=='phase':s['templates'][0]['phase_quest_id']=9
|
|
elif mode=='point_mismatch':p['x']+=1
|
|
elif mode=='cell':o['clusters'][0]['cell']=[0,0]
|
|
elif mode=='missing_spawn':s['spawns'].append(dict(s['spawns'][0],guid=43))
|
|
else:s['spawns'][0]['entries']=[524,777,0,0]
|
|
with self.subTest(mode=mode),self.assertRaises(ValueError):g.generate(d,s)
|
|
|
|
if __name__=='__main__':unittest.main()
|