fix(daily): full 30-room rotation and reset-safe profile
Use a fixed shuffled order so every room appears once before repeats. Keep Profile Confirm/Cancel visible, clear locked avatar/frame on reset, and make Home's avatar caption dynamic.
This commit is contained in:
1 parent
0cc08de31b
commit
b4fd03a8a4
6 files changed
+74
-15
No files matched your search
+16
-2
@@ -53,9 +53,23 @@ static func goal_text(streak: int) -> String:
|
|||||||
return "%d more day%s until the Regular frame" % [3 - streak, "" if 3 - 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.
|
## Stable per-date room choice. A fixed shuffled order guarantees every
|
||||||
|
## room appears once before the daily pool repeats.
|
||||||
static func level_index(level_count: int, key: String = "") -> int:
|
static func level_index(level_count: int, key: String = "") -> int:
|
||||||
if level_count <= 0:
|
if level_count <= 0:
|
||||||
return -1
|
return -1
|
||||||
var date_key := key if key != "" else today_key()
|
var date_key := key if key != "" else today_key()
|
||||||
return absi(("ratdoku-daily-" + date_key).hash()) % level_count
|
var index := absi(day_number(date_key)) % level_count
|
||||||
|
|
||||||
|
# Deterministic across devices and sessions: same seed => same order.
|
||||||
|
var rng := RandomNumberGenerator.new()
|
||||||
|
rng.seed = 0x52415444
|
||||||
|
var order: Array = []
|
||||||
|
for i in range(level_count):
|
||||||
|
order.append(i)
|
||||||
|
for i in range(level_count - 1, 0, -1):
|
||||||
|
var j := rng.randi_range(0, i)
|
||||||
|
var swap = order[i]
|
||||||
|
order[i] = order[j]
|
||||||
|
order[j] = swap
|
||||||
|
return int(order[index])
|
||||||
+12
-1
@@ -11,6 +11,7 @@ signal streak_pressed
|
|||||||
var progress_pill: Button
|
var progress_pill: Button
|
||||||
var primary: Button
|
var primary: Button
|
||||||
var hint_label: Label
|
var hint_label: Label
|
||||||
|
var mascot_caption: Label
|
||||||
var daily_button: Button
|
var daily_button: Button
|
||||||
var streak_button: Button
|
var streak_button: Button
|
||||||
var avatar_holder: CenterContainer
|
var avatar_holder: CenterContainer
|
||||||
@@ -91,7 +92,8 @@ func _ready() -> void:
|
|||||||
card.add_child(mascot)
|
card.add_child(mascot)
|
||||||
column.add_child(card)
|
column.add_child(card)
|
||||||
|
|
||||||
column.add_child(UI.label("Crumb, innkeeper", 12, Palette.MUTED))
|
mascot_caption = UI.label("Crumb, innkeeper", 12, Palette.MUTED)
|
||||||
|
column.add_child(mascot_caption)
|
||||||
hint_label = UI.label(UI.place_hint(), 11, Palette.MUTED)
|
hint_label = UI.label(UI.place_hint(), 11, Palette.MUTED)
|
||||||
column.add_child(hint_label)
|
column.add_child(hint_label)
|
||||||
|
|
||||||
@@ -133,6 +135,15 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func refresh() -> void:
|
func refresh() -> void:
|
||||||
hint_label.text = UI.place_hint()
|
hint_label.text = UI.place_hint()
|
||||||
|
var avatar_id := SaveGame.selected_avatar()
|
||||||
|
if avatar_id == "crumb":
|
||||||
|
mascot_caption.text = "Crumb, innkeeper"
|
||||||
|
else:
|
||||||
|
var guest := Guests.by_id(avatar_id)
|
||||||
|
mascot_caption.text = "%s · %s" % [
|
||||||
|
str(guest.get("name", avatar_id)),
|
||||||
|
str(guest.get("role", "Guest"))
|
||||||
|
]
|
||||||
daily_button.text = _daily_text()
|
daily_button.text = _daily_text()
|
||||||
_refresh_avatar()
|
_refresh_avatar()
|
||||||
var guests := Guests.all()
|
var guests := Guests.all()
|
||||||
|
|||||||
+13
-12
@@ -51,6 +51,19 @@ func _ready() -> void:
|
|||||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||||
column.add_child(scroll)
|
column.add_child(scroll)
|
||||||
|
|
||||||
|
# Confirm/Cancel stay visible instead of being hidden below the scroll.
|
||||||
|
var actions := HBoxContainer.new()
|
||||||
|
actions.add_theme_constant_override("separation", 8)
|
||||||
|
column.add_child(actions)
|
||||||
|
var cancel := UI.button("Cancel", false, 46)
|
||||||
|
cancel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
cancel.pressed.connect(_on_cancel)
|
||||||
|
actions.add_child(cancel)
|
||||||
|
var confirm := UI.button("Confirm", true, 46)
|
||||||
|
confirm.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
confirm.pressed.connect(_on_confirm)
|
||||||
|
actions.add_child(confirm)
|
||||||
|
|
||||||
var content := VBoxContainer.new()
|
var content := VBoxContainer.new()
|
||||||
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
content.add_theme_constant_override("separation", 8)
|
content.add_theme_constant_override("separation", 8)
|
||||||
@@ -99,18 +112,6 @@ func _ready() -> void:
|
|||||||
status_label.custom_minimum_size = Vector2(0, 22)
|
status_label.custom_minimum_size = Vector2(0, 22)
|
||||||
content.add_child(status_label)
|
content.add_child(status_label)
|
||||||
|
|
||||||
var actions := HBoxContainer.new()
|
|
||||||
actions.add_theme_constant_override("separation", 8)
|
|
||||||
content.add_child(actions)
|
|
||||||
var cancel := UI.button("Cancel", false, 46)
|
|
||||||
cancel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
||||||
cancel.pressed.connect(_on_cancel)
|
|
||||||
actions.add_child(cancel)
|
|
||||||
var confirm := UI.button("Confirm", true, 46)
|
|
||||||
confirm.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
||||||
confirm.pressed.connect(_on_confirm)
|
|
||||||
actions.add_child(confirm)
|
|
||||||
|
|
||||||
UI.pass_scroll_input(content)
|
UI.pass_scroll_input(content)
|
||||||
SaveGame.progress_changed.connect(refresh)
|
SaveGame.progress_changed.connect(refresh)
|
||||||
refresh()
|
refresh()
|
||||||
|
|||||||
@@ -151,6 +151,19 @@ func reset_progress() -> void:
|
|||||||
data["completed_rooms"] = []
|
data["completed_rooms"] = []
|
||||||
data["unlocked_guests"] = []
|
data["unlocked_guests"] = []
|
||||||
data["last_room"] = 0
|
data["last_room"] = 0
|
||||||
|
|
||||||
|
# Room-based unlocks can disappear after a reset; never leave a locked
|
||||||
|
# frame or guest avatar equipped.
|
||||||
|
var frame := Frames.by_id(selected_frame())
|
||||||
|
if (
|
||||||
|
frame.is_empty()
|
||||||
|
or rooms_completed() < int(frame.get("rooms", 0))
|
||||||
|
or best_streak() < int(frame.get("streak", 0))
|
||||||
|
):
|
||||||
|
data["profile_frame"] = "plain"
|
||||||
|
if not Avatars.is_unlocked(selected_avatar()):
|
||||||
|
data["avatar_id"] = "crumb"
|
||||||
|
|
||||||
save_game()
|
save_game()
|
||||||
progress_changed.emit()
|
progress_changed.emit()
|
||||||
|
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ func _test_daily(save) -> void:
|
|||||||
all_valid = false
|
all_valid = false
|
||||||
distinct[i] = true
|
distinct[i] = true
|
||||||
_check(all_valid, "30 consecutive dates should all produce valid daily indices")
|
_check(all_valid, "30 consecutive dates should all produce valid daily indices")
|
||||||
|
_check(distinct.size() == 30, "30 consecutive dates should visit all 30 rooms")
|
||||||
_note("distinct daily levels across 30 consecutive days: %d" % distinct.size())
|
_note("distinct daily levels across 30 consecutive days: %d" % distinct.size())
|
||||||
|
|
||||||
_reset_to_clean(save)
|
_reset_to_clean(save)
|
||||||
|
|||||||
@@ -47,12 +47,31 @@ func _run() -> void:
|
|||||||
await _test_campaign(main, save)
|
await _test_campaign(main, save)
|
||||||
await _test_guest_book(main)
|
await _test_guest_book(main)
|
||||||
await _test_back(main)
|
await _test_back(main)
|
||||||
|
await _test_reset_fallback(main, save)
|
||||||
_restore_defaults(save)
|
_restore_defaults(save)
|
||||||
|
|
||||||
print("QA UI: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
print("QA UI: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
||||||
quit(0 if failures == 0 else 1)
|
quit(0 if failures == 0 else 1)
|
||||||
|
|
||||||
|
|
||||||
|
func _test_reset_fallback(main, save) -> void:
|
||||||
|
main.show_screen("home", false)
|
||||||
|
await process_frame
|
||||||
|
save.data["avatar_id"] = "pepper"
|
||||||
|
save.data["profile_frame"] = "paper"
|
||||||
|
save.data["completed_rooms"] = ["a", "b", "c", "d", "e"]
|
||||||
|
save.save_game()
|
||||||
|
save.progress_changed.emit()
|
||||||
|
await process_frame
|
||||||
|
_check(main.home.mascot_caption.text.find("Pepper") >= 0, "Home caption should follow the chosen avatar")
|
||||||
|
|
||||||
|
save.reset_progress()
|
||||||
|
await process_frame
|
||||||
|
_check(save.selected_frame() == "plain", "reset should clear a room-locked frame")
|
||||||
|
_check(save.selected_avatar() == "crumb", "reset should clear a locked guest avatar")
|
||||||
|
_check(main.home.mascot_caption.text.find("Crumb") >= 0, "Home caption should return to Crumb")
|
||||||
|
|
||||||
|
|
||||||
func _test_screen_cycle(main) -> void:
|
func _test_screen_cycle(main) -> void:
|
||||||
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile", "streak"]
|
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile", "streak"]
|
||||||
_check(main.screens.size() == expected.size(), "Main should expose all six screens")
|
_check(main.screens.size() == expected.size(), "Main should expose all six screens")
|
||||||
|
|||||||
Reference in new issue
Block a user