Files
mtgodot-poc/project/shop_cube_mall_test.gd
T
shenandClaude Sonnet 5 47baf6c0c6 Metin2 game client (P0–P11) + mobile asset pipeline
Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
  phases, EntityStore world model, ~all GC/CG headers. char create/delete,
  private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
  quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
  char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
  token), system-option + game-option + ESC system menu, private-shop 39-grid,
  party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
  dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.

Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.

Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).

ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
2026-08-31 20:02:12 +09:00

119 lines
4.5 KiB
GDScript

# shop_cube_mall_test —— 개인상점 / 방주(Cube) / 도구商城 UI headless 자체 검사.
# godot --headless --path project --script shop_cube_mall_test.gd
# 假 client 记录调用;不需要 assets / server.
extends SceneTree
const MallUI = preload("res://ui/mall_ui.gd")
const CubeUI = preload("res://ui/cube_ui.gd")
class FakeClient extends Node:
signal mall_opened(size: int)
signal mall_changed()
signal cube_opened(npc_vnum: int)
signal cube_closed()
signal cube_changed()
signal cube_result(vnum: int, count: int, ok: bool)
var mall_items: Array = []
var mall_open := false
var mall_size := 0
var cube := {}
var inventory: Array = []
var calls: Array = []
func is_mall_open() -> bool: return mall_open
func get_mall_size() -> int: return mall_size
func get_mall_items() -> Array: return mall_items
func mall_checkout(a, b, c) -> bool: calls.append(["mall_checkout", a, b, c]); return true
func get_cube() -> Dictionary: return cube
func cube_make(i) -> bool: calls.append(["cube_make", i]); return true
func cube_request_result_list(n) -> bool: calls.append(["cube_rlist", n]); return true
func cube_request_materials(a, b) -> bool: calls.append(["cube_mats", a, b]); return true
func get_inventory() -> Array: return inventory
func open_private_shop(sign, items) -> bool: calls.append(["open_shop", sign, items]); return true
func close_private_shop() -> bool: calls.append(["close_shop"]); return true
var _fail := 0
func _ck(c: bool, m: String) -> void:
if not c:
_fail += 1
printerr("FAIL: " + m)
func _init() -> void:
await _run()
if _fail == 0:
print("PASS: shop_cube_mall_test")
quit(0)
else:
printerr("%d check(s) failed" % _fail)
quit(1)
func _run() -> void:
var fc := FakeClient.new()
get_root().add_child(fc)
var host := Control.new()
get_root().add_child(host)
# ---------------- MallUI ----------------
var mu = MallUI.new()
get_root().add_child(mu)
mu.setup(fc, host, null)
_ck(not mu.is_open(), "mall: hidden initially")
fc.mall_open = true
fc.mall_size = 45
fc.mall_items = [{"cell": 3, "vnum": 27993, "count": 2}]
fc.mall_opened.emit(45)
await process_frame
_ck(mu.is_open(), "mall: opens on mall_opened")
var out_btn := _find(mu._list, "Button", func(b): return String(b.text) == "취출" or String(b.text) == "取出")
_ck(out_btn != null, "mall: item row has 取出 button")
if out_btn:
out_btn.pressed.emit()
_ck(_has_call(fc, "mall_checkout", func(c): return c[1] == 3 and c[2] == 1), "mall: 取出 → mall_checkout(cell=3, inv, ...)")
# ---------------- CubeUI ----------------
var cu = CubeUI.new()
get_root().add_child(cu)
cu.setup(fc, host, null)
_ck(not cu.is_open(), "cube: hidden initially")
fc.cube = {"open": true, "npc_vnum": 20383, "recipes": [], "results": [
{"vnum": 72723, "count": 1}, {"vnum": 50001, "count": 5}]}
fc.cube_opened.emit(20383)
await process_frame
_ck(cu.is_open(), "cube: opens on cube_opened")
_ck(_has_call(fc, "cube_rlist", func(c): return c[1] == 20383), "cube: open → request result list")
var recipe_btns: Array = cu._list.get_children().filter(func(n): return n is Button)
_ck(recipe_btns.size() == 2, "cube: 2 result rows")
fc.cube = {"open": true, "npc_vnum": 20383, "results": fc.cube["results"], "recipes": [
{"result_vnum": 72723, "gold": 120000, "material_groups": [
[{"vnum": 125, "count": 1}], [{"vnum": 555, "count": 5}]]}]}
(recipe_btns[0] as Button).pressed.emit()
await process_frame
_ck(_has_call(fc, "cube_mats", func(c): return c[1] == 0), "cube: select → request materials(0)")
var gold_lbl := _find(cu._mat, "Label", func(l): return String(l.text).contains("120000"))
_ck(gold_lbl != null, "cube: materials panel shows gold 120000")
_ck(not cu._make_btn.disabled, "cube: 制作 enabled after select")
cu._make_btn.pressed.emit()
_ck(_has_call(fc, "cube_make", func(c): return c[1] == 0), "cube: 制作 → cube_make(0)")
fc.cube_result.emit(72723, 1, true)
await process_frame
_ck(String(cu._status.text).contains("성공") or String(cu._status.text) != "", "cube: result shown")
fc.cube_closed.emit()
await process_frame
_ck(not cu.is_open(), "cube: hides on cube_closed")
# PrivateShopUI 已改走 uiscript(`privateshopbuilder.py`),单独在
# `private_shop_ui_test.gd` 里测(需要 uiscript 资产)。
mu.queue_free(); cu.queue_free()
func _find(node: Node, cls: String, pred: Callable) -> Node:
for n in node.find_children("*", cls, true, false):
if pred.call(n):
return n
return null
func _has_call(fc, name: String, pred: Callable) -> bool:
for c in fc.calls:
if c[0] == name and pred.call(c):
return true
return false