minor admin portal changes
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://4mh5cogtbbs"
|
||||
path="res://.godot/imported/affinity_aether.svg-94416b3b4609b11111b5df16433cf2fc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_aether.svg"
|
||||
dest_files=["res://.godot/imported/affinity_aether.svg-94416b3b4609b11111b5df16433cf2fc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://6i3ktu04l0ms"
|
||||
path="res://.godot/imported/affinity_field.svg-522f55c63657d49c7a61f49fbee59ad9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_field.svg"
|
||||
dest_files=["res://.godot/imported/affinity_field.svg-522f55c63657d49c7a61f49fbee59ad9.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://crsfc8df6jgre"
|
||||
path="res://.godot/imported/affinity_forest.svg-a4958271ee14ec71c38042778dd9f8d5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_forest.svg"
|
||||
dest_files=["res://.godot/imported/affinity_forest.svg-a4958271ee14ec71c38042778dd9f8d5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://wt0ll4hwq318"
|
||||
path="res://.godot/imported/affinity_hill.svg-45b1af6a14655e78023c872d7bbd7c4e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_hill.svg"
|
||||
dest_files=["res://.godot/imported/affinity_hill.svg-45b1af6a14655e78023c872d7bbd7c4e.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://233i8peaj58m"
|
||||
path="res://.godot/imported/affinity_lake.svg-ceff37b42daa3548303e2c64fe8d446a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_lake.svg"
|
||||
dest_files=["res://.godot/imported/affinity_lake.svg-ceff37b42daa3548303e2c64fe8d446a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bqldes7t1q8qf"
|
||||
path="res://.godot/imported/affinity_void.svg-f333dd7317a7791605c4a601829f32e6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icons/affinity_void.svg"
|
||||
dest_files=["res://.godot/imported/affinity_void.svg-f333dd7317a7791605c4a601829f32e6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://qvv1n31fsf8k"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/card_widget.gd" id="1_cw"]
|
||||
[ext_resource type="Script" uid="uid://cqrcq3lrws6qm" path="res://scenes/collection/components/card_widget.gd" id="1_cw"]
|
||||
|
||||
[node name="CardWidget" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(146, 204)
|
||||
@@ -18,15 +18,15 @@ layout_mode = 2
|
||||
theme_override_constants/separation = 3
|
||||
|
||||
[node name="TopRow" type="HBoxContainer" parent="Margin/VBox"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 20)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="SpLabel" type="Label" parent="Margin/VBox/TopRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "◆?"
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "◆?"
|
||||
|
||||
[node name="TopFill" type="Control" parent="Margin/VBox/TopRow"]
|
||||
layout_mode = 2
|
||||
@@ -34,23 +34,22 @@ size_flags_horizontal = 3
|
||||
|
||||
[node name="FoilLabel" type="Label" parent="Margin/VBox/TopRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "✦"
|
||||
visible = false
|
||||
modulate = Color(0.95, 0.85, 0.30, 1.0)
|
||||
modulate = Color(0.95, 0.85, 0.3, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "✦"
|
||||
|
||||
[node name="StLabel" type="Label" parent="Margin/VBox/TopRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="ArtArea" type="Panel" parent="Margin/VBox"]
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
|
||||
[node name="ArtRect" type="ColorRect" parent="Margin/VBox/ArtArea"]
|
||||
unique_name_in_owner = true
|
||||
@@ -60,10 +59,11 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.18, 0.18, 0.24, 1.0)
|
||||
color = Color(0.18, 0.18, 0.24, 1)
|
||||
|
||||
[node name="ArtSymbol" type="TextureRect" parent="Margin/VBox/ArtArea"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0.85)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -72,26 +72,24 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
modulate = Color(1, 1, 1, 0.85)
|
||||
|
||||
[node name="NameLabel" type="Label" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 18)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Card Name"
|
||||
text_overrun_behavior = 3
|
||||
custom_minimum_size = Vector2(0, 18)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="TypeRarityRow" type="HBoxContainer" parent="Margin/VBox"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 14)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="TypeLabel" type="Label" parent="Margin/VBox/TypeRarityRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
modulate = Color(0.70, 0.70, 0.75, 1.0)
|
||||
theme_override_font_sizes/font_size = 10
|
||||
|
||||
[node name="TypeFill" type="Control" parent="Margin/VBox/TypeRarityRow"]
|
||||
@@ -101,19 +99,18 @@ size_flags_horizontal = 3
|
||||
[node name="RarityLabel" type="Label" parent="Margin/VBox/TypeRarityRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
theme_override_font_sizes/font_size = 10
|
||||
|
||||
[node name="StatsRow" type="HBoxContainer" parent="Margin/VBox"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 18)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="DmgLabel" type="Label" parent="Margin/VBox/StatsRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "⚔ –"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "⚔ –"
|
||||
|
||||
[node name="StatsFill" type="Control" parent="Margin/VBox/StatsRow"]
|
||||
layout_mode = 2
|
||||
@@ -122,8 +119,8 @@ size_flags_horizontal = 3
|
||||
[node name="HpLabel" type="Label" parent="Margin/VBox/StatsRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "♥ –"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "♥ –"
|
||||
|
||||
[node name="StatsFill2" type="Control" parent="Margin/VBox/StatsRow"]
|
||||
layout_mode = 2
|
||||
@@ -132,5 +129,5 @@ size_flags_horizontal = 3
|
||||
[node name="DefLabel" type="Label" parent="Margin/VBox/StatsRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "▲ –"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "▲ –"
|
||||
|
||||
@@ -72,6 +72,14 @@ theme_override_font_sizes/font_size = 11
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="EditBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(60, 36)
|
||||
text = "Edit"
|
||||
tooltip_text = "Edit deck contents"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="RenameBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
@@ -212,7 +212,7 @@ func _load_stats(def: Dictionary) -> void:
|
||||
|
||||
|
||||
func _load_abilities(def: Dictionary) -> void:
|
||||
var json_str := str(def.get("abilitiesJson", ""))
|
||||
var json_str := str(def.get("abilities", ""))
|
||||
if json_str.is_empty() or json_str == "[]":
|
||||
return
|
||||
var parsed: Variant = JSON.parse_string(json_str)
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
extends VBoxContainer
|
||||
## Deck editor panel — add/remove cards from an existing deck.
|
||||
##
|
||||
## The entire UI is built programmatically in _setup_ui() so no separate
|
||||
## .tscn is needed. Embed this script on a VBoxContainer node in DecksView.
|
||||
##
|
||||
## Usage:
|
||||
## call open_deck(deck_id, deck_name) to load a deck for editing.
|
||||
## connect back_pressed to return to the deck list.
|
||||
|
||||
signal back_pressed()
|
||||
|
||||
const PAGE_SIZE := 50
|
||||
|
||||
# ── Node refs (created in _setup_ui) ─────────────────────────────────────────
|
||||
|
||||
var _title_lbl : Label
|
||||
var _count_lbl : Label
|
||||
var _deck_loading_lbl : Label
|
||||
var _deck_card_list : VBoxContainer
|
||||
var _search_input : LineEdit
|
||||
var _type_option : OptionButton
|
||||
var _coll_loading_lbl : Label
|
||||
var _coll_list : VBoxContainer
|
||||
var _load_more_btn : Button
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _deck_id : String = ""
|
||||
var _deck_name : String = ""
|
||||
## { cardDefinitionId(String): quantity(int) } — kept in sync after mutations
|
||||
var _deck_qty : Dictionary = {}
|
||||
|
||||
var _coll_page : int = 1
|
||||
var _coll_total : int = 0
|
||||
var _has_more : bool = false
|
||||
var _is_loading : bool = false
|
||||
var _search_timer : float = 0.0
|
||||
const _DEBOUNCE := 0.4
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_ui()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _search_timer > 0.0:
|
||||
_search_timer -= delta
|
||||
if _search_timer <= 0.0:
|
||||
_search_timer = 0.0
|
||||
_reload_collection()
|
||||
|
||||
# ── UI construction ───────────────────────────────────────────────────────────
|
||||
|
||||
func _setup_ui() -> void:
|
||||
size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
add_theme_constant_override("separation", 0)
|
||||
|
||||
# Top bar
|
||||
var top_panel := PanelContainer.new()
|
||||
var top_margin := MarginContainer.new()
|
||||
top_margin.add_theme_constant_override("margin_left", 10)
|
||||
top_margin.add_theme_constant_override("margin_right", 10)
|
||||
top_margin.add_theme_constant_override("margin_top", 8)
|
||||
top_margin.add_theme_constant_override("margin_bottom", 8)
|
||||
top_panel.add_child(top_margin)
|
||||
|
||||
var top_bar := HBoxContainer.new()
|
||||
top_bar.add_theme_constant_override("separation", 8)
|
||||
top_margin.add_child(top_bar)
|
||||
|
||||
var back_btn := Button.new()
|
||||
back_btn.text = "◄ Back"
|
||||
back_btn.custom_minimum_size = Vector2(80, 32)
|
||||
back_btn.pressed.connect(func(): back_pressed.emit())
|
||||
top_bar.add_child(back_btn)
|
||||
|
||||
_title_lbl = Label.new()
|
||||
_title_lbl.text = "Editing deck"
|
||||
_title_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_title_lbl.add_theme_font_size_override("font_size", 15)
|
||||
_title_lbl.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
top_bar.add_child(_title_lbl)
|
||||
|
||||
_count_lbl = Label.new()
|
||||
_count_lbl.text = "0 / 40"
|
||||
_count_lbl.add_theme_font_size_override("font_size", 13)
|
||||
_count_lbl.modulate = Color(0.75, 0.75, 0.8)
|
||||
top_bar.add_child(_count_lbl)
|
||||
|
||||
add_child(top_panel)
|
||||
|
||||
# Split area
|
||||
var split := HBoxContainer.new()
|
||||
split.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
split.add_theme_constant_override("separation", 0)
|
||||
|
||||
var left := _make_left_pane()
|
||||
left.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
split.add_child(left)
|
||||
|
||||
var vsep := VSeparator.new()
|
||||
split.add_child(vsep)
|
||||
|
||||
var right := _make_right_pane()
|
||||
right.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
split.add_child(right)
|
||||
|
||||
add_child(split)
|
||||
|
||||
|
||||
func _make_left_pane() -> VBoxContainer:
|
||||
var pane := VBoxContainer.new()
|
||||
pane.add_theme_constant_override("separation", 4)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
pane.add_child(margin)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
inner.add_theme_constant_override("separation", 4)
|
||||
margin.add_child(inner)
|
||||
|
||||
var hdr := Label.new()
|
||||
hdr.text = "Deck Contents"
|
||||
hdr.add_theme_font_size_override("font_size", 13)
|
||||
hdr.modulate = Color(0.8, 0.8, 0.85)
|
||||
inner.add_child(hdr)
|
||||
|
||||
_deck_loading_lbl = Label.new()
|
||||
_deck_loading_lbl.text = "Loading…"
|
||||
_deck_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
|
||||
_deck_loading_lbl.add_theme_font_size_override("font_size", 12)
|
||||
_deck_loading_lbl.visible = false
|
||||
inner.add_child(_deck_loading_lbl)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
inner.add_child(scroll)
|
||||
|
||||
_deck_card_list = VBoxContainer.new()
|
||||
_deck_card_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_deck_card_list.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(_deck_card_list)
|
||||
|
||||
return pane
|
||||
|
||||
|
||||
func _make_right_pane() -> VBoxContainer:
|
||||
var pane := VBoxContainer.new()
|
||||
pane.add_theme_constant_override("separation", 4)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
pane.add_child(margin)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
inner.add_theme_constant_override("separation", 4)
|
||||
margin.add_child(inner)
|
||||
|
||||
var hdr := Label.new()
|
||||
hdr.text = "Add Cards"
|
||||
hdr.add_theme_font_size_override("font_size", 13)
|
||||
hdr.modulate = Color(0.8, 0.8, 0.85)
|
||||
inner.add_child(hdr)
|
||||
|
||||
var search_bar := HBoxContainer.new()
|
||||
search_bar.add_theme_constant_override("separation", 4)
|
||||
inner.add_child(search_bar)
|
||||
|
||||
_search_input = LineEdit.new()
|
||||
_search_input.placeholder_text = "Search…"
|
||||
_search_input.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_search_input.custom_minimum_size = Vector2(0, 30)
|
||||
_search_input.add_theme_font_size_override("font_size", 13)
|
||||
_search_input.text_changed.connect(_on_search_changed)
|
||||
search_bar.add_child(_search_input)
|
||||
|
||||
_type_option = OptionButton.new()
|
||||
_type_option.custom_minimum_size = Vector2(110, 30)
|
||||
_type_option.add_theme_font_size_override("font_size", 12)
|
||||
_type_option.item_selected.connect(func(_i): _reload_collection())
|
||||
_populate_type_options()
|
||||
search_bar.add_child(_type_option)
|
||||
|
||||
_coll_loading_lbl = Label.new()
|
||||
_coll_loading_lbl.text = "Loading…"
|
||||
_coll_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
|
||||
_coll_loading_lbl.add_theme_font_size_override("font_size", 12)
|
||||
_coll_loading_lbl.visible = false
|
||||
inner.add_child(_coll_loading_lbl)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
inner.add_child(scroll)
|
||||
|
||||
_coll_list = VBoxContainer.new()
|
||||
_coll_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_coll_list.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(_coll_list)
|
||||
|
||||
_load_more_btn = Button.new()
|
||||
_load_more_btn.text = "Load More"
|
||||
_load_more_btn.visible = false
|
||||
_load_more_btn.pressed.connect(_on_load_more)
|
||||
inner.add_child(_load_more_btn)
|
||||
|
||||
return pane
|
||||
|
||||
|
||||
func _populate_type_options() -> void:
|
||||
_type_option.clear()
|
||||
_type_option.add_item("All Types")
|
||||
for t in ["Creature", "Spell", "Item", "ArchSpirit"]:
|
||||
_type_option.add_item(t)
|
||||
|
||||
# ── Public ────────────────────────────────────────────────────────────────────
|
||||
|
||||
func open_deck(deck_id: String, deck_name: String) -> void:
|
||||
_deck_id = deck_id
|
||||
_deck_name = deck_name
|
||||
_title_lbl.text = "Editing: %s" % deck_name
|
||||
_search_input.text = ""
|
||||
_type_option.selected = 0
|
||||
_deck_qty.clear()
|
||||
_load_deck_contents()
|
||||
_reload_collection()
|
||||
|
||||
# ── Deck contents ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _load_deck_contents() -> void:
|
||||
for child in _deck_card_list.get_children():
|
||||
child.queue_free()
|
||||
_deck_loading_lbl.visible = true
|
||||
Network.request(
|
||||
"collection.get_deck",
|
||||
{ "deckId": _deck_id },
|
||||
func(_t: String, p: Variant): _on_deck_response(p),
|
||||
func(_code: String, msg: String): _on_deck_error(msg)
|
||||
)
|
||||
|
||||
|
||||
func _on_deck_response(payload: Variant) -> void:
|
||||
_deck_loading_lbl.visible = false
|
||||
var p := payload as Dictionary
|
||||
var deck_raw := 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()
|
||||
|
||||
|
||||
func _on_deck_error(msg: String) -> void:
|
||||
_deck_loading_lbl.visible = false
|
||||
push_warning("DeckEditor get_deck: %s" % msg)
|
||||
|
||||
|
||||
func _make_deck_row(card: Dictionary) -> Control:
|
||||
var def_id := str(card.get("cardDefinitionId", ""))
|
||||
var qty := int(card.get("quantity", 0))
|
||||
var owned := int(card.get("ownedCount", 0))
|
||||
|
||||
var outer := MarginContainer.new()
|
||||
outer.add_theme_constant_override("margin_left", 2)
|
||||
outer.add_theme_constant_override("margin_right", 2)
|
||||
outer.add_theme_constant_override("margin_top", 1)
|
||||
outer.add_theme_constant_override("margin_bottom", 1)
|
||||
outer.set_meta("def_id", def_id)
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 4)
|
||||
outer.add_child(row)
|
||||
|
||||
var info := VBoxContainer.new()
|
||||
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
info.add_theme_constant_override("separation", 1)
|
||||
row.add_child(info)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = str(card.get("name", "?"))
|
||||
name_lbl.add_theme_font_size_override("font_size", 13)
|
||||
name_lbl.clip_text = true
|
||||
info.add_child(name_lbl)
|
||||
|
||||
var sub_lbl := Label.new()
|
||||
sub_lbl.text = "%s · %s" % [str(card.get("cardType", "")), str(card.get("affinity", ""))]
|
||||
sub_lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.62))
|
||||
sub_lbl.add_theme_font_size_override("font_size", 10)
|
||||
info.add_child(sub_lbl)
|
||||
|
||||
var qty_lbl := Label.new()
|
||||
qty_lbl.text = "×%d/%d" % [qty, owned]
|
||||
qty_lbl.add_theme_font_size_override("font_size", 12)
|
||||
qty_lbl.custom_minimum_size = Vector2(52, 0)
|
||||
qty_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
row.add_child(qty_lbl)
|
||||
|
||||
var minus_btn := Button.new()
|
||||
minus_btn.text = "–"
|
||||
minus_btn.custom_minimum_size = Vector2(28, 30)
|
||||
minus_btn.pressed.connect(func(): _remove_card(def_id, 1))
|
||||
row.add_child(minus_btn)
|
||||
|
||||
var remove_btn := Button.new()
|
||||
remove_btn.text = "✕"
|
||||
remove_btn.custom_minimum_size = Vector2(28, 30)
|
||||
remove_btn.pressed.connect(func(): _remove_card(def_id, null))
|
||||
row.add_child(remove_btn)
|
||||
|
||||
return outer
|
||||
|
||||
# ── Collection browser ────────────────────────────────────────────────────────
|
||||
|
||||
func _reload_collection() -> void:
|
||||
_coll_page = 1
|
||||
_coll_total = 0
|
||||
_has_more = false
|
||||
for child in _coll_list.get_children():
|
||||
child.queue_free()
|
||||
_load_more_btn.visible = false
|
||||
_fetch_coll_page(1)
|
||||
|
||||
|
||||
func _fetch_coll_page(page: int) -> void:
|
||||
if _is_loading:
|
||||
return
|
||||
_is_loading = true
|
||||
_coll_loading_lbl.visible = true
|
||||
|
||||
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)
|
||||
)
|
||||
|
||||
|
||||
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
|
||||
|
||||
# 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:
|
||||
continue
|
||||
seen[def_id] = true
|
||||
_coll_list.add_child(_make_coll_row(dto))
|
||||
|
||||
|
||||
func _on_coll_error(msg: String) -> void:
|
||||
_is_loading = false
|
||||
_coll_loading_lbl.visible = false
|
||||
push_warning("DeckEditor collection: %s" % msg)
|
||||
|
||||
|
||||
func _make_coll_row(dto: Dictionary) -> Control:
|
||||
var def_id := str(dto.get("cardDefinitionId", ""))
|
||||
var in_deck := int(_deck_qty.get(def_id, 0))
|
||||
|
||||
var outer := MarginContainer.new()
|
||||
outer.add_theme_constant_override("margin_left", 2)
|
||||
outer.add_theme_constant_override("margin_right", 2)
|
||||
outer.add_theme_constant_override("margin_top", 1)
|
||||
outer.add_theme_constant_override("margin_bottom", 1)
|
||||
outer.set_meta("def_id", def_id)
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 4)
|
||||
outer.add_child(row)
|
||||
|
||||
var info := VBoxContainer.new()
|
||||
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
info.add_theme_constant_override("separation", 1)
|
||||
row.add_child(info)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = str(dto.get("name", "?"))
|
||||
name_lbl.add_theme_font_size_override("font_size", 13)
|
||||
name_lbl.clip_text = true
|
||||
info.add_child(name_lbl)
|
||||
|
||||
var sub_lbl := Label.new()
|
||||
sub_lbl.text = "%s · %s" % [str(dto.get("cardType", "")), str(dto.get("affinity", ""))]
|
||||
sub_lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.62))
|
||||
sub_lbl.add_theme_font_size_override("font_size", 10)
|
||||
info.add_child(sub_lbl)
|
||||
|
||||
var deck_lbl := Label.new()
|
||||
deck_lbl.text = "In deck: %d" % in_deck
|
||||
deck_lbl.add_theme_font_size_override("font_size", 11)
|
||||
deck_lbl.custom_minimum_size = Vector2(72, 0)
|
||||
deck_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
outer.set_meta("deck_lbl", deck_lbl)
|
||||
row.add_child(deck_lbl)
|
||||
|
||||
var add_btn := Button.new()
|
||||
add_btn.text = "+"
|
||||
add_btn.custom_minimum_size = Vector2(28, 30)
|
||||
add_btn.pressed.connect(func(): _add_card(def_id))
|
||||
row.add_child(add_btn)
|
||||
|
||||
return outer
|
||||
|
||||
|
||||
func _refresh_coll_in_deck_labels() -> void:
|
||||
for child in _coll_list.get_children():
|
||||
if not child.has_meta("def_id"):
|
||||
continue
|
||||
var def_id := str(child.get_meta("def_id"))
|
||||
var in_deck := int(_deck_qty.get(def_id, 0))
|
||||
if child.has_meta("deck_lbl"):
|
||||
(child.get_meta("deck_lbl") as Label).text = "In deck: %d" % in_deck
|
||||
|
||||
|
||||
func _on_load_more() -> void:
|
||||
_fetch_coll_page(_coll_page + 1)
|
||||
|
||||
|
||||
func _on_search_changed(_t: String) -> void:
|
||||
_search_timer = _DEBOUNCE
|
||||
|
||||
# ── Mutate: add / remove ──────────────────────────────────────────────────────
|
||||
|
||||
func _add_card(def_id: String) -> void:
|
||||
Network.request(
|
||||
"collection.add_card",
|
||||
{ "deckId": _deck_id, "cardDefinitionId": def_id, "quantity": 1 },
|
||||
func(_t: String, _p: Variant): _load_deck_contents(),
|
||||
func(_code: String, msg: String): push_warning("DeckEditor add_card: %s" % msg)
|
||||
)
|
||||
|
||||
|
||||
func _remove_card(def_id: String, qty: Variant) -> void:
|
||||
var payload : Dictionary = { "deckId": _deck_id, "cardDefinitionId": def_id }
|
||||
if qty != null:
|
||||
payload["quantity"] = int(qty)
|
||||
Network.request(
|
||||
"collection.remove_card",
|
||||
payload,
|
||||
func(_t: String, _p: Variant): _load_deck_contents(),
|
||||
func(_code: String, msg: String): push_warning("DeckEditor remove_card: %s" % msg)
|
||||
)
|
||||
@@ -7,12 +7,14 @@ extends PanelContainer
|
||||
signal rename_requested(deck_id: String, new_name: String)
|
||||
signal delete_requested(deck_id: String, deck_name: String)
|
||||
signal clone_requested(deck_id: String)
|
||||
signal edit_requested(deck_id: String, deck_name: String)
|
||||
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var name_edit : LineEdit = %NameEdit
|
||||
@onready var arch_spirit_label : Label = %ArchSpiritLabel
|
||||
@onready var count_label : Label = %CountLabel
|
||||
@onready var valid_label : Label = %ValidLabel
|
||||
@onready var edit_btn : Button = %EditBtn
|
||||
@onready var rename_btn : Button = %RenameBtn
|
||||
@onready var clone_btn : Button = %CloneBtn
|
||||
@onready var delete_btn : Button = %DeleteBtn
|
||||
@@ -21,13 +23,17 @@ signal clone_requested(deck_id: String)
|
||||
|
||||
var _deck_id : String = ""
|
||||
var _deck_name : String = ""
|
||||
var _is_ready : bool = false
|
||||
var _pending_deck : Dictionary = {}
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_is_ready = true
|
||||
_apply_row_style()
|
||||
_exit_rename_mode()
|
||||
|
||||
edit_btn.pressed.connect(func(): edit_requested.emit(_deck_id, _deck_name))
|
||||
rename_btn.pressed.connect(_start_rename)
|
||||
clone_btn.pressed.connect(func(): clone_requested.emit(_deck_id))
|
||||
delete_btn.pressed.connect(func(): delete_requested.emit(_deck_id, _deck_name))
|
||||
@@ -35,9 +41,21 @@ func _ready() -> void:
|
||||
cancel_rename.pressed.connect(_cancel_rename)
|
||||
name_edit.text_submitted.connect(func(_t): _finish_rename())
|
||||
|
||||
if not _pending_deck.is_empty():
|
||||
_apply_setup(_pending_deck)
|
||||
_pending_deck.clear()
|
||||
|
||||
# ── Public ────────────────────────────────────────────────────────────────────
|
||||
|
||||
func setup(deck: Dictionary) -> void:
|
||||
if not _is_ready:
|
||||
_pending_deck = deck.duplicate(true)
|
||||
return
|
||||
|
||||
_apply_setup(deck)
|
||||
|
||||
|
||||
func _apply_setup(deck: Dictionary) -> void:
|
||||
_deck_id = str(deck.get("id", ""))
|
||||
_deck_name = str(deck.get("name", "Unnamed Deck"))
|
||||
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://ca8qmqtdwyt1s"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/views/cars_view.gd" id="1_cv"]
|
||||
[ext_resource type="Script" uid="uid://d26atv3dne7jl" path="res://scenes/collection/views/cards_view.gd" id="1_cv"]
|
||||
|
||||
[node name="CardsView" type="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
script = ExtResource("1_cv")
|
||||
|
||||
[node name="FilterBar" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="SearchInput" type="LineEdit" parent="FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
placeholder_text = "Search cards…"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
placeholder_text = "Search cards…"
|
||||
|
||||
[node name="FilterRow" type="HBoxContainer" parent="FilterBar"]
|
||||
layout_mode = 2
|
||||
@@ -49,42 +44,42 @@ theme_override_constants/separation = 0
|
||||
[node name="CardGridMargin" type="MarginContainer" parent="Scroll/ScrollInner"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="CardGrid" type="GridContainer" parent="Scroll/ScrollInner/CardGridMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
columns = 2
|
||||
theme_override_constants/h_separation = 8
|
||||
theme_override_constants/v_separation = 8
|
||||
columns = 2
|
||||
|
||||
[node name="StatusRow" type="HBoxContainer" parent="Scroll/ScrollInner"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LoadingLabel" type="Label" parent="Scroll/ScrollInner/StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.75, 0.75, 0.8, 1)
|
||||
layout_mode = 2
|
||||
text = "Loading…"
|
||||
modulate = Color(0.75, 0.75, 0.8, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Loading…"
|
||||
|
||||
[node name="EmptyLabel" type="Label" parent="Scroll/ScrollInner/StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "No cards found."
|
||||
visible = false
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
modulate = Color(0.6, 0.6, 0.65, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "No cards found."
|
||||
|
||||
[node name="LoadMoreBtn" type="Button" parent="Scroll/ScrollInner/StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(120, 36)
|
||||
text = "Load More"
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(120, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Load More"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/views/decks_view.gd" id="1_dv"]
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/deck_editor_panel.gd" id="2_dep"]
|
||||
|
||||
[node name="DecksView" type="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
@@ -142,6 +143,13 @@ visible = false
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="DeckEditorPanel" type="VBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
visible = false
|
||||
script = ExtResource("2_dep")
|
||||
|
||||
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
title = "Confirm Delete"
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
extends VBoxContainer
|
||||
## Cards tab — paginated, filterable grid of the player's owned cards.
|
||||
##
|
||||
## Fetches from collection.get_cards (page, pageSize, nameFilter?,
|
||||
## cardTypeFilter?, affinityFilter?). Displays results as CardWidget
|
||||
## instances in a responsive GridContainer.
|
||||
##
|
||||
## Typing in the search box starts a 0.4 s debounce before reloading.
|
||||
## "Load More" appends the next page without clearing the existing cards.
|
||||
|
||||
const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
const PAGE_SIZE := 20
|
||||
|
||||
# ── Node references ───────────────────────────────────────────────────────────
|
||||
|
||||
@onready var search_input : LineEdit = %SearchInput
|
||||
@onready var type_option : OptionButton = %TypeOption
|
||||
@onready var affinity_option : OptionButton = %AffinityOption
|
||||
@onready var card_grid : GridContainer = %CardGrid
|
||||
@onready var loading_label : Label = %LoadingLabel
|
||||
@onready var empty_label : Label = %EmptyLabel
|
||||
@onready var load_more_btn : Button = %LoadMoreBtn
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _current_page : int = 1
|
||||
var _total_count : int = 0
|
||||
var _has_more : bool = false
|
||||
var _loading : bool = false
|
||||
var _search_timer : float = 0.0
|
||||
const _SEARCH_DEBOUNCE := 0.4
|
||||
|
||||
# Emitted when the user taps a card — parent uses this to show the detail popup.
|
||||
signal card_selected(dto: Dictionary, def: Dictionary)
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_populate_type_options()
|
||||
_populate_affinity_options()
|
||||
_update_columns()
|
||||
search_input.text_changed.connect(_on_search_changed)
|
||||
type_option.item_selected.connect(func(_i): _reload())
|
||||
affinity_option.item_selected.connect(func(_i): _reload())
|
||||
load_more_btn.pressed.connect(_on_load_more)
|
||||
get_viewport().size_changed.connect(_update_columns)
|
||||
_reload()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if get_viewport() and get_viewport().size_changed.is_connected(_update_columns):
|
||||
get_viewport().size_changed.disconnect(_update_columns)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _search_timer > 0.0:
|
||||
_search_timer -= delta
|
||||
if _search_timer <= 0.0:
|
||||
_search_timer = 0.0
|
||||
_reload()
|
||||
|
||||
# ── Option population ─────────────────────────────────────────────────────────
|
||||
|
||||
func _populate_type_options() -> void:
|
||||
type_option.clear()
|
||||
type_option.add_item("All Types")
|
||||
for t in ["Creature", "Spell", "Item", "ArchSpirit"]:
|
||||
type_option.add_item(t)
|
||||
|
||||
|
||||
func _populate_affinity_options() -> void:
|
||||
affinity_option.clear()
|
||||
affinity_option.add_item("All Affinities")
|
||||
for a in [
|
||||
# Basic
|
||||
"Void", "Aether", "Lake", "Hill", "Forest", "Field",
|
||||
# Non-basic
|
||||
"Ocean", "Island", "Marsh", "Swamp",
|
||||
"Mountain", "Steppe", "Fort",
|
||||
"Plains", "Grove", "Jungle",
|
||||
"PerfectAether", "PureVoid",
|
||||
]:
|
||||
affinity_option.add_item(a)
|
||||
|
||||
# ── Responsive columns ────────────────────────────────────────────────────────
|
||||
|
||||
func _update_columns() -> void:
|
||||
var vp_w := get_viewport_rect().size.x
|
||||
card_grid.columns = max(2, int(vp_w / 160))
|
||||
|
||||
# ── Data fetching ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _reload() -> void:
|
||||
_current_page = 1
|
||||
_total_count = 0
|
||||
_has_more = false
|
||||
for child in card_grid.get_children():
|
||||
child.queue_free()
|
||||
_fetch_page(1)
|
||||
|
||||
|
||||
func _fetch_page(page: int) -> void:
|
||||
if _loading:
|
||||
return
|
||||
_loading = true
|
||||
_set_status("loading")
|
||||
|
||||
var payload := {
|
||||
"page": page,
|
||||
"pageSize": PAGE_SIZE,
|
||||
}
|
||||
var search := search_input.text.strip_edges()
|
||||
if not search.is_empty():
|
||||
payload["nameFilter"] = search
|
||||
|
||||
# Type filter — index 0 = "All Types" (skip)
|
||||
var type_idx := type_option.selected
|
||||
if type_idx > 0:
|
||||
payload["cardTypeFilter"] = type_option.get_item_text(type_idx)
|
||||
|
||||
# Affinity filter — index 0 = "All Affinities" (skip)
|
||||
var aff_idx := affinity_option.selected
|
||||
if aff_idx > 0:
|
||||
payload["affinityFilter"] = affinity_option.get_item_text(aff_idx)
|
||||
|
||||
Network.request(
|
||||
"collection.get_cards",
|
||||
payload,
|
||||
func(_t: String, p: Variant): _on_cards_response(p, page),
|
||||
func(_code: String, msg: String): _on_error(msg)
|
||||
)
|
||||
|
||||
|
||||
func _on_cards_response(payload: Variant, page: int) -> void:
|
||||
_loading = false
|
||||
var p := payload as Dictionary
|
||||
var cards : Array = p.get("cards", [])
|
||||
_total_count = int(p.get("totalCount", 0))
|
||||
var page_size : int = int(p.get("pageSize", PAGE_SIZE))
|
||||
_current_page = page
|
||||
_has_more = (page * page_size) < _total_count
|
||||
|
||||
for dto in cards:
|
||||
var def := ContentCache.get_definition(str(dto.get("cardDefinitionId", "")))
|
||||
var widget = CARD_WIDGET.instantiate() as PanelContainer
|
||||
widget.setup(dto, def)
|
||||
widget.card_pressed.connect(func(_def_id: String):
|
||||
card_selected.emit(dto, def))
|
||||
card_grid.add_child(widget)
|
||||
|
||||
if cards.is_empty() and page == 1:
|
||||
_set_status("empty")
|
||||
else:
|
||||
_set_status("done")
|
||||
|
||||
load_more_btn.visible = _has_more
|
||||
|
||||
|
||||
func _on_error(msg: String) -> void:
|
||||
_loading = false
|
||||
_set_status("empty")
|
||||
push_warning("CardsView: %s" % msg)
|
||||
|
||||
# ── Button handlers ───────────────────────────────────────────────────────────
|
||||
|
||||
func _on_search_changed(_text: String) -> void:
|
||||
_search_timer = _SEARCH_DEBOUNCE
|
||||
|
||||
|
||||
func _on_load_more() -> void:
|
||||
_fetch_page(_current_page + 1)
|
||||
|
||||
# ── Status helper ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _set_status(state: String) -> void:
|
||||
loading_label.visible = (state == "loading")
|
||||
empty_label.visible = (state == "empty")
|
||||
if state != "loading":
|
||||
load_more_btn.visible = _has_more
|
||||
@@ -26,6 +26,10 @@ const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.t
|
||||
@onready var loading_label : Label = %LoadingLabel
|
||||
@onready var empty_label : Label = %EmptyLabel
|
||||
@onready var confirm_dialog : ConfirmationDialog = %ConfirmDialog
|
||||
@onready var deck_editor : VBoxContainer = %DeckEditorPanel
|
||||
@onready var _header_margin : MarginContainer = $HeaderMargin
|
||||
@onready var _scroll : ScrollContainer = $Scroll
|
||||
@onready var _status_row : HBoxContainer = $StatusRow
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -41,6 +45,7 @@ func _ready() -> void:
|
||||
create_btn.pressed.connect(_on_create_deck)
|
||||
deck_name_input.text_changed.connect(_on_name_changed)
|
||||
confirm_dialog.confirmed.connect(_on_delete_confirmed)
|
||||
deck_editor.back_pressed.connect(_on_editor_back)
|
||||
create_btn.disabled = true
|
||||
_load_decks()
|
||||
|
||||
@@ -66,6 +71,7 @@ func _on_decks_response(payload: Variant) -> void:
|
||||
for deck in decks:
|
||||
var item = DECK_LIST_ITEM.instantiate()
|
||||
item.setup(deck)
|
||||
item.edit_requested.connect(_on_edit_requested)
|
||||
item.rename_requested.connect(_on_rename_requested)
|
||||
item.delete_requested.connect(_on_delete_requested)
|
||||
item.clone_requested.connect(_on_clone_requested)
|
||||
@@ -104,7 +110,7 @@ func _load_arch_spirits() -> void:
|
||||
_clear_arch_spirit_grid()
|
||||
Network.request(
|
||||
"collection.get_cards",
|
||||
{ "page": 1, "pageSize": 50, "cardTypeFilter": "ArchSpirit" },
|
||||
{ "page": 1, "pageSize": 50, "cardTypeFilter": "ArchSpirit", "tierFilter": 1 },
|
||||
func(_t: String, p: Variant): _on_arch_spirits(p),
|
||||
func(_code: String, msg: String): push_warning("DecksView arch spirits: %s" % msg)
|
||||
)
|
||||
@@ -204,6 +210,24 @@ func _on_mutate_error(msg: String) -> void:
|
||||
push_warning("DecksView mutate: %s" % msg)
|
||||
_load_decks()
|
||||
|
||||
# ── Deck editor ───────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_edit_requested(deck_id: String, deck_name: String) -> void:
|
||||
_header_margin.visible = false
|
||||
new_deck_form.visible = false
|
||||
_scroll.visible = false
|
||||
_status_row.visible = false
|
||||
deck_editor.visible = true
|
||||
deck_editor.open_deck(deck_id, deck_name)
|
||||
|
||||
|
||||
func _on_editor_back() -> void:
|
||||
deck_editor.visible = false
|
||||
_header_margin.visible = true
|
||||
_scroll.visible = true
|
||||
_status_row.visible = true
|
||||
_load_decks()
|
||||
|
||||
# ── Status helper ─────────────────────────────────────────────────────────────
|
||||
|
||||
## Pass a bool (is_empty) + the desired state string, or just a string "loading".
|
||||
|
||||
@@ -27,7 +27,7 @@ else
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>ArchSpirit</th>
|
||||
<th>Cards</th>
|
||||
<th>Unique Cards</th>
|
||||
<th>Origin Points</th>
|
||||
<th>USD</th>
|
||||
<th>Available</th>
|
||||
|
||||
@@ -6,13 +6,17 @@ namespace SOR.Collection;
|
||||
/// Paginated list of all cards the authenticated player owns.
|
||||
/// NameFilter: case-insensitive substring match on card name (optional).
|
||||
/// CardTypeFilter / AffinityFilter: exact enum name match (optional).
|
||||
/// TierFilter: when set, only returns cards whose Tier equals this value
|
||||
/// (null Tier is treated as 1). Useful combined with CardTypeFilter="ArchSpirit"
|
||||
/// to show only Tier-1 commanders or only Tier-2+ ascension targets.
|
||||
/// </summary>
|
||||
public sealed record GetCardsRequest(
|
||||
int Page = 1,
|
||||
int PageSize = 50,
|
||||
string? NameFilter = null,
|
||||
string? CardTypeFilter = null,
|
||||
string? AffinityFilter = null);
|
||||
string? AffinityFilter = null,
|
||||
int? TierFilter = null);
|
||||
|
||||
/// <summary>Returns all decks for the authenticated player (summaries only).</summary>
|
||||
public sealed record GetDecksRequest; // no fields — identity from connection
|
||||
@@ -81,7 +85,8 @@ public sealed record PlayerCardDto(
|
||||
int? SerialNumber,
|
||||
DateTimeOffset AcquiredAt,
|
||||
string? ArtUrl,
|
||||
bool IsTradeable = true);
|
||||
bool IsTradeable = true,
|
||||
int? Tier = null);
|
||||
|
||||
public sealed record GetDecksResponse(IEnumerable<DeckSummaryDto> Decks);
|
||||
|
||||
|
||||
@@ -47,10 +47,11 @@ internal sealed class CollectionGetCardsHandler : CollectionHandlerBase, IMessag
|
||||
var query = _collectionDb.PlayerCards
|
||||
.Where(pc => pc.AccountId == accountId);
|
||||
|
||||
// Cross-context name/type filter: first resolve matching definition IDs from catalog.
|
||||
// Cross-context name/type/tier filter: first resolve matching definition IDs from catalog.
|
||||
if (!string.IsNullOrWhiteSpace(req.NameFilter)
|
||||
|| !string.IsNullOrWhiteSpace(req.CardTypeFilter)
|
||||
|| !string.IsNullOrWhiteSpace(req.AffinityFilter))
|
||||
|| !string.IsNullOrWhiteSpace(req.AffinityFilter)
|
||||
|| req.TierFilter.HasValue)
|
||||
{
|
||||
var defQuery = _catalogDb.CardDefinitions.AsQueryable();
|
||||
if (!string.IsNullOrWhiteSpace(req.NameFilter))
|
||||
@@ -61,6 +62,11 @@ internal sealed class CollectionGetCardsHandler : CollectionHandlerBase, IMessag
|
||||
if (!string.IsNullOrWhiteSpace(req.AffinityFilter)
|
||||
&& Enum.TryParse<Affinity>(req.AffinityFilter, true, out var af))
|
||||
defQuery = defQuery.Where(cd => cd.Affinity == af);
|
||||
if (req.TierFilter.HasValue)
|
||||
// Null Tier in the DB is treated as Tier 1.
|
||||
defQuery = defQuery.Where(cd =>
|
||||
cd.Tier == req.TierFilter.Value
|
||||
|| (req.TierFilter.Value == 1 && cd.Tier == null));
|
||||
|
||||
var matchingIds = await defQuery.Select(cd => cd.Id).ToListAsync(cancellationToken);
|
||||
query = query.Where(pc => matchingIds.Contains(pc.CardDefinitionId));
|
||||
@@ -94,7 +100,8 @@ internal sealed class CollectionGetCardsHandler : CollectionHandlerBase, IMessag
|
||||
SerialNumber: pc.SerialNumber,
|
||||
AcquiredAt: pc.AcquiredAt,
|
||||
ArtUrl: GetArtUrl(def),
|
||||
IsTradeable: pc.IsTradeable);
|
||||
IsTradeable: pc.IsTradeable,
|
||||
Tier: def?.Tier ?? 1);
|
||||
});
|
||||
|
||||
return ServerMessage.Reply(
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
-- Import legacy card rows into catalog.card_definitions.
|
||||
--
|
||||
-- Usage:
|
||||
-- 1. Load your old rows into temp_legacy_cards (COPY, INSERT, psql \copy, etc.).
|
||||
-- 2. Run the INSERT ... SELECT below.
|
||||
--
|
||||
-- Notes:
|
||||
-- - This script targets the current Postgres schema used by SOR.Database.
|
||||
-- - It intentionally does NOT preserve the old CardId as the new primary key.
|
||||
-- - ArchSpirit tier chains are preserved by mapping legacy ParentCardId -> new UUID.
|
||||
-- - Repentance payloads cannot be losslessly converted yet because the old
|
||||
-- Repentances[] ids do not map directly to the new Action/Effect DSL in this repo.
|
||||
-- For those rows, a placeholder JSON payload is written to "effects" so the legacy
|
||||
-- ids are preserved for manual follow-up.
|
||||
-- - Card assets (CardArt / CardModelName) are not imported here; this only populates
|
||||
-- catalog.card_definitions.
|
||||
--
|
||||
-- Legacy enum assumptions used here:
|
||||
-- Type:
|
||||
-- 1 = Spirit
|
||||
-- 3 = Repentance
|
||||
-- 5 = Terramorpha
|
||||
-- 6 = ArchSpirit
|
||||
-- Affinity:
|
||||
-- 1 = Void
|
||||
-- 2 = Lake
|
||||
-- 3 = Hill
|
||||
-- 4 = Field
|
||||
-- 5 = Forest
|
||||
-- 6 = Aether
|
||||
-- 7 = Ocean
|
||||
-- 8 = Island
|
||||
-- 9 = Marsh
|
||||
-- 10 = Swamp
|
||||
-- 11 = Mountain
|
||||
-- 12 = Steppe
|
||||
-- 13 = Fort
|
||||
-- 14 = Plains
|
||||
-- 15 = Grove
|
||||
-- 16 = Jungle
|
||||
--
|
||||
-- If your old DB used a different numeric enum layout, update the two CASE maps below
|
||||
-- before running this script.
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
|
||||
DROP TABLE IF EXISTS temp_legacy_cards;
|
||||
CREATE TEMP TABLE temp_legacy_cards
|
||||
(
|
||||
legacy_card_id integer PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
description text NOT NULL,
|
||||
legacy_type integer NOT NULL,
|
||||
sp_cost integer NOT NULL,
|
||||
st_cost integer NOT NULL,
|
||||
legacy_affinity integer NOT NULL,
|
||||
card_data jsonb NOT NULL
|
||||
);
|
||||
|
||||
-- Paste the raw legacy SQL tuple blob below (the exact format you pasted in chat),
|
||||
-- replacing the placeholder line. Example row format:
|
||||
-- '146', 'Barrier of Unseen', 'A Barrier of nothing', '1', '4', '1', '1', '{\"CardGenus\": [\"Barrier\"]}'
|
||||
WITH raw_blob AS
|
||||
(
|
||||
SELECT $blob$
|
||||
PASTE_LEGACY_ROWS_HERE
|
||||
$blob$ AS blob
|
||||
),
|
||||
parsed_rows AS
|
||||
(
|
||||
SELECT
|
||||
(m)[1]::integer AS legacy_card_id,
|
||||
regexp_replace((m)[2], E'\\\\''', '''', 'g') AS name,
|
||||
regexp_replace((m)[3], E'\\\\''', '''', 'g') AS description,
|
||||
(m)[4]::integer AS legacy_type,
|
||||
(m)[5]::integer AS sp_cost,
|
||||
(m)[6]::integer AS st_cost,
|
||||
(m)[7]::integer AS legacy_affinity,
|
||||
replace(
|
||||
regexp_replace((m)[8], E'\\\\''', '''', 'g'),
|
||||
E'\\\"',
|
||||
'"'
|
||||
)::jsonb AS card_data
|
||||
FROM raw_blob rb
|
||||
CROSS JOIN LATERAL regexp_matches(
|
||||
rb.blob,
|
||||
'''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''\s*,\s*''((?:[^''\\]|\\.)*)''',
|
||||
'g'
|
||||
) AS m
|
||||
)
|
||||
INSERT INTO temp_legacy_cards
|
||||
(legacy_card_id, name, description, legacy_type, sp_cost, st_cost, legacy_affinity, card_data)
|
||||
SELECT
|
||||
legacy_card_id,
|
||||
name,
|
||||
description,
|
||||
legacy_type,
|
||||
sp_cost,
|
||||
st_cost,
|
||||
legacy_affinity,
|
||||
card_data
|
||||
FROM parsed_rows;
|
||||
|
||||
WITH source_rows AS
|
||||
(
|
||||
SELECT
|
||||
l.*,
|
||||
gen_random_uuid() AS new_id,
|
||||
CASE l.legacy_type
|
||||
WHEN 1 THEN 'Spirit'
|
||||
WHEN 3 THEN 'Repentance'
|
||||
WHEN 5 THEN 'Terramorpha'
|
||||
WHEN 6 THEN 'ArchSpirit'
|
||||
ELSE NULL
|
||||
END AS mapped_card_type,
|
||||
CASE l.legacy_affinity
|
||||
WHEN 1 THEN 'Void'
|
||||
WHEN 2 THEN 'Lake'
|
||||
WHEN 3 THEN 'Hill'
|
||||
WHEN 4 THEN 'Field'
|
||||
WHEN 5 THEN 'Forest'
|
||||
WHEN 6 THEN 'Aether'
|
||||
WHEN 7 THEN 'Ocean'
|
||||
WHEN 8 THEN 'Island'
|
||||
WHEN 9 THEN 'Marsh'
|
||||
WHEN 10 THEN 'Swamp'
|
||||
WHEN 11 THEN 'Mountain'
|
||||
WHEN 12 THEN 'Steppe'
|
||||
WHEN 13 THEN 'Fort'
|
||||
WHEN 14 THEN 'Plains'
|
||||
WHEN 15 THEN 'Grove'
|
||||
WHEN 16 THEN 'Jungle'
|
||||
ELSE NULL
|
||||
END AS mapped_affinity,
|
||||
CASE (l.card_data ->> 'AttackType')
|
||||
WHEN '0' THEN 'Melee'
|
||||
WHEN '1' THEN 'Ranged'
|
||||
ELSE NULL
|
||||
END AS mapped_attack_type,
|
||||
CASE (l.card_data ->> 'TerraType')
|
||||
WHEN '1' THEN 'Mono'
|
||||
WHEN '2' THEN 'Di'
|
||||
WHEN '3' THEN 'Tri'
|
||||
ELSE NULL
|
||||
END AS mapped_terramorpha_mode,
|
||||
NULLIF(l.card_data ->> 'ParentCardId', '')::integer AS legacy_parent_card_id
|
||||
FROM temp_legacy_cards l
|
||||
),
|
||||
validated AS
|
||||
(
|
||||
SELECT *
|
||||
FROM source_rows
|
||||
WHERE mapped_card_type IS NOT NULL
|
||||
AND mapped_affinity IS NOT NULL
|
||||
),
|
||||
inserted AS
|
||||
(
|
||||
INSERT INTO catalog.card_definitions
|
||||
(
|
||||
"Id",
|
||||
"Name",
|
||||
"Description",
|
||||
"CardType",
|
||||
"Affinity",
|
||||
"SpCost",
|
||||
"StCost",
|
||||
"OtherCosts",
|
||||
"MinChannelRange",
|
||||
"MaxChannelRange",
|
||||
"AttackType",
|
||||
"RequiresLos",
|
||||
"MinAttackRange",
|
||||
"MaxAttackRange",
|
||||
"CanAttack",
|
||||
"Damage",
|
||||
"CanDefend",
|
||||
"MaxHealth",
|
||||
"MaxDefense",
|
||||
"CanBeAttacked",
|
||||
"CanBeBlocked",
|
||||
"CanMove",
|
||||
"MovementType",
|
||||
"MovementPoints",
|
||||
"CanBeObstructed",
|
||||
"CanUseAbility",
|
||||
"Genus",
|
||||
"CanBeSacrificed",
|
||||
"Tier",
|
||||
"PreviousTierId",
|
||||
"TerramorphaMode",
|
||||
"Abilities",
|
||||
"Effects",
|
||||
"Rarity",
|
||||
"SetId",
|
||||
"CollectorNumber",
|
||||
"IsPublished",
|
||||
"IsRetired",
|
||||
"RetiredAt",
|
||||
"CreatedAt",
|
||||
"UpdatedAt"
|
||||
)
|
||||
SELECT
|
||||
s.new_id,
|
||||
s.name,
|
||||
COALESCE(s.description, ''),
|
||||
s.mapped_card_type,
|
||||
s.mapped_affinity,
|
||||
s.sp_cost,
|
||||
s.st_cost,
|
||||
NULL,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardChannelMinRange', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardChannelMaxRange', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
AND s.card_data ? 'AttackType'
|
||||
THEN s.mapped_attack_type
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
AND s.card_data ? 'AttackType'
|
||||
THEN false
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardAttackMinRange', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardAttackMaxRange', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN COALESCE((s.card_data ->> 'CanAttack')::boolean, false)
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardAttack', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
AND s.card_data ? 'CardDefense'
|
||||
THEN true
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardHealthPoints', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardDefense', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN true
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN true
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN COALESCE((s.card_data ->> 'CanMove')::boolean, false)
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
AND COALESCE((s.card_data ->> 'CanMove')::boolean, false)
|
||||
THEN 'Walk'
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN NULLIF(s.card_data ->> 'CardMovementPoints', '')::integer
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN true
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type IN ('Spirit', 'ArchSpirit')
|
||||
THEN COALESCE(
|
||||
NULLIF(s.card_data ->> 'CardCanUseAbilities', '')::boolean,
|
||||
jsonb_typeof(s.card_data -> 'Abilities') = 'array'
|
||||
AND jsonb_array_length(s.card_data -> 'Abilities') > 0,
|
||||
false)
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.card_data ? 'CardGenus'
|
||||
THEN ARRAY(SELECT jsonb_array_elements_text(s.card_data -> 'CardGenus'))
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type = 'Spirit' THEN true
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type = 'ArchSpirit'
|
||||
THEN COALESCE(NULLIF(s.card_data ->> 'CardTier', '')::integer, 1)
|
||||
ELSE NULL
|
||||
END,
|
||||
parent.new_id,
|
||||
CASE
|
||||
WHEN s.mapped_card_type = 'Terramorpha'
|
||||
THEN s.mapped_terramorpha_mode
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.card_data ? 'Abilities'
|
||||
AND jsonb_typeof(s.card_data -> 'Abilities') = 'array'
|
||||
THEN s.card_data -> 'Abilities'
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN s.mapped_card_type = 'Repentance'
|
||||
AND s.card_data ? 'Repentances'
|
||||
THEN jsonb_build_array(
|
||||
jsonb_build_object(
|
||||
'LegacyRepentanceIds', s.card_data -> 'Repentances',
|
||||
'MigrationNote', 'Manual conversion to new Action/Effect DSL required'))
|
||||
ELSE NULL
|
||||
END,
|
||||
'Common',
|
||||
NULL,
|
||||
NULL,
|
||||
true,
|
||||
false,
|
||||
NULL,
|
||||
now(),
|
||||
now()
|
||||
FROM validated s
|
||||
LEFT JOIN validated parent
|
||||
ON parent.legacy_card_id = s.legacy_parent_card_id
|
||||
RETURNING "Id", "Name"
|
||||
)
|
||||
SELECT count(*) AS inserted_count
|
||||
FROM inserted;
|
||||
Reference in New Issue
Block a user