feat: guest stories, accessibility and cozy events
v0.9.0-alpha local build. Adds per-guest story vignettes, a scrollable Guest Book story section, live text scaling, Android haptics, a difficulty picker with descriptions, six repeating cosmetic hotel events, and isolated free play using verified symmetry variants. Save format v7 with automatic migration. QA is 9/9 including the free-play uniqueness suite.
This commit is contained in:
1 parent
e0fd33c25e
commit
9e2776f7c4
27 files changed
+1559
-99
No files matched your search
+165
-10
@@ -20,6 +20,8 @@ const DEFAULTS := {
|
||||
"sfx_volume": 0.8,
|
||||
"difficulty": "normal",
|
||||
"theme": "cream",
|
||||
"ui_scale": 1.0,
|
||||
"haptics": true,
|
||||
}
|
||||
|
||||
var data := {}
|
||||
@@ -40,9 +42,11 @@ func _default_daily() -> Dictionary:
|
||||
|
||||
func _default_data() -> Dictionary:
|
||||
return {
|
||||
"version": 6,
|
||||
"version": 7,
|
||||
"completed_rooms": [],
|
||||
"unlocked_guests": [],
|
||||
"guest_notes": {},
|
||||
"events": {},
|
||||
"settings": DEFAULTS.duplicate(true),
|
||||
"last_room": 0,
|
||||
"daily": _default_daily(),
|
||||
@@ -63,7 +67,7 @@ func _new_player_id() -> String:
|
||||
|
||||
func load_game() -> void:
|
||||
data = _default_data()
|
||||
var stored_version := 6
|
||||
var stored_version := 7
|
||||
|
||||
if FileAccess.file_exists(PATH):
|
||||
var file := FileAccess.open(PATH, FileAccess.READ)
|
||||
@@ -112,12 +116,16 @@ func load_game() -> void:
|
||||
data["gift_claimed"] = []
|
||||
if typeof(data.get("saved_boards")) != TYPE_DICTIONARY:
|
||||
data["saved_boards"] = {}
|
||||
if typeof(data.get("guest_notes")) != TYPE_DICTIONARY:
|
||||
data["guest_notes"] = {}
|
||||
if typeof(data.get("events")) != TYPE_DICTIONARY:
|
||||
data["events"] = {}
|
||||
|
||||
var migrated := false
|
||||
# Version 2 made double-tap the default; version 3 added daily streaks and
|
||||
# profile frames; version 4 added avatars and streak history; version 5
|
||||
# added music; version 6 added identity, achievements, gifts, themes,
|
||||
# difficulty and saved boards.
|
||||
# difficulty and saved boards; version 7 added guest notes and events.
|
||||
if stored_version < 2:
|
||||
data["settings"]["double_tap_place"] = true
|
||||
migrated = true
|
||||
@@ -129,6 +137,8 @@ func load_game() -> void:
|
||||
migrated = true
|
||||
if stored_version < 6:
|
||||
migrated = true
|
||||
if stored_version < 7:
|
||||
migrated = true
|
||||
|
||||
if typeof(data.get("completed_rooms")) != TYPE_ARRAY:
|
||||
data["completed_rooms"] = []
|
||||
@@ -136,7 +146,7 @@ func load_game() -> void:
|
||||
data["unlocked_guests"] = []
|
||||
|
||||
if migrated:
|
||||
data["version"] = 6
|
||||
data["version"] = 7
|
||||
save_game()
|
||||
|
||||
|
||||
@@ -192,15 +202,12 @@ func reset_progress() -> void:
|
||||
data["unlocked_guests"] = []
|
||||
data["last_room"] = 0
|
||||
data["saved_boards"] = {}
|
||||
data["guest_notes"] = {}
|
||||
data["events"] = {}
|
||||
|
||||
# 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))
|
||||
):
|
||||
if not Frames.is_unlocked(selected_frame()):
|
||||
data["profile_frame"] = "plain"
|
||||
if not Avatars.is_unlocked(selected_avatar()):
|
||||
data["avatar_id"] = "crumb"
|
||||
@@ -221,6 +228,153 @@ func rooms_completed() -> int:
|
||||
return (data.get("completed_rooms") as Array).size()
|
||||
|
||||
|
||||
## Guest story progress. Free play never calls this; only campaign/daily rooms.
|
||||
func record_guest_visit(id: String) -> int:
|
||||
if id.is_empty() or not is_guest_unlocked(id):
|
||||
return guest_visits(id)
|
||||
var notes: Dictionary = data.get("guest_notes", {})
|
||||
var entry: Dictionary = notes.get(id, {})
|
||||
if typeof(entry) != TYPE_DICTIONARY:
|
||||
entry = {}
|
||||
entry["visits"] = int(entry.get("visits", 0)) + 1
|
||||
notes[id] = entry
|
||||
data["guest_notes"] = notes
|
||||
save_game()
|
||||
return int(entry["visits"])
|
||||
|
||||
|
||||
func guest_visits(id: String) -> int:
|
||||
var notes: Dictionary = data.get("guest_notes", {})
|
||||
var entry = notes.get(id, {})
|
||||
return int(entry.get("visits", 0)) if typeof(entry) == TYPE_DICTIONARY else 0
|
||||
|
||||
|
||||
func story_line_count(id: String) -> int:
|
||||
if not is_guest_unlocked(id):
|
||||
return 0
|
||||
var visits := guest_visits(id)
|
||||
if visits >= 7:
|
||||
return 3
|
||||
if visits >= 3:
|
||||
return 2
|
||||
return 1
|
||||
|
||||
|
||||
static var _events_cache: Array = []
|
||||
|
||||
|
||||
static func event_defs() -> Array:
|
||||
if _events_cache.is_empty():
|
||||
var path := "res://data/events.json"
|
||||
if FileAccess.file_exists(path):
|
||||
var file := FileAccess.open(path, FileAccess.READ)
|
||||
if file != null:
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_ARRAY:
|
||||
_events_cache = parsed
|
||||
return _events_cache
|
||||
|
||||
|
||||
static func event_cycle_length() -> int:
|
||||
var total := 0
|
||||
for event in event_defs():
|
||||
total += max(1, int(event.get("duration_days", 3)))
|
||||
return max(1, total)
|
||||
|
||||
|
||||
func current_event() -> Dictionary:
|
||||
var defs := event_defs()
|
||||
if defs.is_empty():
|
||||
return {}
|
||||
var day := int(floor(Time.get_unix_time_from_system() / 86400.0))
|
||||
var cycle := day / event_cycle_length()
|
||||
var position := day % event_cycle_length()
|
||||
var start := 0
|
||||
for event in defs:
|
||||
var duration := max(1, int(event.get("duration_days", 3)))
|
||||
if position < start + duration:
|
||||
var out: Dictionary = (event as Dictionary).duplicate(true)
|
||||
out["cycle"] = cycle
|
||||
out["day_in_event"] = position - start
|
||||
return out
|
||||
start += duration
|
||||
var out: Dictionary = (defs[defs.size() - 1] as Dictionary).duplicate(true)
|
||||
out["cycle"] = cycle
|
||||
out["day_in_event"] = max(0, position - start)
|
||||
return out
|
||||
|
||||
|
||||
func event_state(id: String, cycle: int) -> Dictionary:
|
||||
var events: Dictionary = data.get("events", {})
|
||||
var entry = events.get(id, {})
|
||||
if typeof(entry) != TYPE_DICTIONARY or int(entry.get("cycle", -1)) != cycle:
|
||||
return {"cycle": cycle, "progress": 0, "claimed": false, "last_date": ""}
|
||||
return (entry as Dictionary).duplicate(true)
|
||||
|
||||
|
||||
func record_daily_event_progress(date_key: String) -> void:
|
||||
var event := current_event()
|
||||
var id := str(event.get("id", ""))
|
||||
if id.is_empty():
|
||||
return
|
||||
var cycle := int(event.get("cycle", 0))
|
||||
var entry: Dictionary = event_state(id, cycle)
|
||||
if str(entry.get("last_date", "")) == date_key:
|
||||
return
|
||||
entry["cycle"] = cycle
|
||||
entry["last_date"] = date_key
|
||||
entry["progress"] = min(3, int(entry.get("progress", 0)) + 1)
|
||||
var events: Dictionary = data.get("events", {})
|
||||
events[id] = entry
|
||||
data["events"] = events
|
||||
save_game()
|
||||
|
||||
|
||||
func event_progress(id: String = "") -> int:
|
||||
var event := current_event()
|
||||
var event_id := id if not id.is_empty() else str(event.get("id", ""))
|
||||
return int(event_state(event_id, int(event.get("cycle", 0))).get("progress", 0))
|
||||
|
||||
|
||||
func event_claimable(id: String) -> bool:
|
||||
var event := current_event()
|
||||
var entry: Dictionary = event_state(id, int(event.get("cycle", 0)))
|
||||
return int(entry.get("progress", 0)) >= 3 and not bool(entry.get("claimed", false))
|
||||
|
||||
|
||||
func claim_event(id: String) -> bool:
|
||||
var event := current_event()
|
||||
var cycle := int(event.get("cycle", 0))
|
||||
var entry: Dictionary = event_state(id, cycle)
|
||||
if int(entry.get("progress", 0)) < 3 or bool(entry.get("claimed", false)):
|
||||
return false
|
||||
entry["claimed"] = true
|
||||
var events: Dictionary = data.get("events", {})
|
||||
events[id] = entry
|
||||
data["events"] = events
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
return true
|
||||
|
||||
|
||||
func event_claimed(id: String) -> bool:
|
||||
var events: Dictionary = data.get("events", {})
|
||||
var entry = events.get(id, {})
|
||||
return typeof(entry) == TYPE_DICTIONARY and bool(entry.get("claimed", false))
|
||||
|
||||
|
||||
func claimed_event_frames() -> Array:
|
||||
var out: Array = []
|
||||
var events: Dictionary = data.get("events", {})
|
||||
for def in event_defs():
|
||||
var id := str(def.get("id", ""))
|
||||
var entry = events.get(id, {})
|
||||
if typeof(entry) == TYPE_DICTIONARY and bool(entry.get("claimed", false)):
|
||||
out.append(str(def.get("reward_frame", "")))
|
||||
return out
|
||||
|
||||
|
||||
func daily_data() -> Dictionary:
|
||||
if typeof(data.get("daily")) != TYPE_DICTIONARY:
|
||||
data["daily"] = _default_daily()
|
||||
@@ -275,6 +429,7 @@ func complete_daily(key: String, seconds: int = 0) -> bool:
|
||||
history.pop_front()
|
||||
daily["history"] = history
|
||||
data["daily"] = daily
|
||||
record_daily_event_progress(key)
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
return true
|
||||
|
||||
Reference in new issue
Block a user