Files
Ratdoku/scripts/Frames.gd
T
Ratdoku Builder 7e6a338240 feat(daily): add daily rooms, streaks, and profile frames
A deterministic daily room rotates through the 30-level pool and tracks current and best streaks in save version 3. Daily wins are separate from campaign progress. The new Profile screen shows framed Crumb, stats, and selectable frames unlocked by rooms or best streak.
2026-12-02 22:29:32 -06:00

107 lines
3.3 KiB
GDScript

class_name Frames
extends RefCounted
## Profile frame definitions. Unlocks use campaign room count and the best
## daily streak, so a frame is never lost when a streak resets.
const DEFS := [
{
"id": "plain", "name": "Plain", "rooms": 0, "streak": 0,
"border": Palette.WALL, "width": 2, "shadow": Color(0, 0, 0, 0), "shadow_size": 0,
},
{
"id": "paper", "name": "Paper", "rooms": 5, "streak": 0,
"border": Palette.MUTED, "width": 3, "shadow": Color(0, 0, 0, 0), "shadow_size": 0,
},
{
"id": "gold", "name": "Gold", "rooms": 10, "streak": 0,
"border": Palette.GOLD, "width": 4, "shadow": Palette.GOLD, "shadow_size": 5,
},
{
"id": "bell", "name": "Bellhop", "rooms": 20, "streak": 0,
"border": Palette.INK, "width": 3, "shadow": Palette.ORANGE, "shadow_size": 4,
},
{
"id": "star", "name": "Star guest", "rooms": 30, "streak": 0,
"border": Palette.GOLD, "width": 4, "shadow": Palette.WHITE, "shadow_size": 7,
},
{
"id": "regular", "name": "Regular", "rooms": 0, "streak": 3,
"border": Palette.ORANGE, "width": 4, "shadow": Palette.ORANGE, "shadow_size": 6,
},
{
"id": "night", "name": "Night owl", "rooms": 0, "streak": 7,
"border": Palette.INK, "width": 4, "shadow": Palette.GOLD, "shadow_size": 8,
},
]
static func all() -> Array:
return DEFS
static func by_id(id: String) -> Dictionary:
for frame in DEFS:
if str(frame.get("id", "")) == id:
return frame
return {}
static func is_unlocked(id: String) -> bool:
var frame := by_id(id)
if frame.is_empty():
return false
var rooms: int = SaveGame.rooms_completed()
var streak: int = SaveGame.best_streak()
return rooms >= int(frame.get("rooms", 0)) and streak >= int(frame.get("streak", 0))
static func requirement_text(id: String) -> String:
var frame := by_id(id)
if frame.is_empty():
return ""
var rooms := int(frame.get("rooms", 0))
var streak := int(frame.get("streak", 0))
if rooms > 0 and streak > 0:
return "%d rooms · %d-day streak" % [rooms, streak]
if rooms > 0:
return "Complete %d rooms" % rooms
if streak > 0:
return "%d-day best streak" % streak
return "Always available"
static func style_for(id: String, size: int) -> StyleBoxFlat:
var frame := by_id(id)
if frame.is_empty():
frame = DEFS[0]
var radius: int = max(6, int(size * 0.45))
var width: int = int(frame.get("width", 2))
var style := StyleBoxFlat.new()
style.bg_color = Color(0, 0, 0, 0)
style.corner_radius_top_left = radius
style.corner_radius_top_right = radius
style.corner_radius_bottom_left = radius
style.corner_radius_bottom_right = radius
style.border_width_left = width
style.border_width_right = width
style.border_width_top = width
style.border_width_bottom = width
style.border_color = frame.get("border", Palette.WALL)
style.shadow_color = frame.get("shadow", Color(0, 0, 0, 0))
style.shadow_size = int(frame.get("shadow_size", 0))
style.shadow_offset = Vector2(0, 2)
style.content_margin_left = width + 2
style.content_margin_right = width + 2
style.content_margin_top = width + 2
style.content_margin_bottom = width + 2
return style
## A sized PanelContainer with the frame border. Add the avatar inside it.
static func frame_panel(id: String, size: int) -> PanelContainer:
var panel := PanelContainer.new()
panel.custom_minimum_size = Vector2(size, size)
panel.add_theme_stylebox_override("panel", style_for(id, size))
return panel