feat: port native AVA2 chest preview and CG235 pickup flows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import sys,unittest
|
||||
import sys,unittest,tempfile
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parents[1];sys.path.insert(0,str(HERE))
|
||||
import make_items as m
|
||||
@@ -7,6 +7,28 @@ READER=HERE.parents[3]/'metin2-server/src/server/db/src/ProtoReader.cpp'
|
||||
def row(vnum,t,st,anti='NONE',flags='NONE',wear='NONE',applies=('APPLY_NONE','0')*3,values=('0',)*6,refine=('0','0')):
|
||||
return [str(vnum),'x',t,st,'1',anti,flags,wear,'NONE','10','20',refine[0],refine[1],'0','LEVEL','120','LIMIT_NONE','0',*applies,*values,'0','0','-1','']
|
||||
|
||||
class UIAssetTests(unittest.TestCase):
|
||||
def test_private_v1_and_v2_atlas_closure(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
assets=Path(tmp)/'assets';sources=Path(tmp)/'sources';sources.mkdir()
|
||||
a=sources/'properties.dds';a.write_bytes(b'AVA2 atlas')
|
||||
b=sources/'switchbot.tga';b.write_bytes(b'switchbot atlas')
|
||||
files={'d:/ymir work/ui/properties_01.dds':a,'d:/ymir work/ui/switchbot/switchbot.tga':b}
|
||||
v1=assets/'d:/ymir work/ui/game/attr6th7th/material_slot.sub';v1.parent.mkdir(parents=True)
|
||||
v1.write_bytes(b'version 1.0\nimage "properties_01.dds"\nleft 44\n')
|
||||
v2=assets/'d:/ymir work/ui/switchbot/btn.sub';v2.parent.mkdir(parents=True)
|
||||
v2.write_bytes(b'version 2.0\nimage "switchbot.tga"\nleft 0\n')
|
||||
base=assets/'d:/ymir work/ui/properties_01.dds';base.write_bytes(b'base atlas')
|
||||
m.pack_ui_subimages(assets,files)
|
||||
self.assertEqual(base.read_bytes(),b'base atlas')
|
||||
self.assertIn(b'image "ava2_native/properties_01.dds"',v1.read_bytes())
|
||||
self.assertIn(b'version 1.0',v2.read_bytes())
|
||||
self.assertEqual((assets/'d:/ymir work/ui/ava2_native/switchbot/switchbot.tga').read_bytes(),b'switchbot atlas')
|
||||
def test_missing_atlas_rejects_pack(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root=Path(tmp);(root/'a.sub').write_bytes(b'version 1.0\nimage "missing.dds"\n')
|
||||
with self.assertRaisesRegex(ValueError,'missing UI subimage atlas'):m.pack_ui_subimages(root,{})
|
||||
|
||||
@unittest.skipUnless(READER.is_file(),'needs ../metin2-server')
|
||||
class ConvertTests(unittest.TestCase):
|
||||
E=m.enums(READER) if READER.is_file() else None
|
||||
@@ -142,8 +164,13 @@ class ConvertTests(unittest.TestCase):
|
||||
self.assertTrue(kept);self.assertEqual(server[24],str(month));self.assertEqual(client[23],month)
|
||||
|
||||
|
||||
def test_premium_pickup_consumable(self):
|
||||
s,c,kept=m.convert(row(70002,'ITEM_USE','USE_SPECIAL',values=('60','0','0','0','0','0')),self.E,{70002})
|
||||
self.assertTrue(kept);self.assertEqual(s[2:4],['ITEM_USE','USE_SPECIAL'])
|
||||
self.assertEqual(m.names()[70002],'第三只手')
|
||||
|
||||
def test_names_cover_ranges(self):
|
||||
n=m.names();self.assertEqual(len(n),518+6*200+4*9+14+12+136);self.assertEqual(n[54100],'武器外观强化石')
|
||||
n=m.names();self.assertEqual(len(n),518+6*200+4*9+14+12+136+1);self.assertEqual(n[54100],'武器外观强化石')
|
||||
self.assertEqual([n[v] for v in (21210,21219,21279)],['暗龙铠甲+0','暗龙铠甲+9','神龙铠甲+9'])
|
||||
self.assertTrue(all(len(v.encode('gbk'))<=24 for v in n.values()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user