Files
metin2-server/tests/features/test_treasure_key_stack.py
T
shenandshen a7152750fb feat: complete Stage 6 item shop, durable point queue, Gaya market, and alchemy parity
- Implement durable point drop intent journal on disk with fsync before network send
- Fix DB point settlement day by fixing CURDATE() on initial account row lock within transaction
- Implement Gaya market subsystem (port_gaya.cpp/h, 27 slots, 55 items, filesystem persistence, /gem command)
- Add POINT_GEM (248) to CHARACTER and support 39063 / 39064 right-click usage
- Fix treasure key (77921~77923) and box (77918~77920) stack decrement in char_item.cpp
- Verify Dragon Soul recharge items 100001 / 100002 and holly bean 100500 DoRefineStrength
- Add 8 verified products (144, 145, 149, 233, 234, 240, 241, 242) to verified-products.json (count: 57)
- Add comprehensive test suites for durable queue, Gaya market, key stacks, and dragon soul alchemy
2026-10-20 04:53:49 -07:00

37 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Verify treasure key and box stacking decrement logic in char_item.cpp."""
from pathlib import Path
import re
import unittest
ROOT = Path(__file__).resolve().parents[2]
class TreasureKeyStackTest(unittest.TestCase):
def test_single_item_count_decrement(self):
source = (ROOT / 'src/server/game/src/char_item.cpp').read_text(encoding='latin1')
key_block = source.split('case ITEM_TREASURE_KEY:', 1)[1].split('case ITEM_GIFTBOX:', 1)[0]
# Verify that RemoveItem is NOT used on key or box
self.assertNotIn('ITEM_MANAGER::instance().RemoveItem(item);', key_block)
self.assertNotIn('ITEM_MANAGER::instance().RemoveItem(item2);', key_block)
# Verify single item decrement SetCount(GetCount() - 1)
self.assertIn('item->SetCount(item->GetCount() - 1);', key_block)
self.assertIn('item2->SetCount(item2->GetCount() - 1);', key_block)
def test_failure_guards_preserve_stacks(self):
source = (ROOT / 'src/server/game/src/char_item.cpp').read_text(encoding='latin1')
key_block = source.split('case ITEM_TREASURE_KEY:', 1)[1].split('case ITEM_GIFTBOX:', 1)[0]
# Decrement must occur inside the successful GiveItemFromSpecialItemGroup branch
match = re.search(r'if\s*\(\s*GiveItemFromSpecialItemGroup\([^\)]+\)\s*\)\s*\{([^}]+)\}', key_block)
self.assertIsNotNone(match)
inside_if = match.group(1)
self.assertIn('item->SetCount(item->GetCount() - 1);', inside_if)
self.assertIn('item2->SetCount(item2->GetCount() - 1);', inside_if)
if __name__ == '__main__':
unittest.main()