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()