ENABLE_CHEQUE_SYSTEM / ENABLE_WON_EXCHANGE_WINDOW = 1: Won in trades, private shop Won prices (int32 cheque[] after the CG_MYSHOP items), shop item cheque prices, mt_won script fixes, zh locale_game_ex overlay staged into locale_zh_ava2 (fixes the swapped %s/%d in WONEXCHANGE_CONFIRM_QUESTION_2). Also zero-init every TPacketCGExchange: arg1 was uninitialised and the HEAD server drops arg1 > UINT32_MAX, so accept/cancel/item-add were lost and trades never completed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.7 KiB
Python
61 lines
2.7 KiB
Python
"""Run the installed motion wrapper with explicit registration/pack substitutes."""
|
|
from pathlib import Path
|
|
import sys
|
|
import types
|
|
import re
|
|
from unittest.mock import patch
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
class QuiverMotionTests(unittest.TestCase):
|
|
def test_wallet_and_dependent_window_switch_together(self):
|
|
source=(ROOT/'src/port/UserInterface/PythonApplicationModule.cpp').read_text()
|
|
for name in ('ENABLE_CHEQUE_SYSTEM','ENABLE_WON_EXCHANGE_WINDOW'):
|
|
values=re.findall(r'PyModule_AddIntConstant\(poModule,\s*"'+name+r'",\s*(\d+)\)',source)
|
|
self.assertEqual(values,['1'])
|
|
|
|
def load(self, missing=None):
|
|
names = ['chr', 'chrmgr', 'pack', 'playerSettingModule']
|
|
mods = {n: types.ModuleType(n) for n in names}
|
|
calls = []
|
|
chr = mods['chr']
|
|
chr.MOTION_MODE_BOW_SPECIAL = 19
|
|
for i, n in enumerate(['MOTION_WAIT', 'MOTION_WALK', 'MOTION_RUN', 'MOTION_DAMAGE',
|
|
'MOTION_DAMAGE_BACK', 'MOTION_COMBO_ATTACK_1']):
|
|
setattr(chr, n, i)
|
|
for n in ['SelectRace', 'SetPathName', 'RegisterMotionMode', 'RegisterCacheMotionData',
|
|
'ReserveComboAttackNew', 'RegisterComboAttackNew']:
|
|
setattr(mods['chrmgr'], n, lambda *args, n=n: calls.append((n, args)))
|
|
mods['pack'].Exist = lambda p: p != missing
|
|
setting = mods['playerSettingModule']
|
|
setting.RACE_ASSASSIN_W = 1
|
|
setting.RACE_ASSASSIN_M = 5
|
|
setting.LoadGameData = lambda n: calls.append(('original', (n,))) or 7
|
|
raw = (ROOT / 'src/platform/ScriptLib/QuiverMotionScript.inc').read_text()
|
|
ns = {}
|
|
with patch.dict(sys.modules, mods):
|
|
exec(raw.split('R"PY(', 1)[1].rsplit(')PY";', 1)[0], ns)
|
|
return setting, ns, calls
|
|
|
|
def test_original_loader_and_complete_both_sexes(self):
|
|
setting, ns, calls = self.load()
|
|
self.assertEqual(setting.LoadGameData('WARRIOR'), 7)
|
|
self.assertEqual(calls, [('original', ('WARRIOR',))])
|
|
self.assertEqual(setting.LoadGameData('ASSASSIN'), 7)
|
|
self.assertEqual(ns['loaded'], {1: True, 5: True})
|
|
self.assertEqual(sum(n == 'RegisterCacheMotionData' for n, _ in calls), 18)
|
|
self.assertEqual([a for n, a in calls if n == 'RegisterComboAttackNew'],
|
|
[(19, 0, 0, 5), (19, 0, 0, 5)])
|
|
|
|
def test_missing_motion_does_not_register_partial_mode(self):
|
|
setting, ns, calls = self.load('d:/ymir work/pc/assassin/bow/attack_special.msa')
|
|
setting.LoadGameData('ASSASSIN')
|
|
self.assertEqual(ns['loaded'], {1: False, 5: True})
|
|
self.assertEqual([a for n, a in calls if n == 'SelectRace'], [(5,)])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|