Files
metin2-server/tests/features/test_applies.py
T
shenleiandClaude Opus 5.5 5ad07886ea AVA2 unlock P1/P2: stone and Boss bonus apply types
APPLY_ATTBONUS_STONE 139 / APPLY_ATTBONUS_BOSS 140 (AVA2 numbering, 92-138
reserved) in the game and the db proto reader; docs/FEATURE-AVA2-UNLOCK.md.

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

35 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""AVA2 bonus numbering: the stone/boss applies the AVA2 stones and guardian weapons carry (docs/FEATURE-AVA2-UNLOCK.md)."""
from pathlib import Path
import re
ROOT=Path(__file__).resolve().parents[2]
SRC=ROOT/'src/server'
def source(name):return (SRC/name).read_bytes().decode('latin1')
length=source('common/length.h')
enum=length[length.index('enum EApplyTypes'):] if 'enum EApplyTypes' in length else length[length.index('APPLY_NONE'):]
enum=enum[:enum.index('MAX_APPLY_NUM')]
assert 'APPLY_ATTBONUS_STONE = 139,' in enum and 'APPLY_ATTBONUS_BOSS = 140,' in enum and enum.rstrip().endswith('= 140,')
# the db reads apply names by position, so the array index is the apply number
reader=source('db/src/ProtoReader.cpp')
names=re.findall(r'"([^"]+)"',re.search(r'arApplyType\[\]\s*=\s*\{(.*?)\};',reader,re.S).group(1))
assert len(names)==141 and names[91]=='APPLY_ANTI_PENETRATE_PCT' and names[139:]==['APPLY_ATTBONUS_STONE','APPLY_ATTBONUS_BOSS'],names[88:]
# aApplyInfo is indexed by apply number: 141 rows, the two new ones mapped to the biolog points
constants=source('game/src/constants.cpp')
table=constants[constants.index('aApplyInfo[MAX_APPLY_NUM]'):]
table=table[table.index('{')+1:table.index('};')]
rows=re.findall(r'\{\s*(POINT_[A-Z_]+)',table)
assert len(rows)==141 and rows[139:]==['POINT_ATTBONUS_STONE','POINT_ATTBONUS_BOSS'] and set(rows[92:139])=={'POINT_NONE'},len(rows)
assert '"ATTBONUS_STONE",\tAPPLY_ATTBONUS_STONE' in constants and '"ATTBONUS_BOSS",\tAPPLY_ATTBONUS_BOSS' in constants
char=source('game/src/char.cpp')
apply=char[char.index('void CHARACTER::ApplyPoint('):char.index('void CHARACTER::MotionPacketEncode(')]
assert 'case APPLY_ATTBONUS_STONE:' in apply and 'case APPLY_ATTBONUS_BOSS:' in apply
points=source('game/src/char.h')
assert 'POINT_ATTBONUS_STONE = 240,' in points and 'POINT_ATTBONUS_BOSS = 241,' in points
battle=source('game/src/battle.cpp')
assert 'GetPoint(POINT_ATTBONUS_STONE)' in battle and 'GetPoint(POINT_ATTBONUS_BOSS)' in battle
print('PASS: stone/boss applies 139/140 in the db reader, aApplyInfo, apply names and ApplyPoint')