Add starter deck flow, admin force-logout + rename, shop flag
Auth chain: - auth.proto: add needs_starter_deck to Login/Register/ValidateToken responses - auth.proto: add RevokeAllSessions RPC - AuthGrpcHandler: populate NeedsStarterDeck from Account.StarterDeckSelectedAt - AuthGrpcHandler: track tokens in UserSessions Redis SET on create/logout - AuthGrpcHandler: implement RevokeAllSessions (Redis + Postgres) - IGatewayAuthValidator / GatewayAuthValidator: thread NeedsStarterDeck through tuples - ConnectionLoop: include needsStarterDeck in auth ack payload Client: - Auth.gd: store needs_starter_deck from auth reply; clear on logout - login_screen.gd: route to StarterDeckScreen when needs_starter_deck = true - scenes/starter_deck/: new StarterDeckScreen (fetch decks → pick → confirm → InitScreen) Admin panel: - AccountDetail.razor: Force Logout All Sessions card (Redis + Postgres revoke) - AccountDetail.razor: Change Display Name form with uniqueness check - SOR.Admin: add StackExchange.Redis package + DI registration - PrebuiltDeckEditor.razor: split into IsStarterDeck + IsAvailableInShop checkboxes - PrebuiltDeck.cs: add IsAvailableInShop field - Migration: AddPrebuiltDeckShopFlag 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>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/starter_deck/starter_deck_screen.gd" id="1_sds"]
|
||||
|
||||
[node name="StarterDeckScreen" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_sds")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.094, 0.094, 0.137, 1.0)
|
||||
|
||||
[node name="OuterMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_right = 40
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="Layout" type="VBoxContainer" parent="OuterMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="OuterMargin/Layout"]
|
||||
layout_mode = 2
|
||||
text = "Choose Your Starter Deck"
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 28
|
||||
|
||||
[node name="SubLabel" type="Label" parent="OuterMargin/Layout"]
|
||||
layout_mode = 2
|
||||
text = "Select a deck to begin your journey. This choice is permanent."
|
||||
horizontal_alignment = 1
|
||||
modulate = Color(0.7, 0.7, 0.8, 1.0)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="OuterMargin/Layout"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="OuterMargin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Loading…"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 3
|
||||
modulate = Color(0.75, 0.75, 0.8, 1.0)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="OuterMargin/Layout"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DeckList" type="VBoxContainer" parent="OuterMargin/Layout/Scroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="ConfirmBtn" type="Button" parent="OuterMargin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 48)
|
||||
text = "Choose This Deck"
|
||||
disabled = true
|
||||
theme_override_font_sizes/font_size = 16
|
||||
@@ -0,0 +1,168 @@
|
||||
extends Control
|
||||
## Starter deck selection screen — shown to new players immediately after auth.
|
||||
##
|
||||
## Flow:
|
||||
## 1. Send collection.get_starter_decks → populate deck list.
|
||||
## 2. Player taps a deck item to select it (highlighted border).
|
||||
## 3. "Choose This Deck" button becomes enabled; player confirms.
|
||||
## 4. Send collection.select_starter_deck { starterDeckId }.
|
||||
## 5. On success: set Auth.needs_starter_deck = false → navigate to InitScreen.
|
||||
|
||||
@onready var status_label : Label = %StatusLabel
|
||||
@onready var deck_list : VBoxContainer = %DeckList
|
||||
@onready var confirm_btn : Button = %ConfirmBtn
|
||||
|
||||
const SEL_COLOR := Color(0.36, 0.56, 1.0, 1.0)
|
||||
const DEF_COLOR := Color(0.25, 0.25, 0.35, 1.0)
|
||||
|
||||
var _selected_id: String = ""
|
||||
var _confirming: bool = false
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
confirm_btn.disabled = true
|
||||
confirm_btn.pressed.connect(_on_confirm_pressed)
|
||||
_fetch_decks()
|
||||
|
||||
# ── Deck fetch ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _fetch_decks() -> void:
|
||||
status_label.text = "Loading starter decks…"
|
||||
status_label.visible = true
|
||||
deck_list.visible = false
|
||||
|
||||
Network.request(
|
||||
"collection.get_starter_decks",
|
||||
{},
|
||||
func(_type: String, p: Variant): _on_decks_ok(p),
|
||||
func(code: String, _msg: String): _on_decks_error(code)
|
||||
)
|
||||
|
||||
|
||||
func _on_decks_ok(payload: Variant) -> void:
|
||||
var p := payload as Dictionary
|
||||
var decks := p.get("decks", []) as Array
|
||||
|
||||
if decks.is_empty():
|
||||
status_label.text = "No starter decks are available right now. Please contact support."
|
||||
return
|
||||
|
||||
status_label.visible = false
|
||||
deck_list.visible = true
|
||||
_populate_list(decks)
|
||||
|
||||
|
||||
func _on_decks_error(code: String) -> void:
|
||||
status_label.text = "Failed to load starter decks (%s). Check your connection." % code
|
||||
|
||||
# ── Deck list ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _populate_list(decks: Array) -> void:
|
||||
for child in deck_list.get_children():
|
||||
child.queue_free()
|
||||
|
||||
for deck in decks:
|
||||
var d := deck as Dictionary
|
||||
var id := d.get("id", "") as String
|
||||
deck_list.add_child(_build_card(d, id))
|
||||
|
||||
|
||||
func _build_card(d: Dictionary, id: String) -> Button:
|
||||
var btn := Button.new()
|
||||
btn.name = "Deck_%s" % id
|
||||
btn.flat = false
|
||||
btn.focus_mode = Control.FOCUS_CLICK
|
||||
btn.size_flags_horizontal = Control.SIZE_FILL
|
||||
_apply_card_style(btn, false)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.add_theme_constant_override("separation", 5)
|
||||
btn.add_child(inner)
|
||||
|
||||
# Deck name
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = d.get("name", "Unknown Deck")
|
||||
name_lbl.add_theme_font_size_override("font_size", 16)
|
||||
inner.add_child(name_lbl)
|
||||
|
||||
# ArchSpirit · card count
|
||||
var arch : String = d.get("archSpiritName", "")
|
||||
var total : int = d.get("totalCards", 0)
|
||||
var sub_lbl := Label.new()
|
||||
sub_lbl.text = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||
else ("%d cards" % total)
|
||||
sub_lbl.modulate = Color(0.7, 0.7, 0.8)
|
||||
sub_lbl.add_theme_font_size_override("font_size", 12)
|
||||
inner.add_child(sub_lbl)
|
||||
|
||||
# Optional description
|
||||
var desc : String = d.get("description", "")
|
||||
if not desc.is_empty():
|
||||
var desc_lbl := Label.new()
|
||||
desc_lbl.text = desc
|
||||
desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
desc_lbl.modulate = Color(0.65, 0.65, 0.75)
|
||||
desc_lbl.add_theme_font_size_override("font_size", 11)
|
||||
inner.add_child(desc_lbl)
|
||||
|
||||
btn.pressed.connect(func(): _select_deck(id))
|
||||
return btn
|
||||
|
||||
|
||||
func _apply_card_style(btn: Button, selected: bool,
|
||||
bg: Color = Color(0.13, 0.13, 0.20, 1.0)) -> void:
|
||||
var make := func(b: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = b
|
||||
s.border_color = SEL_COLOR if selected else DEF_COLOR
|
||||
s.set_border_width_all(2)
|
||||
s.set_corner_radius_all(6)
|
||||
s.content_margin_left = 14
|
||||
s.content_margin_right = 14
|
||||
s.content_margin_top = 12
|
||||
s.content_margin_bottom = 12
|
||||
return s
|
||||
btn.add_theme_stylebox_override("normal", make.call(bg))
|
||||
btn.add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||
btn.add_theme_stylebox_override("pressed", make.call(bg))
|
||||
btn.add_theme_stylebox_override("focus", make.call(bg))
|
||||
|
||||
|
||||
func _select_deck(id: String) -> void:
|
||||
_selected_id = id
|
||||
for child in deck_list.get_children():
|
||||
var btn := child as Button
|
||||
if btn == null:
|
||||
continue
|
||||
_apply_card_style(btn, btn.name == ("Deck_%s" % id))
|
||||
confirm_btn.disabled = false
|
||||
|
||||
# ── Confirm ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_confirm_pressed() -> void:
|
||||
if _selected_id.is_empty() or _confirming:
|
||||
return
|
||||
_confirming = true
|
||||
confirm_btn.disabled = true
|
||||
status_label.text = "Claiming your starter deck…"
|
||||
status_label.visible = true
|
||||
|
||||
Network.request(
|
||||
"collection.select_starter_deck",
|
||||
{ "starterDeckId": _selected_id },
|
||||
func(_type: String, _p: Variant): _on_select_ok(),
|
||||
func(code: String, msg: String): _on_select_error(code, msg)
|
||||
)
|
||||
|
||||
|
||||
func _on_select_ok() -> void:
|
||||
Auth.needs_starter_deck = false
|
||||
get_tree().change_scene_to_file("res://scenes/init/InitScreen.tscn")
|
||||
|
||||
|
||||
func _on_select_error(code: String, msg: String) -> void:
|
||||
_confirming = false
|
||||
confirm_btn.disabled = false
|
||||
status_label.text = "Could not select deck (%s): %s" % [code, msg]
|
||||
status_label.visible = true
|
||||
Reference in New Issue
Block a user