Remove request cancellation and protect the final mother dialogue

This commit is contained in:
Codex
2026-10-30 12:49:18 +02:00
parent 2476242d27
commit aa45c6c0bd
9 changed files with 137 additions and 53 deletions
+20 -19
View File
@@ -56,7 +56,6 @@ var task_label: Label
var title_label: Label
var phase_label: Label
var busy_bar: ProgressBar
var cancel_button: Button
var last_caption: Label
var voice: AudioStreamPlayer
var soundscape: Node
@@ -548,21 +547,34 @@ func advance() -> void:
refresh_commands()
"hum":
fired.hum = elapsed
# The final reaction owns the rest of the call. Stop pending requests
# before speaking, so neither a late reply nor a click can replace it.
events.clear()
busy = {}
soundscape.cancel_task()
hum.play()
say("hum")
refresh_commands()
"dialogue":
var event: Dictionary = events.pop_front()
if busy.is_empty() and not fired.has("hum"): say(event.line)
"reply":
replied = true
say(busy.response)
# Leave a clean breath before the fixed final line. Katya may be cut
# short by that line, but do not begin a mother reply that cannot fit.
if elapsed + voice_length(busy.response) + 0.2 <= float(story.timeline.hum):
say(busy.response)
else:
# An unheard answer must not grant knowledge or items just before
# the final reaction. That reaction will interrupt the request.
busy_end = maxf(busy_end,float(story.timeline.hum))
"finish": finish_task()
elapsed = target
soundscape.advance(elapsed, place)
refresh_live()
func command_allowed(action: Dictionary) -> bool:
if not running or chapter == 1 or elapsed >= float(story.timeline.impact) or not busy.is_empty(): return false
if not running or chapter == 1 or fired.has("hum") or elapsed >= float(story.timeline.hum) or not busy.is_empty(): return false
if action.get("once", false) and done.has(action.id): return false
if action.has("places") and place not in action.places: return false
if action.get("power", false) and elapsed >= float(story.timeline.power): return false
@@ -601,7 +613,7 @@ func choose_action(id: String) -> void:
busy = selected.duplicate(true)
busy_start = elapsed
busy_end = elapsed + action_duration(selected)
reply_at = maxf(elapsed + voice_length(selected.request) + 0.15, busy_end - voice_length(selected.response))
reply_at = maxf(elapsed + voice_length(selected.request) + 0.2, busy_end - voice_length(selected.response))
replied = false
soundscape.schedule_task(id, elapsed + voice_length(selected.request) + 0.12, reply_at)
say(selected.request)
@@ -626,16 +638,6 @@ func finish_task() -> void:
save_progress()
refresh()
func cancel_task() -> void:
if not running or busy.is_empty(): return
if not speech_finished(): return
busy = {}
soundscape.cancel_task()
voice.stop()
say("cancel")
system_caption("Мама остановилась. Потраченное время не вернуть.")
refresh_commands()
func save_progress() -> void:
if qa_mode or test_mode: return
var result := Profile.write_profile(SAVE_PATH, facts, endings, completed)
@@ -727,13 +729,12 @@ func refresh() -> void:
func refresh_commands() -> void:
if not is_instance_valid(command_list): return
clear_children(command_list)
cancel_button.visible = running and not busy.is_empty()
cancel_button.disabled = not speech_finished()
if not running:
var silence: Label = stage.centered("Линия молчит.",20,MUTED)
silence.custom_minimum_size = Vector2(300,60)
command_list.add_child(silence)
return
if fired.has("hum"): return
if chapter == 1:
var note: Label = stage.centered("Вы просто разговариваете.\nКажется, на всё ещё есть время.",19,Color("91839f"))
note.custom_minimum_size = Vector2(400,85)
@@ -756,12 +757,11 @@ func speech_finished() -> bool:
return elapsed >= speech_until and (not voice_enabled or not voice.playing)
func can_respond() -> bool:
return running and chapter != 1 and events.is_empty() and speech_finished()
return running and chapter != 1 and not fired.has("hum") and busy.is_empty() and events.is_empty() and speech_finished()
func update_choice_state() -> void:
for child in command_list.get_children():
if child is Button: child.disabled = not can_respond()
cancel_button.disabled = not speech_finished()
func refresh_live() -> void:
if running and fired.has("alarm"):
@@ -775,7 +775,7 @@ func refresh_live() -> void:
held.append({"keys": "ключи", "lamp": "фонарь", "spare": "запасной ключ", "connected": "телефон на полке"}[key])
objects_label.text = "У мамы: " + (", ".join(held) if not held.is_empty() else "телефон")
task_label.text = str(busy.label) if not busy.is_empty() else ("Дождись окончания реплики" if not can_respond() else "Что сказать маме?")
if not running: task_label.text = ""
if not running or fired.has("hum"): task_label.text = ""
if chapter == 1: task_label.text = ""
update_choice_state()
busy_bar.visible = not busy.is_empty()
@@ -803,6 +803,7 @@ func voice_length(id: String) -> float:
return stream.get_length() if stream != null else maxf(2.0, str(story.lines[id].text).length() / 13.0)
func say(id: String) -> void:
if running and fired.has("hum") and id != "hum": return
var entry: Dictionary = story.lines[id]
heard.append(id)
stage.speaker = entry.speaker
+56 -17
View File
@@ -17,7 +17,7 @@ func check_clocks(expected: String, context: String) -> void:
check(game.stage.mother_clock.text == expected, "Mother call duration " + context)
func click(id: String) -> void:
var gameplay := id in ["question", "cancel"]
var gameplay := id == "question"
for action in game.story.actions:
if action.id == id: gameplay = true
if gameplay: wait_for_speech()
@@ -145,6 +145,25 @@ func realtime_check() -> void:
game.qa_mode = true
print("PHONE_REALTIME complete")
func realtime_final_check() -> void:
start(2)
wait_for_speech()
at(float(game.story.timeline.hum)-0.5)
click("keys_search")
var finished_at: Array[float] = []
var record_final := func():
if game.running and game.heard[-1] == "hum": finished_at.append(game.elapsed)
game.voice.finished.connect(record_final)
await game.get_tree().create_timer(10.0).timeout
game.voice.finished.disconnect(record_final)
check(game.impacted and game.heard[-1] == "hum", "Real late Katya request ends with mother's final line")
check(finished_at.size() == 1, "Real final mother recording finishes without interruption")
if finished_at.size() == 1:
var gap := float(game.story.timeline.impact)-finished_at[0]
check(gap >= 5.0, "Real final line still leaves five seconds before explosion")
print("PHONE_FINAL_REALTIME gap=",gap)
check("keys_search_m" not in game.heard and not game.items.has("keys"), "Real deferred reply cannot replace final mother line")
func run(target: Node) -> void:
game = target
DirAccess.make_dir_recursive_absolute(directory())
@@ -292,11 +311,14 @@ func run(target: Node) -> void:
check(game.action_button("close_memory") != null, "Notebook opens from call screen")
click("close_memory")
click("keys_search")
check(game.cancel_button.disabled, "Cancellation cannot interrupt the spoken request")
game.cancel_task()
check(not game.busy.is_empty(), "Direct cancel rejected while speaking")
check(game.action_button("cancel") == null, "No change-answer control")
game.choose_action("lamp_search")
check(game.busy.get("id") == "keys_search", "Chosen request cannot be replaced while speaking")
at(game.speech_until + 0.1)
game.choose_action("lamp_search")
check(game.busy.get("id") == "keys_search" and not game.can_respond(), "Chosen request stays locked during the search")
at(game.reply_at + 0.01)
check(game.cancel_button.disabled, "Mother's answer cannot be interrupted")
check(not game.can_respond(), "Mother's answer cannot be interrupted by a choice")
at(game.busy_end + 0.12)
check(game.can_respond(), "Next choices enabled after response and task completion")
@@ -322,9 +344,8 @@ func run(target: Node) -> void:
perform("keys_search")
check(game.soundscape.history.any(func(cue): return cue.id == "keys"), "Key sound follows actual search")
click("lamp_search")
wait_for_speech()
click("cancel")
check(not game.soundscape.queue.any(func(cue): return cue.task), "Cancel discards pending action sounds")
at(float(game.story.timeline.hum) + 0.01)
check(not game.soundscape.queue.any(func(cue): return cue.task), "Final reaction discards pending action sounds")
# Every redial repeats the same external world, including the first call.
for number in range(1, 11):
start(number)
@@ -449,17 +470,34 @@ func run(target: Node) -> void:
at(92)
check(game.outcome == "landing", "Late frame resolves movement before impact")
# The final mother line always wins, including a request spoken by Katya
# at the boundary and a queued answer that would overlap the ending.
for number in range(2,11):
start(number)
wait_for_speech()
at(warning_at - 0.5)
click("keys_search")
check(game.stage.speaker == "Катя" and game.speech_until > warning_at, "Late Katya request crosses final cue: " + str(number))
at(warning_at + 0.01)
check(game.heard[-1] == "hum" and game.stage.speaker == "Мама", "Mother interrupts Katya at final cue: " + str(number))
check(game.busy.is_empty() and game.events.is_empty() and game.command_list.get_child_count() == 0, "Final sequence clears pending choices: " + str(number))
game.choose_action("speak_love")
game.say("here")
at(89.99)
check(game.heard[-1] == "hum" and game.heard.count("hum") == 1 and not game.can_respond(), "Nothing replaces the final line: " + str(number))
finish("flat")
check(not game.items.has("keys") and not game.facts.has("keys"), "Interrupted request grants nothing: " + str(number))
start(2)
wait_for_speech()
var search: Dictionary = game.story.actions.filter(func(action): return action.id == "keys_search")[0]
at(warning_at - game.action_duration(search) + game.voice_length(search.response)*0.5)
click("keys_search")
at(8)
click("cancel")
at(21)
check(not game.facts.has("keys") and not game.items.has("keys"), "Cancelled search grants nothing")
check(game.elapsed >= 21, "Cancellation never refunds time")
at(89)
click("keys_search")
check(game.reply_at < warning_at and game.busy_end > warning_at, "Mother reply would overlap the final cue")
at(game.reply_at + 0.01)
check(search.response not in game.heard, "Do not start a mother reply that cannot finish before the final phrase")
at(89.99)
check(game.heard[-1] == "hum" and not game.items.has("keys"), "Skipped reply cannot overtake final phrase or grant an item")
finish("flat")
check(not game.items.has("keys"), "Impact rejects unfinished search")
start(3)
perform("inner")
@@ -499,7 +537,7 @@ func run(target: Node) -> void:
# A late frame cannot complete a task after the impact. Old callbacks and
# popup buttons cannot apply a task twice.
start(10, 2)
at(82)
at(80)
click("safe")
at(92)
check(game.outcome == "flat" and not game.items.has("spare"), "Low-FPS deadline wins over pending safe")
@@ -586,6 +624,7 @@ func run(target: Node) -> void:
click("resume")
check(game.menu_screen.is_empty() and game.action_button("next") != null, "Menu returns to the completed call outcome")
game.qa_mode = true
await realtime_final_check()
if "--phone-real-time" in OS.get_cmdline_user_args():
await realtime_check()
var file := FileAccess.open(directory().path_join("phone-result.json"), FileAccess.WRITE)
-4
View File
@@ -115,9 +115,6 @@ func build(target: Node) -> void:
fill.content_margin_bottom = 0
game.busy_bar.add_theme_stylebox_override("fill",fill)
center_region.add_child(game.busy_bar)
game.cancel_button = chip("Изменить просьбу", "cancel", game.cancel_task)
game.cancel_button.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
center_region.add_child(game.cancel_button)
choice_scroll = ScrollContainer.new()
choice_scroll.custom_minimum_size.y = 300
choice_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
@@ -254,7 +251,6 @@ func begin_dial() -> void:
game.last_caption.text = ""
game.task_label.text = "Соединение…"
game.busy_bar.visible = false
game.cancel_button.visible = false
game.clear_children(game.transcript)
game.clear_children(game.command_list)
update(0.01)