Files
metin2-server/tests/features/test_costume_attr.py
T
shenleiandClaude Opus 5.5 6199b2cbff AVA2 unlock P6: costume enchants (USE_CHANGE_ATTRIBUTE 54001-54267)
Enchant stones add one fixed attribute to an unequipped body / hair /
mount-skin costume (max 3, no duplicates); gear and the switchbot refuse
them. MTCATTR chat commands report the result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:12:30 +09:00

29 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""AVA2 costume enchants (docs/FEATURE-AVA2-UNLOCK.md P6): 54001-54267 add one fixed attribute to a
body/hair/mount-skin costume, are routed before the 40250 switcher path and are no switchbot scroll."""
from pathlib import Path
ROOT=Path(__file__).resolve().parents[2]
SRC=ROOT/'src/server/game/src'
def source(name):return (SRC/name).read_bytes().decode('latin1')
items=source('char_item.cpp')
case=items[items.index('case USE_CHANGE_ATTRIBUTE2 :'):]
hook=case.index('if (item->IsCostumeEnchant())\n\t\t\t\t\t\t\t\treturn CostumeEnchantUse(item, item2);')
assert hook<case.index('BuffOnAttr_RemoveBuffsFromItem(item2)')<case.index('ITEM_COSTUME == item2->GetType()'),'hook must run before the costume refusal'
assert '!scroll->IsCostumeEnchant()' in source('port_switchbot.h')
assert 'port_costume_attr.cpp' in source('Makefile')
port=source('port_costume_attr.cpp')
for text in ('COSTUME_ENCHANT_VNUM_MIN = 54001','COSTUME_ENCHANT_VNUM_MAX = 54267','COSTUME_ENCHANT_MAX_ATTR = 3',
'case COSTUME_BODY:\n\t\t\treturn 1;','case COSTUME_HAIR:\n\t\t\treturn 2;','case COSTUME_MOUNT_SKIN:\n\t\t\treturn 4;',
'GetValue(2) & (1 << flag)','item->SetCount(item->GetCount() - 1);'):
assert text in port,text
codes=('target','none','equipped','full','has','done')
for code in codes:assert '"MTCATTR %s"'%code in port,code
# the add must come after every refusal
assert all(port.index('"MTCATTR %s"'%c)<port.index('item2->AddAttribute') for c in codes[:-1])
script=ROOT.parent/'metin2-client/src/platform/ScriptLib/CostumeAttrScript.inc'
if script.is_file():
s=script.read_text()
for code in codes:assert "'%s':"%code in s,code
print('PASS: costume enchant hook before switcher path, body/hair/mount-skin masks, max 3, switchbot excluded, MTCATTR codes')