Files
metin2-server/tests/features/test_costume_attr.py
T
shenleiandClaude Opus 5.5 a28393b16b Port the AVA2 switchbot (自动洗练) 1:1
AVA2 new_switchbot ported as port_switchbot.{h,cpp}: SWITCHBOT item window (7),
CG/GC 171 and GG 31 with AVA2 subheaders and field order, pack(1) structs pinned
by static_assert, 0.1 s roll, P2P hand-over on warp, boot ALTER of
player.item.window. Switchers come from the inventory; current checks and
ItemLog are kept. Clients sending "mt20261016" or newer as the version
timestamp get the switchbot; older clients are left alone.

The v1 /mt_switchbot chat command, its lock verb and query capability bit 64
are removed (cap mask 1023 -> 959).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 20:26:06 +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 never taken by the switchbot."""
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 'IsCostumeEnchant' not in source('port_switchbot.cpp') and 's_adwNormal[] = { 71084, 39028 };' in source('port_switchbot.cpp')
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')