Files
metin2-client/tests/wiki/test_shop_appearance.py
T
shenandshen 6661b17084 feat: add point currency and stage extended shop items
Rename shop currency and vouchers to points, synchronize the wiki catalogue, and display point rewards. Add wear40 item metadata transport and pet identity accessors; stage sixteen timed mounts and appearance items with AVA2 model registration.

Include build and sbtest acceptance evidence. Remaining shop systems are unfinished and are not enabled or deployed. Wear40 requires the matching server migration and mt20261022 client.
2026-10-19 18:30:19 -07:00

49 lines
2.6 KiB
Python

"""Verify runtime race registration against the AVA2 definitions, for every sex/job."""
from pathlib import Path
import re
import sys
import types
import unittest
from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[2]
REFERENCE = ROOT.parent/'AVA2/1. Client DEV/pack_maker/root'
@unittest.skipUnless(REFERENCE.is_dir(), 'requires original AVA2 race definitions')
class ShopAppearance(unittest.TestCase):
def test_models_and_skins_match_original_race_definitions(self):
calls = []
module = types.ModuleType('chrmgr')
module.LoadLocalRaceData = lambda name: calls.append(('load', name)) or True
for name in ('SetShapeModel', 'AppendShapeSkin', 'SetHairSkin'):
setattr(module, name, lambda *args, method=name: calls.append((method,)+args))
text = (ROOT/'src/platform/ScriptLib/ArmorShapesScript.inc').read_text()
script = text.split('R"PY(', 1)[1].split(')PY"', 1)[0]
with patch.dict(sys.modules, chrmgr=module):
exec(compile(script, '<appearance>', 'exec'), {})
for race in ('warrior', 'assassin', 'sura', 'shaman'):
for sex in ('m', 'w'):
with self.subTest(race=race, sex=sex):
calls.clear()
filename = race+'_'+sex+'.msm'
self.assertTrue(module.LoadLocalRaceData(filename))
self.assertEqual(calls[0], ('load', filename))
source = (REFERENCE/filename).read_text(errors='replace')
hair_data = source[source.index('Group HairData'):]
base = re.search(r'PathName\s+"([^"]+)"', hair_data).group(1).lower()
groups = re.findall(r'\{([^{}]+)\}', source)
for index, kind in ((40062, 'Shape'), (40063, 'Shape'), (161, 'Hair'), (191, 'Hair')):
group = next(g for g in groups if re.search(kind+r'Index\s+'+str(index)+r'\b', g))
model = re.search(r'Model\s+"([^"]+)"', group).group(1).lower()
skin = re.search(r'TargetSkin\s+"([^"]+)"', group).group(1).lower()
if kind == 'Shape':
self.assertIn(('SetShapeModel', index, base+model), calls)
self.assertIn(('AppendShapeSkin', index, 0, base+skin, base+skin), calls)
else:
self.assertIn(('SetHairSkin', index, 0, base+model, base+skin, base+skin), calls)
if __name__ == '__main__':
unittest.main()