完善客户端功能并同步差距文档

This commit is contained in:
shenlei
2026-09-03 18:40:01 +09:00
parent f93a172296
commit 13ccb8d02d
135 changed files with 21881 additions and 1259 deletions
+46 -20
View File
@@ -31,6 +31,7 @@ class FakeClient extends Node:
var safebox_size := 0
var safebox_gold := 0
var inventory := []
var main_pos := Vector3.ZERO
var main_vid := 20
var distribute_mode := 0
@@ -69,6 +70,12 @@ class FakeClient extends Node:
func get_safebox_size() -> int: return safebox_size
func get_safebox_gold() -> int: return safebox_gold
func get_inventory() -> Array: return inventory
func get_item(window, cell) -> Dictionary:
if window != 1: return {}
for item in inventory:
if int(item.get("cell", -1)) == int(cell): return item
return {}
func get_entity(_vid) -> Dictionary: return {"pos_cm": main_pos}
func safebox_checkin(sp, w, c) -> bool: calls.append(["sb_checkin", sp, w, c]); return true
func safebox_checkout(sp, w, c) -> bool: calls.append(["sb_checkout", sp, w, c]); return true
@@ -233,13 +240,12 @@ func _run() -> void:
{"pos": 1, "vnum": 19, "price": 800, "count": 1}]
fc.shop_opened.emit(8080)
_ck(su.is_open(), "shop opens on shop_opened")
_ck(su._list.get_child_count() == 2, "shop: 2 item rows")
# 第一行的「买」按钮
var buy_btn: Button = null
for b in su._list.get_child(0).find_children("*", "Button", true, false):
buy_btn = b
if buy_btn:
buy_btn.pressed.emit()
_ck(su._grid.get_child_count() == 40, "shop: 5x8 item grid")
# 第一格点击进入购买确认,再确认后固定以 count=1 发包。
(su._grid.get_child(0) as Button).pressed.emit()
_ck(su._buy_confirm != null, "shop: slot click opens buy confirmation")
if su._buy_confirm:
su._buy_confirm.confirmed.emit()
_ck(fc.calls.has(["shop_buy", 0, 1]), "shop: buy row 0")
su.sell(5)
_ck(fc.calls.has(["shop_sell", 5, 1]), "shop: sell inv cell 5")
@@ -258,23 +264,19 @@ func _run() -> void:
fc.shop_opened.emit(8080)
_ck(su.is_open(), "shop_ex: opens")
_ck(su._tabbar.visible and su._tabbar.get_child_count() == 2, "shop_ex: 2 tab buttons")
_ck(su._list.get_child_count() == 2, "shop_ex: tab 0 has 2 rows")
# tab 0 第二slot 5)买 -> pos = 0*40 + 5
var r1_buy: Button = null
for b in su._list.get_child(1).find_children("*", "Button", true, false):
r1_buy = b
if r1_buy:
r1_buy.pressed.emit()
_ck(su._grid.get_child_count() == 40, "shop_ex: tab 0 has 5x8 grid")
# tab 0 第二个货位slot 5)买 -> pos = 0*40 + 5
(su._grid.get_child(5) as Button).pressed.emit()
if su._buy_confirm:
su._buy_confirm.confirmed.emit()
_ck(fc.calls.has(["shop_buy", 5, 1]), "shop_ex: tab0 slot5 -> buy pos 5")
# 切到货架 2
su._tabbar.get_child(1).pressed.emit()
_ck(su._active_tab == 1, "shop_ex: switched to tab 1")
_ck(su._list.get_child_count() == 1, "shop_ex: tab 1 has 1 row")
var t1_buy: Button = null
for b in su._list.get_child(0).find_children("*", "Button", true, false):
t1_buy = b
if t1_buy:
t1_buy.pressed.emit()
_ck(su._grid.get_child_count() == 40, "shop_ex: tab 1 has 5x8 grid")
(su._grid.get_child(3) as Button).pressed.emit()
if su._buy_confirm:
su._buy_confirm.confirmed.emit()
_ck(fc.calls.has(["shop_buy", 43, 1]), "shop_ex: tab1 slot3 -> buy pos 1*40+3=43")
fc.shop_closed.emit()
fc.shop_tabs = []
@@ -289,15 +291,39 @@ func _run() -> void:
"peer_items": [], "self_gold": 100, "peer_gold": 0,
"self_accept": false, "peer_accept": true,
}
fc.inventory = [{"cell": 7, "vnum": 901, "count": 1, "anti_flags": 0}]
fc.exchange_changed.emit()
_ck(xu.is_open(), "exchange window opens when active")
_ck(xu._self_box.get_child_count() == 1, "exchange: 1 self item row")
_ck(xu._root.get_node("PeerAccept").text == "对方: 已接受", "exchange: peer accept shown")
_ck(not xu._accept_btn.disabled, "exchange: accept enabled before server accept")
xu._on_accept()
_ck(fc.calls.has(["ex_accept"]) and xu._accept_btn.disabled,
"exchange: accept sends once and disables immediately")
fc.exchange["self_accept"] = false
fc.exchange_changed.emit()
_ck(not xu._accept_btn.disabled, "exchange: server-cleared accept re-enables button")
xu.offer(1, 7)
_ck(fc.calls.has(["ex_add_item", 1, 7, 1]), "exchange: offer item uses first free display slot (1)")
fc.exchange["self_gold"] = 0
xu._gold_input.text = "500"
xu._on_put_gold()
_ck(fc.calls.has(["ex_gold", 500]), "exchange: put gold")
fc.exchange["self_gold"] = 500
xu._gold_input.text = "100"
xu._on_put_gold()
_ck(not fc.calls.has(["ex_gold", 100]), "exchange: existing gold cannot be edited")
fc.exchange["self_gold"] = 0
xu._gold_input.text = "10000000"
xu._on_put_gold()
_ck(not fc.calls.has(["ex_gold", 10000000]), "exchange: gold is limited to 7 digits")
fc.inventory = [{"cell": 8, "vnum": 902, "count": 1, "anti_flags": 1 << 13}]
_ck(not xu._drop_to_slot({"window": 1, "cell": 8, "vnum": 902, "count": 1}, 3),
"exchange: ANTIFLAG_GIVE item rejected")
fc.main_pos = Vector3(1001, 0, 0)
xu._process(0.1)
_ck(not xu.is_open() and fc.calls.has(["ex_cancel"]),
"exchange: moving beyond 1000 exits trade")
fc.exchange = {"active": false}
fc.exchange_changed.emit()
_ck(not xu.is_open(), "exchange closes when inactive")