Cleaning up errors on Deck editor of client

This commit is contained in:
dingo
2026-03-20 11:01:16 -04:00
parent 2e3a5e4569
commit 6c6a66c011
@@ -36,6 +36,7 @@ var _coll_total : int = 0
var _has_more : bool = false
var _is_loading : bool = false
var _search_timer : float = 0.0
var _coll_req_gen : int = 0
const _DEBOUNCE := 0.4
# ── Lifecycle ─────────────────────────────────────────────────────────────────
@@ -225,7 +226,7 @@ func _make_right_pane() -> VBoxContainer:
func _populate_type_options() -> void:
_type_option.clear()
_type_option.add_item("All Types")
for t in ["Creature", "Spell", "Item", "ArchSpirit"]:
for t in ["ArchSpirit", "Spirit", "Ruin", "Terramorpha", "Repentance", "Instinct"]:
_type_option.add_item(t)
# ── Public ────────────────────────────────────────────────────────────────────
@@ -340,47 +341,58 @@ func _reload_collection() -> void:
func _fetch_coll_page(page: int) -> void:
if _is_loading:
return
_is_loading = true
_coll_loading_lbl.visible = true
# Bump generation so stale async responses can be ignored.
_coll_req_gen += 1
var req_gen := _coll_req_gen
var payload := { "page": page, "pageSize": PAGE_SIZE }
var search := _search_input.text.strip_edges()
if not search.is_empty():
payload["nameFilter"] = search
var type_idx := _type_option.selected
if type_idx > 0:
payload["cardTypeFilter"] = _type_option.get_item_text(type_idx)
Network.request(
"collection.get_cards",
payload,
func(_t: String, p: Variant): _on_coll_response(p, page),
func(_code: String, msg: String): _on_coll_error(msg)
)
"collection.get_cards",
payload,
func(_t: String, p: Variant):
_on_coll_response(p, page, req_gen),
func(_code: String, msg: String):
# Only surface error if this is still current request generation.
if req_gen == _coll_req_gen:
_on_coll_error(msg)
)
func _on_coll_response(payload: Variant, page: int) -> void:
func _on_coll_response(payload: Variant, page: int, req_gen: int) -> void:
if req_gen != _coll_req_gen:
return
var p_cache := payload as Dictionary
CollectionCache.store_cards_response(_collection_query_key(page), p_cache)
_render_coll_response(p_cache, page)
var cards : Array = []
# Track def_ids already in the list to avoid duplicates across pages
var seen : Dictionary = {}
for child in _coll_list.get_children():
if child.has_meta("def_id"):
seen[str(child.get_meta("def_id"))] = true
for dto in cards:
var def_id := str(dto.get("cardDefinitionId", ""))
if def_id.is_empty() or def_id in seen:
continue
## Tier 1 ArchSpirits are commanders — cannot be added as deck cards
#if str(dto.get("cardType", "")) == "ArchSpirit" \
#and int(dto.get("tier", 1)) <= 1:
#var cards : Array = []
#
## Track def_ids already in the list to avoid duplicates across pages
#var seen : Dictionary = {}
#for child in _coll_list.get_children():
#if child.has_meta("def_id"):
#seen[str(child.get_meta("def_id"))] = true
#
#for dto in cards:
#var def_id := str(dto.get("cardDefinitionId", ""))
#if def_id.is_empty() or def_id in seen:
#continue
seen[def_id] = true
_coll_list.add_child(_make_coll_row(dto))
### Tier 1 ArchSpirits are commanders — cannot be added as deck cards
##if str(dto.get("cardType", "")) == "ArchSpirit" \
##and int(dto.get("tier", 1)) <= 1:
##continue
#seen[def_id] = true
#_coll_list.add_child(_make_coll_row(dto))
func _on_coll_error(msg: String) -> void: