Reset phone-game progress on every launch

This commit is contained in:
Codex
2026-10-30 17:31:47 +02:00
parent b572e0bf50
commit d0e3a8d551
7 changed files with 120 additions and 40 deletions
+17 -16
View File
@@ -4,7 +4,6 @@ const Profile = preload("res://scripts/profile.gd")
const Soundscape = preload("res://scripts/phone_soundscape.gd")
const PhoneStage = preload("res://scripts/phone_stage.gd")
const UI_FONT = preload("res://assets/fonts/Arimo-Bold.tres")
const SAVE_PATH := "user://profile/phone_memory.cfg"
const BG := Color("0b0a12")
const CARD := Color("1c1826")
const INK := Color("eee9dd")
@@ -17,6 +16,9 @@ var story: Dictionary
var facts: Dictionary = {}
var endings: Dictionary = {}
var completed := 0
# Progress lives only for this application run. Scene tests use their own
# working dictionaries and cannot contaminate the normal sequence of calls.
var session_progress: Dictionary = {"facts": {}, "endings": {}, "loops": 0}
var chapter := 1
var test_mode := false
var qa_mode := false
@@ -85,21 +87,22 @@ func _ready() -> void:
story = JSON.parse_string(FileAccess.get_file_as_string("res://data/phone_story.json"))
voice_levels = JSON.parse_string(FileAccess.get_file_as_string("res://data/voice_levels.json"))
qa_mode = "--phone-qa" in OS.get_cmdline_user_args()
if not qa_mode:
var saved := Profile.read_profile(SAVE_PATH, story.facts, story.endings)
facts = saved.facts
endings = saved.endings
completed = mini(saved.loops, 10)
make_audio()
make_ui()
show_menu()
if qa_mode:
call_deferred("run_qa")
elif "--phone-session-qa" in OS.get_cmdline_user_args():
call_deferred("run_session_qa")
func run_qa() -> void:
var qa = load("res://scripts/phone_qa.gd").new()
await qa.run(self)
func run_session_qa() -> void:
var qa = load("res://scripts/phone_session_qa.gd").new()
await qa.run(self)
func style(color: Color, border: Color = Color.TRANSPARENT, radius: int = 16) -> StyleBoxFlat:
var box := StyleBoxFlat.new()
box.bg_color = color
@@ -360,8 +363,8 @@ func _unhandled_key_input(event: InputEvent) -> void:
show_menu()
func continuation_chapter() -> int:
# Old profiles without the new conversation must hear it, not receive an
# invented memory. Existing discoveries and completed-call count stay intact.
# A continuation needs the first conversation's setup; the call number
# alone must never create knowledge of the letter.
if not facts.has("key_letter") and not facts.has("key_custody"): return 1
return mini(completed+1,10)
@@ -420,7 +423,7 @@ func show_settings() -> void:
func show_test_menu() -> void:
var box := menu_page("testing")
box.add_child(stage.centered("Проверка сцен",34,INK))
box.add_child(label("Отдельная сессия для тестирования. Основное сохранение не меняется.", 20, MUTED))
box.add_child(label("Отдельная проверка. Память основного прохождения не меняется.", 20, MUTED))
var choices := OptionButton.new()
choices.custom_minimum_size.y = 48
for entry in story.chapters:
@@ -464,12 +467,11 @@ func dial_call(number: int, testing: bool, knowledge: int = 1, animate_in_qa: bo
func begin_call(number: int, testing: bool, knowledge: int = 1, retained_facts: Variant = null) -> void:
dial_epoch += 1
dialing = false
# A test never writes the normal profile, including learned facts.
# Restore this run's normal progress; never reload a previous launch's file.
if not qa_mode:
var saved := Profile.read_profile(SAVE_PATH, story.facts, story.endings)
facts = saved.facts
endings = saved.endings
completed = mini(saved.loops, 10)
facts = session_progress.facts.duplicate()
endings = session_progress.endings.duplicate()
completed = mini(session_progress.loops, 10)
test_mode = testing
if retained_facts != null: facts = retained_facts.duplicate()
if testing and knowledge == 0: facts = {}
@@ -713,8 +715,7 @@ func finish_task() -> void:
func save_progress() -> void:
if qa_mode or test_mode: return
var result := Profile.write_profile(SAVE_PATH, facts, endings, completed)
if result != OK: system_caption("Не удалось сохранить память на диске.")
session_progress = {"facts": facts.duplicate(), "endings": endings.duplicate(), "loops": completed}
func strike() -> void:
if impacted: return