Files
metin2-server/tests/features/test_rings.py
T

40 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""AVA2 new rings (docs/FEATURE-AVA2-UNLOCK.md P8): ITEM_NEW_RINGS (36) worn in WEAR_RINGS_1/2, socket accessories
with AVA2's jewels, their own 20-row attribute pool reached through the 40250 switchers / adders."""
from pathlib import Path
ROOT=Path(__file__).resolve().parents[2]
SRC=ROOT/'src/server'
def source(name):return (SRC/name).read_bytes().decode('latin1')
il=source('common/item_length.h')
assert il.index('ITEM_BELT,')<il.index('ITEM_SHINING,')<il.index('ITEM_NEW_RINGS,')<il.index('enum EMetinSubTypes'),'AVA2 numbering 35/36'
length=source('common/length.h')
assert length.index('WEAR_PENDANT,\t\t// 27')<length.index('WEAR_RINGS_1,\t\t// 28')<length.index('WEAR_RINGS_2,\t\t// 29')<length.index('WEAR_MAX = 40')
reader=source('db/src/ProtoReader.cpp')
types=reader[reader.index('string arType[]'):];types=types[:types.index('};')]
assert types.index('"ITEM_BELT"')<types.index('"ITEM_SHINING", "ITEM_NEW_RINGS"')
for name,rows in (('arSubType[] =',37),('arNumberOfSubtype[_countof(arSubType)] =',38)): # item types 0..36
arr=reader[reader.index(name):];arr=arr[:arr.index('};')]
assert arr.count('\n\t\t')==rows,(name,arr.count('\n\t\t'))
item=source('game/src/item.cpp')
fec=item[item.index('int CItem::FindEquipCell('):item.index('void CItem::ModifyPoints(')]
assert 'ITEM_BELT != GetType() && ITEM_NEW_RINGS != GetType()' in fec
assert 'if (ch->GetWear(WEAR_RINGS_1))\n\t\t\treturn WEAR_RINGS_2;\n\t\telse\n\t\t\treturn WEAR_RINGS_1;' in fec
assert '\tcase ITEM_BELT:\n\tcase ITEM_NEW_RINGS:' in item
assert '(m_pProto->bType == ITEM_BELT) || (m_pProto->bType == ITEM_NEW_RINGS);' in item
assert 'return GetVnum() == GetNewRingJewelVnum(item->GetVnum());' in item
items=source('game/src/char_item.cpp')
assert '\t\tcase ITEM_NEW_RINGS:\t// AVA2 new rings\n' in items
assert items.count('if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())')==3
assert items.count('if (item2->GetAttributeSetIndex() == -1)\n')==2 # 71051 / 71052 rare attributes stay closed
attr=source('game/src/item_attribute.cpp')
put=attr[attr.index('void CItem::PutAttributeWithLevel('):]
assert put.index('PutNewRingAttributeWithLevel(bLevel);')<put.index('GetAttributeSetIndex()')
assert 'port_rings.cpp' in source('game/src/Makefile')
port=source('game/src/port_rings.cpp')
pool=port[port.index('s_aRingAttr[] ='):];pool=pool[:pool.index('};')]
assert pool.count('{ APPLY_')==20 and '{ APPLY_MAX_HP,\t\t\t35,\t{ 200, 300, 300, 500, 500 } }' in pool
for ring,jewel in ((19500,50635),(19520,50636),(19540,50637),(19560,50638)):assert '{ %d, %d }'%(ring,jewel) in port
assert 'dwRingVnum / 10 * 10' in port and 'AddAttribute(r.bApply, r.asValues[bLevel - 1]);' in port
print('PASS: ring type 36 + WEAR_RINGS_1/2, accessory sockets + jewels, switchers/adders via the 20-row ring pool, rare attrs closed')