Server: - CardSalvageValues: rarity-base + (SpCost+StCost)*CostMultiplier formula, foil 2x - CollectionSalvageCardHandler: collection.salvage_card — validates ownership, tradeable, not listed, deck copy check, then atomically deletes card + credits OP - BazaarGetPlayerShopHandler: bazaar.get_player_shop — paginated active listings for any seller with their display name (public read endpoint) - BazaarGetSuggestedPriceHandler: bazaar.get_suggested_price — recent sale avg if ≥3 sales, otherwise 4× salvage floor - Added GetPlayerShopRequest/Response + GetSuggestedPriceRequest/Response DTOs - Added SalvageCardRequest/Response DTOs - Registered all 3 new handlers in their respective ServiceRegistration files Client: - card_detail_popup: List for Sale form (with live price suggestion) + Salvage button with OP preview; both gated on IsTradeable - salvage_confirm_popup: confirmation modal that calls collection.salvage_card, emits confirmed(player_card_id, op_awarded) on success - bazaar_screen: My Shop tab (own active listings + cancel), player storefront search by account ID, sort options for own listings Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
550 lines
20 KiB
GDScript
550 lines
20 KiB
GDScript
extends VBoxContainer
|
||
## Bazaar — Boosters, Decks, Cosmetics, Cards marketplace, and My Shop.
|
||
##
|
||
## Five tabs with sort/filter controls.
|
||
## Cards tab: P2P marketplace with rarity/type filtering.
|
||
## My Shop tab: own active listings with cancel + re-list actions, plus a
|
||
## search field to navigate to another player's storefront.
|
||
|
||
const STORE_ITEM_ROW := preload("res://scenes/bazaar/components/StoreItemRow.tscn")
|
||
|
||
const FALLBACK_ART := "https://cdn.aeternalisgames.com/sor-assets/cardart/0_No-Card-Art.jpg"
|
||
|
||
const RARITY_ORDER := { "Common": 0, "Uncommon": 1, "Rare": 2, "Epic": 3, "Legendary": 4 }
|
||
|
||
enum Tab { BOOSTERS, DECKS, COSMETICS, CARDS, MY_SHOP }
|
||
|
||
# ── Node references ────────────────────────────────────────────────────────────
|
||
|
||
@onready var back_btn : Button = %BackBtn
|
||
@onready var balance_label : Label = %BalanceLabel
|
||
@onready var buy_op_btn : Button = %BuyOpBtn
|
||
@onready var boosters_tab_btn : Button = %BoostersTabBtn
|
||
@onready var decks_tab_btn : Button = %DecksTabBtn
|
||
@onready var cosmetics_tab_btn : Button = %CosmeticsTabBtn
|
||
@onready var cards_tab_btn : Button = %CardsTabBtn
|
||
@onready var my_shop_tab_btn : Button = %MyShopTabBtn
|
||
@onready var sort_option : OptionButton = %SortOption
|
||
@onready var filter_sep : VSeparator = %FilterSep
|
||
@onready var rarity_label : Label = %RarityLabel
|
||
@onready var rarity_option : OptionButton = %RarityOption
|
||
@onready var type_label : Label = %TypeLabel
|
||
@onready var type_option : OptionButton = %TypeOption
|
||
@onready var item_list : VBoxContainer = %ItemList
|
||
@onready var loading_label : Label = %LoadingLabel
|
||
@onready var empty_label : Label = %EmptyLabel
|
||
@onready var confirm_dialog : ConfirmationDialog = %ConfirmDialog
|
||
@onready var result_dialog : AcceptDialog = %ResultDialog
|
||
# My Shop tab extras
|
||
@onready var player_shop_row : HBoxContainer = %PlayerShopRow
|
||
@onready var player_shop_input : LineEdit = %PlayerShopInput
|
||
@onready var player_shop_btn : Button = %PlayerShopBtn
|
||
|
||
# ── Sort option labels per tab ─────────────────────────────────────────────────
|
||
|
||
const SORT_LABELS := {
|
||
Tab.BOOSTERS: ["Name A–Z", "Price ↑", "Price ↓", "Cards ↑", "Set"],
|
||
Tab.DECKS: ["Name A–Z", "Price ↑", "Price ↓", "Cards ↑"],
|
||
Tab.COSMETICS: ["Name A–Z", "Price ↑", "Price ↓", "Type"],
|
||
Tab.CARDS: ["Price ↑", "Price ↓", "Name A–Z", "Rarity"],
|
||
Tab.MY_SHOP: ["Listed ↓", "Price ↑", "Price ↓"],
|
||
}
|
||
|
||
# ── State ─────────────────────────────────────────────────────────────────────
|
||
|
||
var _tab : Tab = Tab.BOOSTERS
|
||
var _packs : Array = []
|
||
var _decks : Array = []
|
||
var _cosmetics : Array = []
|
||
var _listings : Array = [] # Cards tab (marketplace)
|
||
var _my_listings: Array = [] # My Shop tab
|
||
|
||
var _store_loaded := false
|
||
var _bal_loaded := false
|
||
var _listings_loaded := false
|
||
var _my_shop_loaded := false
|
||
|
||
var _pending_item : Dictionary = {}
|
||
var _pending_cancel_id : String = ""
|
||
var _buying := false
|
||
|
||
var _sort : Dictionary = {
|
||
Tab.BOOSTERS: 0, Tab.DECKS: 0, Tab.COSMETICS: 0, Tab.CARDS: 0, Tab.MY_SHOP: 0
|
||
}
|
||
var _rarity_filter : String = ""
|
||
var _type_filter : String = ""
|
||
|
||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||
|
||
func _ready() -> void:
|
||
ContentCache.apply_scene_background(self)
|
||
back_btn.pressed.connect(_on_back)
|
||
boosters_tab_btn.pressed.connect(func(): _switch_tab(Tab.BOOSTERS))
|
||
decks_tab_btn.pressed.connect(func(): _switch_tab(Tab.DECKS))
|
||
cosmetics_tab_btn.pressed.connect(func(): _switch_tab(Tab.COSMETICS))
|
||
cards_tab_btn.pressed.connect(func(): _switch_tab(Tab.CARDS))
|
||
my_shop_tab_btn.pressed.connect(func(): _switch_tab(Tab.MY_SHOP))
|
||
|
||
sort_option.item_selected.connect(_on_sort_changed)
|
||
rarity_option.item_selected.connect(_on_rarity_changed)
|
||
type_option.item_selected.connect(_on_type_changed)
|
||
confirm_dialog.confirmed.connect(_on_purchase_confirmed)
|
||
player_shop_btn.pressed.connect(_on_player_shop_search)
|
||
|
||
buy_op_btn.disabled = true # USD flow not yet available
|
||
|
||
_apply_tab_styles()
|
||
loading_label.visible = true
|
||
empty_label.visible = false
|
||
|
||
_fetch_data()
|
||
|
||
# ── Data fetching ─────────────────────────────────────────────────────────────
|
||
|
||
func _fetch_data() -> void:
|
||
_store_loaded = false
|
||
_bal_loaded = false
|
||
Network.request("bazaar.get_store", {}, _on_store_ok, _on_store_err)
|
||
Network.request("bazaar.get_my_balance", {}, _on_balance_ok, _on_balance_err)
|
||
|
||
|
||
func _fetch_listings() -> void:
|
||
_listings_loaded = false
|
||
Network.request(
|
||
"bazaar.get_listings",
|
||
{ "page": 1, "pageSize": 50 },
|
||
_on_listings_ok,
|
||
_on_listings_err
|
||
)
|
||
|
||
|
||
func _on_store_ok(_t: String, p: Variant) -> void:
|
||
var d := p as Dictionary
|
||
_packs = d.get("packs", [])
|
||
_decks = d.get("decks", [])
|
||
_cosmetics = d.get("cosmetics", [])
|
||
_store_loaded = true
|
||
_check_store_done()
|
||
|
||
|
||
func _on_store_err(code: String, _msg: String) -> void:
|
||
push_warning("Bazaar: get_store failed — %s" % code)
|
||
_store_loaded = true
|
||
_check_store_done()
|
||
|
||
|
||
func _on_balance_ok(_t: String, p: Variant) -> void:
|
||
balance_label.text = "◆ %d OP" % int((p as Dictionary).get("originPoints", 0))
|
||
_bal_loaded = true
|
||
_check_store_done()
|
||
|
||
|
||
func _on_balance_err(code: String, _msg: String) -> void:
|
||
push_warning("Bazaar: balance failed — %s" % code)
|
||
balance_label.text = "◆ — OP"
|
||
_bal_loaded = true
|
||
_check_store_done()
|
||
|
||
|
||
func _check_store_done() -> void:
|
||
if not (_store_loaded and _bal_loaded):
|
||
return
|
||
loading_label.visible = false
|
||
_setup_filter_bar()
|
||
_render_tab()
|
||
|
||
|
||
func _on_listings_ok(_t: String, p: Variant) -> void:
|
||
_listings = (p as Dictionary).get("listings", [])
|
||
_listings_loaded = true
|
||
_rebuild_type_filter()
|
||
loading_label.visible = false
|
||
_render_tab()
|
||
|
||
|
||
func _on_listings_err(code: String, _msg: String) -> void:
|
||
push_warning("Bazaar: get_listings failed — %s" % code)
|
||
_listings_loaded = true
|
||
loading_label.visible = false
|
||
_render_tab()
|
||
|
||
|
||
func _fetch_my_listings() -> void:
|
||
_my_shop_loaded = false
|
||
Network.request(
|
||
"bazaar.get_my_listings",
|
||
{ "statusFilter": "Active" },
|
||
_on_my_listings_ok,
|
||
_on_my_listings_err
|
||
)
|
||
|
||
|
||
func _on_my_listings_ok(_t: String, p: Variant) -> void:
|
||
_my_listings = (p as Dictionary).get("listings", [])
|
||
_my_shop_loaded = true
|
||
loading_label.visible = false
|
||
_render_tab()
|
||
|
||
|
||
func _on_my_listings_err(code: String, _msg: String) -> void:
|
||
push_warning("Bazaar: get_my_listings failed — %s" % code)
|
||
_my_shop_loaded = true
|
||
loading_label.visible = false
|
||
_render_tab()
|
||
|
||
# ── Tabs ──────────────────────────────────────────────────────────────────────
|
||
|
||
func _switch_tab(tab: Tab) -> void:
|
||
_tab = tab
|
||
_apply_tab_styles()
|
||
_setup_filter_bar()
|
||
|
||
if tab == Tab.CARDS and not _listings_loaded:
|
||
loading_label.visible = true
|
||
empty_label.visible = false
|
||
_clear_list()
|
||
_fetch_listings()
|
||
return
|
||
|
||
if tab == Tab.MY_SHOP and not _my_shop_loaded:
|
||
loading_label.visible = true
|
||
empty_label.visible = false
|
||
_clear_list()
|
||
_fetch_my_listings()
|
||
return
|
||
|
||
if _store_loaded and _bal_loaded:
|
||
_render_tab()
|
||
|
||
|
||
func _apply_tab_styles() -> void:
|
||
_style_tab(boosters_tab_btn, _tab == Tab.BOOSTERS)
|
||
_style_tab(decks_tab_btn, _tab == Tab.DECKS)
|
||
_style_tab(cosmetics_tab_btn, _tab == Tab.COSMETICS)
|
||
_style_tab(cards_tab_btn, _tab == Tab.CARDS)
|
||
_style_tab(my_shop_tab_btn, _tab == Tab.MY_SHOP)
|
||
|
||
|
||
func _style_tab(btn: Button, active: bool) -> void:
|
||
var s := StyleBoxFlat.new()
|
||
s.corner_radius_top_left = 6
|
||
s.corner_radius_top_right = 6
|
||
s.corner_radius_bottom_left = 6
|
||
s.corner_radius_bottom_right = 6
|
||
s.bg_color = Color(0.27, 0.47, 0.80, 1.0) if active else Color(0.18, 0.18, 0.26, 1.0)
|
||
s.border_width_bottom = 2 if active else 0
|
||
s.border_color = Color(0.5, 0.72, 1.0)
|
||
btn.add_theme_stylebox_override("normal", s)
|
||
btn.add_theme_stylebox_override("hover", s)
|
||
btn.add_theme_stylebox_override("pressed", s)
|
||
|
||
# ── Filter / sort bar ─────────────────────────────────────────────────────────
|
||
|
||
func _setup_filter_bar() -> void:
|
||
sort_option.clear()
|
||
for lbl: String in (SORT_LABELS as Dictionary)[_tab]:
|
||
sort_option.add_item(lbl)
|
||
sort_option.selected = _sort[_tab]
|
||
|
||
var is_cards := _tab == Tab.CARDS
|
||
var is_my_shop := _tab == Tab.MY_SHOP
|
||
filter_sep.visible = is_cards
|
||
rarity_label.visible = is_cards
|
||
rarity_option.visible = is_cards
|
||
type_label.visible = is_cards
|
||
type_option.visible = is_cards
|
||
# My Shop: show player shop search row
|
||
player_shop_row.visible = is_my_shop
|
||
|
||
|
||
func _rebuild_type_filter() -> void:
|
||
var types := PackedStringArray()
|
||
for l: Dictionary in _listings:
|
||
var t: String = l.get("cardType", "")
|
||
if not t.is_empty() and t not in types:
|
||
types.append(t)
|
||
types.sort()
|
||
|
||
type_option.clear()
|
||
type_option.add_item("All Types")
|
||
for t: String in types:
|
||
type_option.add_item(t)
|
||
|
||
rarity_option.clear()
|
||
rarity_option.add_item("All Rarities")
|
||
for r: String in ["Common", "Uncommon", "Rare", "Epic", "Legendary"]:
|
||
rarity_option.add_item(r)
|
||
|
||
|
||
func _on_sort_changed(idx: int) -> void:
|
||
_sort[_tab] = idx
|
||
_render_tab()
|
||
|
||
|
||
func _on_rarity_changed(idx: int) -> void:
|
||
_rarity_filter = "" if idx == 0 else rarity_option.get_item_text(idx)
|
||
_render_tab()
|
||
|
||
|
||
func _on_type_changed(idx: int) -> void:
|
||
_type_filter = "" if idx == 0 else type_option.get_item_text(idx)
|
||
_render_tab()
|
||
|
||
# ── Render ────────────────────────────────────────────────────────────────────
|
||
|
||
func _render_tab() -> void:
|
||
_clear_list()
|
||
|
||
var items: Array
|
||
match _tab:
|
||
Tab.BOOSTERS: items = _packs.duplicate()
|
||
Tab.DECKS: items = _decks.duplicate()
|
||
Tab.COSMETICS: items = _cosmetics.duplicate()
|
||
Tab.CARDS: items = _listings.duplicate()
|
||
Tab.MY_SHOP: items = _my_listings.duplicate()
|
||
|
||
items = _sort_items(items)
|
||
if _tab == Tab.CARDS:
|
||
items = _filter_cards(items)
|
||
|
||
empty_label.visible = items.is_empty()
|
||
|
||
for item: Dictionary in items:
|
||
var row := STORE_ITEM_ROW.instantiate()
|
||
item_list.add_child(row)
|
||
if _tab == Tab.CARDS:
|
||
row.setup_listing(item, FALLBACK_ART)
|
||
elif _tab == Tab.MY_SHOP:
|
||
row.setup_listing(item, FALLBACK_ART)
|
||
# Override buy button label to "Cancel" for own listings.
|
||
if row.has_method("set_action_label"):
|
||
row.set_action_label("Cancel")
|
||
row.buy_pressed.connect(_on_cancel_listing_pressed)
|
||
else:
|
||
row.setup(item, FALLBACK_ART)
|
||
row.buy_pressed.connect(_on_buy_pressed)
|
||
|
||
|
||
func _clear_list() -> void:
|
||
for c in item_list.get_children():
|
||
c.queue_free()
|
||
|
||
|
||
func _sort_items(items: Array) -> Array:
|
||
var idx: int = _sort[_tab]
|
||
match _tab:
|
||
Tab.BOOSTERS:
|
||
match idx:
|
||
0: items.sort_custom(func(a, b): return a.get("name","") < b.get("name",""))
|
||
1: items.sort_custom(func(a, b): return a.get("originPointPrice",0) < b.get("originPointPrice",0))
|
||
2: items.sort_custom(func(a, b): return a.get("originPointPrice",0) > b.get("originPointPrice",0))
|
||
3: items.sort_custom(func(a, b): return a.get("totalSlots",0) < b.get("totalSlots",0))
|
||
4: items.sort_custom(func(a, b): return str(a.get("cardSetId","")) < str(b.get("cardSetId","")))
|
||
Tab.DECKS:
|
||
match idx:
|
||
0: items.sort_custom(func(a, b): return a.get("name","") < b.get("name",""))
|
||
1: items.sort_custom(func(a, b): return a.get("originPointPrice",0) < b.get("originPointPrice",0))
|
||
2: items.sort_custom(func(a, b): return a.get("originPointPrice",0) > b.get("originPointPrice",0))
|
||
3: items.sort_custom(func(a, b): return a.get("totalCards",0) < b.get("totalCards",0))
|
||
Tab.COSMETICS:
|
||
match idx:
|
||
0: items.sort_custom(func(a, b): return a.get("name","") < b.get("name",""))
|
||
1: items.sort_custom(func(a, b): return a.get("originPointPrice",0) < b.get("originPointPrice",0))
|
||
2: items.sort_custom(func(a, b): return a.get("originPointPrice",0) > b.get("originPointPrice",0))
|
||
3: items.sort_custom(func(a, b): return a.get("cosmeticType","") < b.get("cosmeticType",""))
|
||
Tab.CARDS:
|
||
match idx:
|
||
0: items.sort_custom(func(a, b): return float(a.get("price",0)) < float(b.get("price",0)))
|
||
1: items.sort_custom(func(a, b): return float(a.get("price",0)) > float(b.get("price",0)))
|
||
2: items.sort_custom(func(a, b): return a.get("cardName","") < b.get("cardName",""))
|
||
3: items.sort_custom(func(a, b):
|
||
return RARITY_ORDER.get(a.get("rarity",""), 99) < RARITY_ORDER.get(b.get("rarity",""), 99))
|
||
Tab.MY_SHOP:
|
||
match idx:
|
||
0: items.sort_custom(func(a, b): return str(a.get("listedAt","")) > str(b.get("listedAt","")))
|
||
1: items.sort_custom(func(a, b): return float(a.get("price",0)) < float(b.get("price",0)))
|
||
2: items.sort_custom(func(a, b): return float(a.get("price",0)) > float(b.get("price",0)))
|
||
return items
|
||
|
||
|
||
func _filter_cards(items: Array) -> Array:
|
||
return items.filter(func(item: Dictionary) -> bool:
|
||
if not _rarity_filter.is_empty() and item.get("rarity","") != _rarity_filter:
|
||
return false
|
||
if not _type_filter.is_empty() and item.get("cardType","") != _type_filter:
|
||
return false
|
||
return true)
|
||
|
||
# ── Purchase flow ─────────────────────────────────────────────────────────────
|
||
|
||
func _on_buy_pressed(item: Dictionary) -> void:
|
||
_pending_item = item
|
||
var name_str : String = item.get("name", item.get("cardName", "?"))
|
||
var price_str : String
|
||
if _tab == Tab.CARDS:
|
||
price_str = "◆ %d OP" % int(float(item.get("price", 0)))
|
||
else:
|
||
price_str = "◆ %d OP" % int(item.get("originPointPrice", 0))
|
||
confirm_dialog.dialog_text = "Buy \"%s\" for %s?" % [name_str, price_str]
|
||
confirm_dialog.popup_centered()
|
||
|
||
|
||
func _on_purchase_confirmed() -> void:
|
||
if _pending_item.is_empty() or _buying:
|
||
return
|
||
_buying = true
|
||
|
||
var item := _pending_item
|
||
var tab := _tab
|
||
var id_str : String = str(item.get("id", ""))
|
||
|
||
var req_type : String
|
||
var req_payload : Dictionary
|
||
match tab:
|
||
Tab.BOOSTERS:
|
||
req_type = "bazaar.buy_booster_pack"
|
||
req_payload = { "packId": id_str }
|
||
Tab.DECKS:
|
||
req_type = "bazaar.buy_prebuilt_deck"
|
||
req_payload = { "deckId": id_str }
|
||
Tab.COSMETICS:
|
||
req_type = "bazaar.buy_cosmetic"
|
||
req_payload = { "cosmeticId": id_str }
|
||
Tab.CARDS:
|
||
req_type = "bazaar.buy_listing"
|
||
req_payload = { "listingId": id_str }
|
||
|
||
Network.request(req_type, req_payload,
|
||
func(_t: String, p: Variant): _on_purchase_ok(tab, p),
|
||
func(code: String, msg: String): _on_purchase_err(code, msg))
|
||
|
||
|
||
func _on_purchase_ok(tab: Tab, p: Variant) -> void:
|
||
_buying = false
|
||
var d := p as Dictionary
|
||
var new_bal: int = int(d.get("newOriginPointBalance", 0))
|
||
if new_bal > 0:
|
||
balance_label.text = "◆ %d OP" % new_bal
|
||
|
||
match tab:
|
||
Tab.BOOSTERS:
|
||
_show_pack_result(d.get("cardsOpened", []))
|
||
Tab.DECKS:
|
||
var dname: String = d.get("deckName", _pending_item.get("name", "deck"))
|
||
_show_result("Purchase Complete", "Deck \"%s\" added to your collection!" % dname)
|
||
Tab.COSMETICS:
|
||
_show_result("Purchase Complete", "\"%s\" added to your account!" % _pending_item.get("name", "item"))
|
||
Tab.CARDS:
|
||
var sold_id: String = str(_pending_item.get("id", ""))
|
||
_listings = _listings.filter(func(l: Dictionary) -> bool:
|
||
return str(l.get("id", "")) != sold_id)
|
||
_show_result("Purchase Complete", "Card purchased and added to your collection!")
|
||
|
||
_pending_item = {}
|
||
|
||
|
||
func _on_purchase_err(code: String, msg: String) -> void:
|
||
_buying = false
|
||
_pending_item = {}
|
||
_show_result("Purchase Failed", "Error: %s\n%s" % [code, msg])
|
||
|
||
|
||
func _show_pack_result(cards: Array) -> void:
|
||
var lines := PackedStringArray()
|
||
for card: Dictionary in cards:
|
||
var foil : String = " ✦" if bool(card.get("isFoil", false)) else ""
|
||
var serial = card.get("serialNumber", null)
|
||
var snum : String = " #%d" % int(serial) if serial != null else ""
|
||
lines.append("%s · %s · %s%s%s" % [
|
||
card.get("name", "?"),
|
||
card.get("rarity", ""),
|
||
card.get("affinity", ""),
|
||
foil, snum,
|
||
])
|
||
result_dialog.title = "Pack Opened! (%d cards)" % cards.size()
|
||
result_dialog.dialog_text = "\n".join(lines)
|
||
result_dialog.popup_centered()
|
||
|
||
|
||
func _show_result(title: String, body: String) -> void:
|
||
result_dialog.title = title
|
||
result_dialog.dialog_text = body
|
||
result_dialog.popup_centered()
|
||
|
||
# ── My Shop: cancel listing ────────────────────────────────────────────────────
|
||
|
||
func _on_cancel_listing_pressed(item: Dictionary) -> void:
|
||
var listing_id : String = str(item.get("id", ""))
|
||
var card_name : String = item.get("cardName", "this listing")
|
||
_pending_cancel_id = listing_id
|
||
confirm_dialog.dialog_text = "Cancel listing for \"%s\"?" % card_name
|
||
confirm_dialog.popup_centered()
|
||
# Re-route the confirmed signal to the cancel handler for this press.
|
||
if confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||
confirm_dialog.confirmed.disconnect(_on_purchase_confirmed)
|
||
if not confirm_dialog.confirmed.is_connected(_on_cancel_listing_confirmed):
|
||
confirm_dialog.confirmed.connect(_on_cancel_listing_confirmed, CONNECT_ONE_SHOT)
|
||
|
||
|
||
func _on_cancel_listing_confirmed() -> void:
|
||
if _pending_cancel_id.is_empty():
|
||
return
|
||
var lid := _pending_cancel_id
|
||
_pending_cancel_id = ""
|
||
Network.request(
|
||
"bazaar.cancel_listing",
|
||
{ "listingId": lid },
|
||
func(_t: String, _p: Variant):
|
||
_my_listings = _my_listings.filter(func(l: Dictionary) -> bool:
|
||
return str(l.get("id","")) != lid)
|
||
_render_tab()
|
||
# Reconnect original confirmed handler.
|
||
if not confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||
confirm_dialog.confirmed.connect(_on_purchase_confirmed),
|
||
func(code: String, _msg: String):
|
||
_show_result("Cancel Failed", "Error: %s" % code)
|
||
if not confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||
confirm_dialog.confirmed.connect(_on_purchase_confirmed)
|
||
)
|
||
|
||
# ── My Shop: view another player's storefront ──────────────────────────────────
|
||
|
||
func _on_player_shop_search() -> void:
|
||
var seller_id := player_shop_input.text.strip_edges()
|
||
if seller_id.is_empty():
|
||
return
|
||
loading_label.visible = true
|
||
_clear_list()
|
||
Network.request(
|
||
"bazaar.get_player_shop",
|
||
{ "sellerAccountId": seller_id, "page": 0, "pageSize": 50 },
|
||
_on_player_shop_ok,
|
||
_on_player_shop_err
|
||
)
|
||
|
||
|
||
func _on_player_shop_ok(_t: String, p: Variant) -> void:
|
||
var d := p as Dictionary
|
||
var name_ := str(d.get("sellerDisplayName", "Player"))
|
||
var listings: Array = d.get("listings", [])
|
||
loading_label.visible = false
|
||
_clear_list()
|
||
empty_label.visible = listings.is_empty()
|
||
for item: Dictionary in listings:
|
||
var row := STORE_ITEM_ROW.instantiate()
|
||
item_list.add_child(row)
|
||
row.setup_listing(item, FALLBACK_ART)
|
||
row.buy_pressed.connect(_on_buy_pressed)
|
||
# Show whose shop this is.
|
||
_show_result("%s's Shop" % name_, "%d active listing(s)" % listings.size())
|
||
|
||
|
||
func _on_player_shop_err(code: String, _msg: String) -> void:
|
||
loading_label.visible = false
|
||
_show_result("Shop Not Found", "Error: %s" % code)
|
||
|
||
# ── Navigation ─────────────────────────────────────────────────────────────────
|
||
|
||
func _on_back() -> void:
|
||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|