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