feat(profile): selectable avatars and a daily streak view

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.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 23:57:28 -06:00
1 parent c91586b4a1
commit d0be689faa
16 files changed
+538 -60

No files matched your search

+54 -10
View File
@@ -8,6 +8,7 @@ extends SceneTree
var failures := 0
var frames = null
var avatars = null
func _init() -> void:
@@ -35,13 +36,16 @@ func _run() -> void:
# SaveGame autoload is registered when launched with --script.
frames = load("res://scripts/Frames.gd")
_check(frames != null, "Frames script missing")
if frames == null:
avatars = load("res://scripts/Avatars.gd")
_check(avatars != null, "Avatars script missing")
if frames == null or avatars == null:
_finish()
return
_test_save_migrations(save)
_test_daily(save)
_test_frames(save)
_test_avatars_and_streak(save)
_test_game_data(save)
_test_icons()
@@ -49,8 +53,48 @@ func _run() -> void:
_finish()
func _test_avatars_and_streak(save) -> void:
_note("5. avatars and streak view")
var list: Array = avatars.all()
_check(list.size() == 26, "Crumb plus 25 guests should be selectable")
_check(avatars.is_unlocked("crumb"), "Crumb should always be available")
_check(avatars.by_id("does-not-exist").is_empty(), "unknown avatar should resolve to nothing")
var locked_id := ""
for entry in list:
var id := str(entry.get("id", ""))
if id != "crumb" and not avatars.is_unlocked(id):
locked_id = id
break
_check(locked_id != "", "a guest avatar should be locked with no progress")
_check(not avatars.requirement_text(locked_id).is_empty(), "locked avatar should show a requirement")
save.reset_progress()
save.select_avatar("crumb")
save.load_game()
_check(save.selected_avatar() == "crumb", "avatar selection should persist")
save.apply_profile("crumb", "gold")
save.load_game()
_check(save.selected_avatar() == "crumb" and save.selected_frame() == "gold", "profile should save both choices at once")
var keys: Array = Daily.week_keys()
_check(keys.size() == 7, "the streak week should have seven days")
_check(Daily.weekday_labels().size() == 7, "the streak week should have seven labels")
_check(Daily.goal_text(0).find("Regular") >= 0, "early streak goal should point to Regular")
_check(Daily.goal_text(4).find("Night Owl") >= 0, "mid streak goal should point to Night Owl")
_check(Daily.goal_text(7).find("gift") >= 0, "completed week should show the gift goal")
var today := Daily.today_key()
save.data["daily"] = save._default_daily()
save.complete_daily(today)
_check(save.daily_history().has(today), "completing a daily should record history")
save.complete_daily(today)
_check(save.daily_history().size() == 1, "replaying a day should not duplicate history")
_reset_to_clean(save)
func _test_icons() -> void:
_note("5. icon assets")
_note("6. icon assets")
# Load at runtime so UI.gd does not compile before the autoload exists.
var ui_script = load("res://scripts/UI.gd")
_check(ui_script != null, "UI script missing")
@@ -145,10 +189,10 @@ func _is_default_daily(save, daily: Dictionary) -> bool:
func _test_save_migrations(save) -> void:
_note("1. save migration matrix")
# (a) No save file at all -> fresh version-3 defaults.
# (a) No save file at all -> fresh version-4 defaults.
_remove_save(save)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "fresh save should be version 3")
_check(int(save.data.get("version", 0)) == 4, "fresh save should be version 4")
_check(bool(save.get_setting("double_tap_place")), "fresh save should default to double-tap")
_check(_is_default_daily(save, save.daily_data()), "fresh save should have default daily stats")
_check(save.selected_frame() == "plain", "fresh save should select the plain frame")
@@ -163,7 +207,7 @@ func _test_save_migrations(save) -> void:
v1.erase("profile_frame")
_write_save(save, v1)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "version 1 should migrate to version 3")
_check(int(save.data.get("version", 0)) == 4, "version 1 should migrate to version 4")
_check(bool(save.get_setting("double_tap_place")), "version 1 should migrate to double-tap")
_check(_is_default_daily(save, save.daily_data()), "version 1 missing daily should become defaults")
_check(save.selected_frame() == "plain", "version 1 missing frame should become plain")
@@ -176,7 +220,7 @@ func _test_save_migrations(save) -> void:
v2.erase("profile_frame")
_write_save(save, v2)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "version 2 should migrate to version 3")
_check(int(save.data.get("version", 0)) == 4, "version 2 should migrate to version 4")
_check(not bool(save.get_setting("double_tap_place")), "version 2 double_tap=false should stay false")
_check(_is_default_daily(save, save.daily_data()), "version 2 missing daily should become defaults")
_check(save.selected_frame() == "plain", "version 2 missing frame should become plain")
@@ -189,7 +233,7 @@ func _test_save_migrations(save) -> void:
else:
_check(false, "could not write wrong-shape save")
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "wrong-shape save should restore version 3 defaults")
_check(int(save.data.get("version", 0)) == 4, "wrong-shape save should restore version 4 defaults")
_check(bool(save.get_setting("double_tap_place")), "wrong-shape save should restore double-tap default")
_check(_is_default_daily(save, save.daily_data()), "wrong-shape save should restore daily defaults")
_check(save.selected_frame() == "plain", "wrong-shape save should restore plain frame")
@@ -197,7 +241,7 @@ func _test_save_migrations(save) -> void:
# (e) Missing individual setting keys are filled from DEFAULTS.
var partial: Dictionary = save._default_data()
partial["version"] = 3
partial["version"] = 4
partial["settings"] = {}
_write_save(save, partial)
save.load_game()
@@ -208,9 +252,9 @@ func _test_save_migrations(save) -> void:
"filled setting '%s' should match DEFAULTS" % key
)
# A version-3 save's explicit false must not be overwritten by a default.
# A version-4 save's explicit false must not be overwritten by a default.
var explicit_false: Dictionary = save._default_data()
explicit_false["version"] = 3
explicit_false["version"] = 4
explicit_false["settings"]["double_tap_place"] = false
_write_save(save, explicit_false)
save.load_game()
+34 -6
View File
@@ -53,13 +53,13 @@ func _run() -> void:
func _test_screen_cycle(main) -> void:
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile"]
_check(main.screens.size() == expected.size(), "Main should expose all five screens")
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile", "streak"]
_check(main.screens.size() == expected.size(), "Main should expose all six screens")
for name in expected:
_check(main.screens.has(name) and main.screens[name] != null, "screen missing: %s" % name)
_check(
main.home != null and main.game != null and main.guest_book != null
and main.rulebook != null and main.profile != null,
and main.rulebook != null and main.profile != null and main.streak != null,
"named screen references should all exist"
)
_check(main.settings_sheet != null, "settings sheet missing")
@@ -169,6 +169,8 @@ func _test_profile(main, save) -> void:
if profile == null:
return
profile._set_tab("frame")
await process_frame
var expected: int = frames.all().size()
_check(profile.frame_grid.get_child_count() == expected, "Profile should show every frame")
for i in range(profile.frame_grid.get_child_count()):
@@ -211,9 +213,19 @@ func _test_profile(main, save) -> void:
_check(int(probe["count"]) == count_before, "frame grid must stay stable while pressed emits")
await process_frame
await process_frame
_check(save.selected_frame() == "regular", "pressing an unlocked frame should select it")
_check(profile.pending_frame == "regular", "frame card should update the preview")
profile._on_confirm()
await process_frame
_check(save.selected_frame() == "regular", "Confirm should apply the frame")
_check(profile.status_label.text.find("Profile updated") >= 0, "confirmation should be reported")
_check(profile.frame_grid.get_child_count() == count_before, "frame grid should stay stable after selection")
_check(profile.status_label.text.find("Now wearing") >= 0, "selection should be reported in profile status")
profile.pending_frame = "plain"
profile._build_portrait()
profile._build_grid()
profile._on_cancel()
await process_frame
_check(save.selected_frame() == "regular", "Cancel should not write to the save")
var locked_card = profile.frame_grid.get_child(night_index)
locked_card.pressed.emit()
@@ -222,7 +234,23 @@ func _test_profile(main, save) -> void:
profile.status_label.text.find(frames.requirement_text("night")) >= 0,
"locked frame should show its requirement"
)
_check(save.selected_frame() == "regular", "locked frame must not change the selection")
_check(profile.pending_frame == "regular", "locked frame must not change the preview")
profile._set_tab("avatar")
await process_frame
_check(profile.frame_grid.get_child_count() > 10, "avatar tab should list portraits")
for i in range(profile.frame_grid.get_child_count()):
_check(
profile.frame_grid.get_child(i).mouse_filter == Control.MOUSE_FILTER_PASS,
"avatar card %d should pass swipes" % i
)
profile.streak_pressed.emit()
await process_frame
_check(main.current == "streak", "Profile should open the streak screen")
_check(main.streak.week_row.get_child_count() == 7, "streak screen should show a seven-day week")
_check(main.streak.current_label.text == str(save.daily_streak()), "streak number should match the save")
main.show_screen("profile", false)
func _test_daily(main, save) -> void:
+3
View File
@@ -27,6 +27,9 @@ func _run() -> void:
main.show_screen("profile")
await _settle()
_save("res://screenshots/profile.png")
main.profile.streak_pressed.emit()
await _settle()
_save("res://screenshots/streak.png")
main.show_screen("home", false)
main.open_settings("home")
+15 -4
View File
@@ -169,6 +169,8 @@ func _test_daily_and_frames(save, main) -> void:
await process_frame
_check(main.profile != null, "Profile screen missing")
if main.profile != null:
main.profile._set_tab("frame")
await process_frame
_check(
main.profile.frame_grid.get_child_count() == frames.all().size(),
"Profile should show every frame"
@@ -187,11 +189,20 @@ func _test_daily_and_frames(save, main) -> void:
main.profile.frame_grid.get_child(regular_index).pressed.emit()
await process_frame
await process_frame
_check(save.selected_frame() == "regular", "frame press should select the frame")
_check(main.profile.pending_frame == "regular", "frame card should update the preview")
main.profile._on_confirm()
await process_frame
_check(save.selected_frame() == "regular", "confirm should apply the frame")
_check(
main.profile.frame_grid.get_child_count() == frames.all().size(),
"frame grid should stay stable after selection"
)
main.profile._set_tab("avatar")
await process_frame
_check(main.profile.frame_grid.get_child_count() > 10, "avatar tab should list portraits")
main.home.streak_pressed.emit()
await process_frame
_check(main.current == "streak", "streak button should open the streak screen")
main.show_screen("home")
main.home.daily_pressed.emit()
await process_frame
@@ -205,12 +216,12 @@ func _test_daily_and_frames(save, main) -> void:
func _test_save_defaults(save) -> void:
# A fresh save starts in double-tap mode at version 2.
# A fresh save starts in double-tap mode at version 4.
var abs_path := ProjectSettings.globalize_path(save.PATH)
if FileAccess.file_exists(save.PATH):
DirAccess.remove_absolute(abs_path)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "fresh saves should be version 3")
_check(int(save.data.get("version", 0)) == 4, "fresh saves should be version 4")
_check(bool(save.get_setting("double_tap_place")), "fresh saves should default to double-tap")
# A version 1 save with hold selected migrates to double-tap once.
@@ -222,7 +233,7 @@ func _test_save_defaults(save) -> void:
file.close()
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "version 1 saves should migrate to version 3")
_check(int(save.data.get("version", 0)) == 4, "version 1 saves should migrate to version 4")
_check(bool(save.get_setting("double_tap_place")), "version 1 saves should migrate to double-tap")