|
|
|
@@ -246,6 +246,9 @@ func _load_deck_contents() -> void:
|
|
|
|
|
for child in _deck_card_list.get_children():
|
|
|
|
|
child.queue_free()
|
|
|
|
|
_deck_loading_lbl.visible = true
|
|
|
|
|
var cached := CollectionCache.get_deck_response(_deck_id)
|
|
|
|
|
if not cached.is_empty():
|
|
|
|
|
_render_deck_response(cached)
|
|
|
|
|
Network.request(
|
|
|
|
|
"collection.get_deck",
|
|
|
|
|
{ "deckId": _deck_id },
|
|
|
|
@@ -255,31 +258,9 @@ func _load_deck_contents() -> void:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_deck_response(payload: Variant) -> void:
|
|
|
|
|
_deck_loading_lbl.visible = false
|
|
|
|
|
var p := payload as Dictionary
|
|
|
|
|
var deck_raw : Variant = p.get("deck", null)
|
|
|
|
|
if deck_raw == null or typeof(deck_raw) != TYPE_DICTIONARY:
|
|
|
|
|
push_warning("DeckEditor: missing deck in response")
|
|
|
|
|
return
|
|
|
|
|
var deck := deck_raw as Dictionary
|
|
|
|
|
|
|
|
|
|
var cards : Array = deck.get("cards", [])
|
|
|
|
|
_deck_qty.clear()
|
|
|
|
|
var non_as_total := 0
|
|
|
|
|
for c in cards:
|
|
|
|
|
var def_id := str(c.get("cardDefinitionId", ""))
|
|
|
|
|
var qty := int(c.get("quantity", 0))
|
|
|
|
|
if not def_id.is_empty():
|
|
|
|
|
_deck_qty[def_id] = qty
|
|
|
|
|
if str(c.get("cardType", "")) != "ArchSpirit":
|
|
|
|
|
non_as_total += qty
|
|
|
|
|
|
|
|
|
|
_count_lbl.text = "%d / 40" % non_as_total
|
|
|
|
|
|
|
|
|
|
for c in cards:
|
|
|
|
|
_deck_card_list.add_child(_make_deck_row(c))
|
|
|
|
|
|
|
|
|
|
_refresh_coll_in_deck_labels()
|
|
|
|
|
var p := payload as Dictionary
|
|
|
|
|
CollectionCache.store_deck_response(_deck_id, p)
|
|
|
|
|
_render_deck_response(p)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_deck_error(msg: String) -> void:
|
|
|
|
@@ -350,6 +331,9 @@ func _reload_collection() -> void:
|
|
|
|
|
for child in _coll_list.get_children():
|
|
|
|
|
child.queue_free()
|
|
|
|
|
_load_more_btn.visible = false
|
|
|
|
|
var cached := CollectionCache.get_cards_response(_collection_query_key(1))
|
|
|
|
|
if not cached.is_empty():
|
|
|
|
|
_render_coll_response(cached, 1)
|
|
|
|
|
_fetch_coll_page(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -376,15 +360,10 @@ func _fetch_coll_page(page: int) -> void:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_coll_response(payload: Variant, page: int) -> void:
|
|
|
|
|
_is_loading = false
|
|
|
|
|
_coll_loading_lbl.visible = false
|
|
|
|
|
var p := payload as Dictionary
|
|
|
|
|
var cards : Array = p.get("cards", [])
|
|
|
|
|
_coll_total = int(p.get("totalCount", 0))
|
|
|
|
|
var ps := int(p.get("pageSize", PAGE_SIZE))
|
|
|
|
|
_coll_page = page
|
|
|
|
|
_has_more = (page * ps) < _coll_total
|
|
|
|
|
_load_more_btn.visible = _has_more
|
|
|
|
|
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 = {}
|
|
|
|
@@ -497,3 +476,94 @@ func _remove_card(def_id: String, qty: Variant) -> void:
|
|
|
|
|
func(_t: String, _p: Variant): _load_deck_contents(),
|
|
|
|
|
func(_code: String, msg: String): push_warning("DeckEditor remove_card: %s" % msg)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _render_deck_response(payload: Dictionary) -> void:
|
|
|
|
|
_deck_loading_lbl.visible = false
|
|
|
|
|
var deck_raw : Variant = payload.get("deck", null)
|
|
|
|
|
if deck_raw == null or typeof(deck_raw) != TYPE_DICTIONARY:
|
|
|
|
|
push_warning("DeckEditor: missing deck in response")
|
|
|
|
|
return
|
|
|
|
|
var deck := deck_raw as Dictionary
|
|
|
|
|
|
|
|
|
|
for child in _deck_card_list.get_children():
|
|
|
|
|
child.queue_free()
|
|
|
|
|
|
|
|
|
|
var cards : Array = deck.get("cards", [])
|
|
|
|
|
_deck_qty.clear()
|
|
|
|
|
var non_as_total := 0
|
|
|
|
|
for raw_card in cards:
|
|
|
|
|
var card := raw_card as Dictionary
|
|
|
|
|
var def_id := str(card.get("cardDefinitionId", ""))
|
|
|
|
|
var qty := int(card.get("quantity", 0))
|
|
|
|
|
if not def_id.is_empty():
|
|
|
|
|
_deck_qty[def_id] = qty
|
|
|
|
|
var def := ContentCache.get_definition(def_id)
|
|
|
|
|
if str(def.get("cardType", "")) != "ArchSpirit":
|
|
|
|
|
non_as_total += qty
|
|
|
|
|
|
|
|
|
|
_count_lbl.text = "%d / 40" % non_as_total
|
|
|
|
|
|
|
|
|
|
for raw_card in cards:
|
|
|
|
|
var card := raw_card as Dictionary
|
|
|
|
|
var def := ContentCache.get_definition(str(card.get("cardDefinitionId", "")))
|
|
|
|
|
_deck_card_list.add_child(_make_deck_row(_hydrate_card_dto(card, def)))
|
|
|
|
|
|
|
|
|
|
_refresh_coll_in_deck_labels()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _render_coll_response(payload: Dictionary, page: int) -> void:
|
|
|
|
|
_is_loading = false
|
|
|
|
|
_coll_loading_lbl.visible = false
|
|
|
|
|
var cards : Array = payload.get("cards", [])
|
|
|
|
|
_coll_total = int(payload.get("totalCount", 0))
|
|
|
|
|
var page_size := int(payload.get("pageSize", PAGE_SIZE))
|
|
|
|
|
_coll_page = page
|
|
|
|
|
_has_more = (page * page_size) < _coll_total
|
|
|
|
|
_load_more_btn.visible = _has_more
|
|
|
|
|
|
|
|
|
|
if page == 1:
|
|
|
|
|
for child in _coll_list.get_children():
|
|
|
|
|
child.queue_free()
|
|
|
|
|
|
|
|
|
|
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 raw_dto in cards:
|
|
|
|
|
var dto := raw_dto as Dictionary
|
|
|
|
|
var def_id := str(dto.get("cardDefinitionId", ""))
|
|
|
|
|
if def_id.is_empty() or def_id in seen:
|
|
|
|
|
continue
|
|
|
|
|
var def := ContentCache.get_definition(def_id)
|
|
|
|
|
var tier_value: Variant = def.get("tier", null)
|
|
|
|
|
var tier_num := 1
|
|
|
|
|
if tier_value != null:
|
|
|
|
|
tier_num = type_convert(tier_value, TYPE_INT)
|
|
|
|
|
if str(def.get("cardType", "")) == "ArchSpirit" and tier_num <= 1:
|
|
|
|
|
continue
|
|
|
|
|
seen[def_id] = true
|
|
|
|
|
_coll_list.add_child(_make_coll_row(_hydrate_card_dto(dto, def)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _hydrate_card_dto(dto: Dictionary, def: Dictionary) -> Dictionary:
|
|
|
|
|
var hydrated := dto.duplicate(true)
|
|
|
|
|
if def.is_empty():
|
|
|
|
|
return hydrated
|
|
|
|
|
hydrated["name"] = str(def.get("name", hydrated.get("name", "")))
|
|
|
|
|
hydrated["cardType"] = str(def.get("cardType", hydrated.get("cardType", "")))
|
|
|
|
|
hydrated["affinity"] = str(def.get("affinity", hydrated.get("affinity", "")))
|
|
|
|
|
hydrated["rarity"] = str(def.get("rarity", hydrated.get("rarity", "")))
|
|
|
|
|
var tier_value: Variant = def.get("tier", hydrated.get("tier", null))
|
|
|
|
|
hydrated["tier"] = tier_value if tier_value != null else null
|
|
|
|
|
return hydrated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _collection_query_key(page: int) -> String:
|
|
|
|
|
var search := _search_input.text.strip_edges()
|
|
|
|
|
var type_filter := ""
|
|
|
|
|
var type_idx := _type_option.selected
|
|
|
|
|
if type_idx > 0:
|
|
|
|
|
type_filter = _type_option.get_item_text(type_idx)
|
|
|
|
|
return CollectionCache.cards_query_key(page, PAGE_SIZE, search, type_filter)
|
|
|
|
|