Profile now has tabbed Avatar/Frame pickers with preview and Confirm/Cancel. Crumb plus unlocked guest portraits can be chosen as the avatar. A new Daily Streak screen shows the current streak, best streak, weekly calendar, next-frame goal, and a 7-day gift marker. Save format moves to version 4 with avatar_id and completion history.
62 lines
2.0 KiB
GDScript
62 lines
2.0 KiB
GDScript
class_name Daily
|
|
extends RefCounted
|
|
|
|
## Date helpers for the daily room. Everything is keyed by the player's
|
|
## local calendar date so the same key is used on save and on display.
|
|
|
|
static func today_key() -> String:
|
|
var d := Time.get_date_dict_from_system()
|
|
return "%04d-%02d-%02d" % [int(d.get("year", 0)), int(d.get("month", 0)), int(d.get("day", 0))]
|
|
|
|
|
|
static func day_number(key: String) -> int:
|
|
var parts := key.split("-")
|
|
if parts.size() != 3:
|
|
return 0
|
|
var stamp := Time.get_unix_time_from_datetime_dict({
|
|
"year": int(parts[0]),
|
|
"month": int(parts[1]),
|
|
"day": int(parts[2]),
|
|
"hour": 0,
|
|
"minute": 0,
|
|
"second": 0,
|
|
})
|
|
return int(floor(float(stamp) / 86400.0))
|
|
|
|
|
|
static func key_from_day_number(day: int) -> String:
|
|
var d := Time.get_datetime_dict_from_unix_time(day * 86400)
|
|
return "%04d-%02d-%02d" % [int(d.get("year", 0)), int(d.get("month", 0)), int(d.get("day", 0))]
|
|
|
|
|
|
## Monday-to-Sunday keys for the week containing today.
|
|
static func week_keys() -> Array:
|
|
var date := Time.get_date_dict_from_system()
|
|
var weekday := int(date.get("weekday", 0)) # Godot: 0 = Sunday.
|
|
var monday_offset := (weekday + 6) % 7
|
|
var base := day_number(today_key()) - monday_offset
|
|
var out := []
|
|
for i in range(7):
|
|
out.append(key_from_day_number(base + i))
|
|
return out
|
|
|
|
|
|
static func weekday_labels() -> Array:
|
|
return ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
|
|
|
|
|
|
static func goal_text(streak: int) -> String:
|
|
if streak >= 7:
|
|
return "Week complete — your 7-day gift is ready."
|
|
if streak >= 3:
|
|
return "%d more day%s until the Night Owl frame" % [7 - streak, "" if 7 - streak == 1 else "s"]
|
|
return "%d more day%s until the Regular frame" % [3 - streak, "" if 3 - streak == 1 else "s"]
|
|
|
|
|
|
## Stable per-date room choice. With 30 rooms the pool repeats monthly.
|
|
static func level_index(level_count: int, key: String = "") -> int:
|
|
if level_count <= 0:
|
|
return -1
|
|
var date_key := key if key != "" else today_key()
|
|
return absi(("ratdoku-daily-" + date_key).hash()) % level_count
|