Files
mtgodot-poc/project/dragon_soul_test.gd
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

106 lines
3.1 KiB
GDScript

# dragon_soul_test —— 龙魂精炼窗 headless 自检。
# godot --headless --path project --script dragon_soul_test.gd
extends SceneTree
const DragonSoulUI = preload("res://ui/dragon_soul_ui.gd")
class FakeClient extends Node:
signal ds_window_open()
signal ds_refine_result(ok: bool, sub_type: int, cell: int)
var items := {} # cell -> {vnum, count}
var calls := []
func is_in_game() -> bool: return true
func get_item(window: int, cell: int) -> Dictionary:
return items.get(cell, {"vnum": 0, "count": 0})
func ds_refine(mode: int, cells: Array) -> bool:
calls.append(["ds_refine", mode, cells.duplicate()])
return true
var _fail := 0
func _ck(c: bool, m: String) -> void:
if not c:
_fail += 1
printerr("FAIL: " + m)
func _init() -> void:
_run()
if _fail == 0:
print("PASS: dragon_soul_test")
quit(0)
else:
printerr("%d check(s) failed" % _fail)
quit(1)
func _run() -> void:
var canvas := CanvasLayer.new()
get_root().add_child(canvas)
var fc := FakeClient.new()
get_root().add_child(fc)
fc.items = {
3: {"vnum": 71001, "count": 1}, # 龙魂
5: {"vnum": 72001, "count": 5}, # 材料
8: {"vnum": 72002, "count": 2},
}
var du: Node = DragonSoulUI.new()
get_root().add_child(du)
du.setup(fc, canvas, null)
_ck(not du.is_open(), "初始隐藏")
# ds_window_open -> 弹出
fc.ds_window_open.emit()
_ck(du.is_open(), "ds_window_open -> 弹出")
_ck(du._mode == 2, "默认模式 = 精炼(2)")
# 切模式
du._set_mode(0)
_ck(du._mode == 0, "切到升级(0)")
_ck(du._mode_btns[0].disabled and not du._mode_btns[2].disabled, "当前模式按钮禁用")
# 右键背包 -> 填格
du.add_cell(1, 3)
du.add_cell(1, 5)
du.add_cell(1, 8)
_ck(du._cells == [3, 5, 8], "3 个 cell 按序放入")
_ck(du._slot_labels[0].text.contains("龙魂") and du._slot_labels[0].text.contains("格3"), "槽0 = 龙魂")
_ck(du._slot_labels[1].text.contains("材料"), "槽1 = 材料")
# 非背包窗忽略
du.add_cell(2, 1)
_ck(du._cells == [3, 5, 8], "非 WINDOW_INVENTORY 忽略")
# 再次右键同 cell = 取出
du.add_cell(1, 5)
_ck(du._cells == [3, 8], "再次右键 -> 取出")
du.add_cell(1, 5)
_ck(du._cells == [3, 8, 5], "第三次右键 -> 重新放入末尾")
# 执行
for b in du._root.find_children("*", "Button", true, false):
if b.text == "执行":
b.pressed.emit()
_ck(fc.calls == [["ds_refine", 0, [3, 8, 5]]], "执行 -> client.ds_refine(mode=0, cells)")
# 结果:成功清空
fc.ds_refine_result.emit(true, 11, 3)
_ck(du._cells.is_empty(), "成功 -> 清空格子")
_ck(du._status.text.contains("成功"), "状态行显示成功")
# 结果:失败保留提示
du.add_cell(1, 3)
fc.ds_refine_result.emit(false, 8, 3)
_ck(du._status.text.contains("失败") and du._status.text.contains("8"), "失败 -> 原因码")
_ck(du._cells == [3], "失败不清空")
# 清空按钮
for b in du._root.find_children("*", "Button", true, false):
if b.text == "清空":
b.pressed.emit()
_ck(du._cells.is_empty(), "清空按钮")
# 关闭
for b in du._root.find_children("*", "Button", true, false):
if b.text == "关闭":
b.pressed.emit()
_ck(not du.is_open(), "关闭按钮")