feat: implement costume weapon, sash skin, shining slots and enchants
This commit is contained in:
@@ -14,7 +14,7 @@ assert 'IsCostumeEnchant' not in source('port_switchbot.cpp') and 's_adwNormal[]
|
||||
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;',
|
||||
'case COSTUME_BODY:','case COSTUME_HAIR:','case COSTUME_WEAPON:','case COSTUME_MOUNT_SKIN:','case COSTUME_NEW_SASH:','case SHINING_WEAPON:',
|
||||
'GetValue(2) & (1 << flag)','item->SetCount(item->GetCount() - 1);'):
|
||||
assert text in port,text
|
||||
codes=('target','none','equipped','full','has','done')
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""AVA2 Phase 2: Costume subdivision slots, weapon costumes, shining items, and costume enchants."""
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SRC = ROOT / 'src/server'
|
||||
|
||||
def source(name):
|
||||
return (SRC / name).read_bytes().decode('latin1')
|
||||
|
||||
class TestCostumeSlots(unittest.TestCase):
|
||||
def test_item_length_constants(self):
|
||||
il = source('common/item_length.h')
|
||||
for name in ('COSTUME_BODY', 'COSTUME_HAIR', 'COSTUME_MOUNT', 'COSTUME_SASH',
|
||||
'COSTUME_MOUNT_SKIN', 'COSTUME_WEAPON', 'COSTUME_NEW_SASH', 'COSTUME_PET'):
|
||||
self.assertIn(name, il)
|
||||
self.assertIn('ITEM_SHINING', il)
|
||||
self.assertIn('enum EShiningSubTypes { SHINING_WEAPON, SHINING_ARMOR, SHINING_SPECIAL };', il)
|
||||
|
||||
def test_wear_slots_constants(self):
|
||||
length = source('common/length.h')
|
||||
for wear, num in (('WEAR_COSTUME_WEAPON', 30), ('WEAR_COSTUME_PET', 31),
|
||||
('WEAR_PET', 32), ('WEAR_COSTUME_NEW_SASH', 33),
|
||||
('WEAR_SHINING_WEAPON', 34), ('WEAR_SHINING_ARMOR', 35),
|
||||
('WEAR_SHINING_SPECIAL', 36), ('WEAR_MAX', 40)):
|
||||
self.assertIn(f'{wear} = {num}', length)
|
||||
|
||||
def test_item_find_equip_cell(self):
|
||||
item = source('game/src/item.cpp')
|
||||
self.assertIn('ITEM_SHINING != GetType() && ITEM_PET != GetType()', item)
|
||||
self.assertIn('return WEAR_SHINING_WEAPON;', item)
|
||||
self.assertIn('return WEAR_SHINING_ARMOR;', item)
|
||||
self.assertIn('return WEAR_SHINING_SPECIAL;', item)
|
||||
self.assertIn('return WEAR_PET;', item)
|
||||
self.assertIn('return WEAR_COSTUME_WEAPON;', item)
|
||||
self.assertIn('return WEAR_COSTUME_PET;', item)
|
||||
self.assertIn('return WEAR_COSTUME_NEW_SASH;', item)
|
||||
|
||||
def test_item_modify_points_and_guards(self):
|
||||
item = source('game/src/item.cpp')
|
||||
self.assertIn('if (0 != m_pOwner->GetWear(WEAR_COSTUME_WEAPON))\n\t\t\t\t\tbreak;', item)
|
||||
self.assertIn('else if (GetSubType() == COSTUME_WEAPON)\n\t\t\t\t{\n\t\t\t\t\ttoSetPart = PART_WEAPON;', item)
|
||||
self.assertIn('else if (GetSubType() == COSTUME_NEW_SASH)\n\t\t\t\t{\n\t\t\t\t\ttoSetPart = PART_SASH;', item)
|
||||
self.assertIn('case ITEM_SHINING:\n\tcase ITEM_PET:\n\t\treturn true;', item)
|
||||
|
||||
def test_char_item_weapon_costume_guards(self):
|
||||
char_item = source('game/src/char_item.cpp')
|
||||
self.assertIn('LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);', char_item)
|
||||
self.assertIn('costumeWeapon->GetValue(3) != item->GetSubType()', char_item)
|
||||
self.assertIn('item->GetValue(3) != pkWeapon->GetSubType()', char_item)
|
||||
self.assertIn('static BYTE abSlot[] = { WEAR_COSTUME_BODY, WEAR_COSTUME_HAIR, WEAR_COSTUME_WEAPON, WEAR_COSTUME_NEW_SASH };', char_item)
|
||||
|
||||
def test_port_costume_attr_enchant_flags(self):
|
||||
port = source('game/src/port_costume_attr.cpp')
|
||||
self.assertIn('case COSTUME_BODY:\n\t\t\t\treturn 1;', port)
|
||||
self.assertIn('case COSTUME_HAIR:\n\t\t\t\treturn 2;', port)
|
||||
self.assertIn('case COSTUME_WEAPON:\n\t\t\t\treturn 3;', port)
|
||||
self.assertIn('case COSTUME_MOUNT_SKIN:\n\t\t\t\treturn 4;', port)
|
||||
self.assertIn('case COSTUME_NEW_SASH:\n\t\t\t\treturn 5;', port)
|
||||
self.assertIn('case SHINING_WEAPON:\n\t\t\tcase SHINING_ARMOR:\n\t\t\tcase SHINING_SPECIAL:\n\t\t\t\treturn 6;', port)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -14,7 +14,7 @@ def enum_after(text,start,end):
|
||||
item=source('common/item_length.h')
|
||||
assert 'COSTUME_MOUNT = 2,' in item and 'COSTUME_MOUNT_SKIN = 4,' in item
|
||||
reader=source('db/src/ProtoReader.cpp')
|
||||
assert '"COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };' in reader
|
||||
assert '"COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN"' in reader
|
||||
wear=enum_after(source('common/length.h'),'WEAR_BODY','WEAR_MAX_NUM')
|
||||
assert wear.index('WEAR_COSTUME_MOUNT')==25 and wear.index('WEAR_COSTUME_MOUNT_SKIN')==26,wear
|
||||
if CLIENT.is_dir():
|
||||
@@ -28,7 +28,7 @@ body=horse[horse.index('DWORD CHARACTER::GetMyHorseVnum'):];body=body[:body.inde
|
||||
assert body.index('WEAR_COSTUME_MOUNT_SKIN')<body.index('GetWear(WEAR_COSTUME_MOUNT)')<body.index('c_aHorseStat'),body
|
||||
assert 'return WEAR_COSTUME_MOUNT;' in source('game/src/item.cpp') and 'return WEAR_COSTUME_MOUNT_SKIN;' in source('game/src/item.cpp')
|
||||
attr=source('game/src/item_attribute.cpp')
|
||||
assert 'GetSubType() == COSTUME_MOUNT || GetSubType() == COSTUME_SASH || GetSubType() == COSTUME_MOUNT_SKIN))\n\t\treturn -1;' in attr
|
||||
assert 'GetSubType() == COSTUME_MOUNT' in attr and 'GetSubType() == COSTUME_MOUNT_SKIN' in attr and 'return -1;' in attr
|
||||
|
||||
items=source('game/src/char_item.cpp')
|
||||
for hook in ('MountCostumeCanEquip(item)','MountCostumeCanUnequip(item)','MountCostumeEquipped(item);',
|
||||
|
||||
@@ -9,18 +9,18 @@ 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 = 32')
|
||||
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[] =',36),('arNumberOfSubtype[_countof(arSubType)] =',37)): # item types 0..36
|
||||
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 '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:\n\t\treturn true;' in item
|
||||
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')
|
||||
|
||||
@@ -17,7 +17,7 @@ for k,v in (('SASH_ABSORPTION_SOCKET',0),('SASH_ABSORBED_SOCKET',1),('SASH_GRADE
|
||||
('SASH_GRADE_4_ABS_MAX_COMB',19),('SASH_EFFECT_FROM_ABS',19),('SASH_GRADE_4_PRICE',500000),('SASH_COMBINE_GRADE_4',30)):
|
||||
assert re.search(r'\b%s = %d,'%(k,v),item),k
|
||||
reader=source('db/src/ProtoReader.cpp')
|
||||
assert 'arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };' in reader
|
||||
assert '"COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN"' in reader
|
||||
|
||||
length=source('common/length.h')
|
||||
wear=enum_after(length,'WEAR_BODY','WEAR_MAX_NUM')
|
||||
|
||||
Reference in New Issue
Block a user