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
67 lines
2.3 KiB
GDScript
67 lines
2.3 KiB
GDScript
# inventory_test — 扩展装备位和腰带背包的协议坐标 / 锁格规则。
|
|
extends SceneTree
|
|
|
|
const InventoryUI = preload("res://ui/inventory_ui.gd")
|
|
|
|
class FakeProto extends Node:
|
|
func item(_vnum: int) -> Dictionary:
|
|
return {"values": [4]}
|
|
|
|
class FakeClient extends Node:
|
|
var item_ops := []
|
|
func use_item_to_item(sw: int, sc: int, tw: int, tc: int) -> bool:
|
|
item_ops.append([sw, sc, tw, tc])
|
|
return true
|
|
|
|
var failed := 0
|
|
|
|
func _check(ok: bool, message: String) -> void:
|
|
if not ok:
|
|
failed += 1
|
|
printerr("FAIL: " + message)
|
|
|
|
func _init() -> void:
|
|
var inv := InventoryUI.new()
|
|
_check(inv._to_wire(0) == [1, 0], "normal inventory uses INVENTORY cell")
|
|
_check(inv._to_wire(113) == [1, 113], "wear belt uses legacy global cell 113")
|
|
_check(inv._to_wire(200) == [1, 152], "belt UI cell 0 uses global cell 152")
|
|
_check(inv._to_wire(215) == [1, 167], "belt UI cell 15 uses global cell 167")
|
|
|
|
inv.proto = FakeProto.new()
|
|
inv.add_child(inv.proto)
|
|
for i in 16:
|
|
var cell := Panel.new()
|
|
inv.add_child(cell)
|
|
inv._cells[200 + i] = cell
|
|
var eq := []
|
|
for _i in 24:
|
|
eq.append({"vnum": 0, "count": 0})
|
|
eq[23] = {"vnum": 12345, "count": 1}
|
|
inv._apply_belt_locks(eq)
|
|
_check(not bool(inv._cells[200].get_meta("locked", true)), "grade 4 unlocks belt cell 0")
|
|
_check(not bool(inv._cells[202].get_meta("locked", true)), "grade 4 unlocks belt cell 2")
|
|
_check(bool(inv._cells[203].get_meta("locked", false)), "grade 4 locks belt cell 3 (needs 6)")
|
|
_check(not bool(inv._cells[206].get_meta("locked", true)), "grade 4 unlocks belt cell 6")
|
|
_check(bool(inv._cells[207].get_meta("locked", false)), "grade 4 locks belt cell 7 (needs 6)")
|
|
var fake_client := FakeClient.new()
|
|
inv.add_child(fake_client)
|
|
inv.client = fake_client
|
|
for index in [0, 1]:
|
|
var item_cell := Panel.new()
|
|
item_cell.set_meta("vnum", 100 + index)
|
|
item_cell.set_meta("count", 2)
|
|
inv.add_child(item_cell)
|
|
inv._cells[index] = item_cell
|
|
_check(inv._use_to_item(0, 1), "item-to-item intent accepted")
|
|
_check(fake_client.item_ops == [[1, 0, 1, 1]], "item-to-item uses original inventory positions")
|
|
inv._begin_combine(0)
|
|
_check(inv._combine_from == 0, "shift selects combine source")
|
|
inv._begin_combine(0)
|
|
_check(inv._combine_from == -1, "shift same source cancels combine")
|
|
inv.free()
|
|
if failed == 0:
|
|
print("PASS: inventory_test (extended equipment + belt mapping)")
|
|
quit(0)
|
|
else:
|
|
quit(1)
|