Deveras Taktiktisch als Klick-Karte statt Menue: zehn Kanon-Regionen aus data/lessons/battle_map.json liegen fraktionsgefaerbt an relativen Ankern, ein Zeitbalken laeuft mit, und die Truppenbewegungen wandern als Pfeile ueber das Brett. lesson_teacher kennt den neuen Beat-Typ map_question: richtig gibt +1 Verstand und +1 Fachwissen (optional ein Wahrheits-Fragment), falsch kostet Staffel-Ansehen — Devera benennt den Fehler offen, dann liefert ein namentlicher Mitschueler die richtige Antwort nach. Schweigen bleibt folgenlos. Kanon-Zeitfilter Buch 1: offener Feind ist Poromiel mit seinen Greifen. Die Veneni werden in keinem sichtbaren Text benannt und erscheinen nur als unerklaerte Anomalien, die sich mit Wahrheit 1 verzahnen. Verifiziert mit dev_cr11_probe (18/18) und einem Boot-Check ueber sieben Szenen; Sonde vor dem Commit geloescht. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
193 lines
7.7 KiB
GDScript
193 lines
7.7 KiB
GDScript
extends StaticBody3D
|
||
## Interaktiver Unterricht als Szene (Phase 9, CR 4 — ersetzt für die
|
||
## Wissens-Fächer das Stationsmodell; SPEC §5.1/§6, Inhalte aus WELT.md).
|
||
##
|
||
## Der Professor steht im Raum; interact in Reichweite startet die
|
||
## Unterrichts-Szene aus lesson_path (data/lessons/*.json): Tyrveil wird
|
||
## auf den Sitzplatz (sit_marker_path) gesetzt, die Steuerung ist
|
||
## gesperrt, und die Mini-Vorlesung läuft über die Sprechblasen —
|
||
## Lehrer-Beats, Zwischenrufe des Nachbarn (neighbor_path) und mehrere
|
||
## Timed Events (~7 s, lesson_quiz.tscn): „nichts sagen" + vier
|
||
## Antworten, eine richtig. Richtig = +1 Verstand + 1 Fachwissen
|
||
## (knowledge_flag der Lektion; Fragen können zusätzlich per
|
||
## fragment_flag/fragment_text ein Wahrheit-1-Fragment aufs Muster-Board
|
||
## legen — Gefechtskunde). Falsch = spöttischer Nachbar-Kommentar und
|
||
## −1 Staffel-Ansehen (FactionSystem, Fraktion "staffel"). Schweigen =
|
||
## sicher, kein Gewinn. Gefechtskunde kennt zusätzlich map_question-Beats
|
||
## (CR 11): Deveras Taktiktisch mit animierten Truppenbewegungen, auf dem
|
||
## die Region angeklickt wird; Auswertung wie oben, bei Fehler benennt
|
||
## Devera ihn offen und ein Mitschüler antwortet richtig nach. Das
|
||
## Durchspielen der Szene verbraucht den
|
||
## Tages-Slot; ist der Slot verbraucht, gibt es nur die Absage-Zeile.
|
||
## Reine Körper-Stationen (Sparring/Ausweichen) bleiben Walk-up.
|
||
|
||
const QUIZ_SCENE := preload("res://scenes/ui/lesson_quiz.tscn")
|
||
const MAP_SCENE := preload("res://scenes/ui/battle_map.tscn")
|
||
const STAFFEL_FACTION_ID := "staffel"
|
||
const CLASSMATE_NAMES := {
|
||
"violet": "Violet",
|
||
"rhiannon": "Rhiannon",
|
||
"ridoc": "Ridoc",
|
||
"sawyer": "Sawyer",
|
||
"liam": "Liam",
|
||
}
|
||
const DEFAULT_SILENT_LINE := "Schweigen. Kein Fehler — aber auch keine Antwort. Weiter."
|
||
|
||
@export_file("*.json") var lesson_path: String
|
||
@export var neighbor_path: NodePath
|
||
@export var sit_marker_path: NodePath
|
||
@export var exhausted_line := "Für heute reicht es — der Unterricht wartet morgen wieder."
|
||
|
||
var _is_player_in_range := false
|
||
var _is_running := false
|
||
var _lesson: Dictionary = {}
|
||
|
||
@onready var _prompt_label: Label3D = $PromptLabel
|
||
@onready var _interaction_area: Area3D = $InteractionArea
|
||
@onready var _bubble: Node3D = $SpeechBubble
|
||
@onready var _neighbor_bubble: Node3D = get_node(neighbor_path).get_node("SpeechBubble")
|
||
@onready var _sit_marker: Node3D = get_node(sit_marker_path)
|
||
|
||
|
||
## Lädt die Lektion und verbindet die Reichweiten-Signale.
|
||
func _ready() -> void:
|
||
_interaction_area.body_entered.connect(_on_body_entered)
|
||
_interaction_area.body_exited.connect(_on_body_exited)
|
||
var file := FileAccess.open(lesson_path, FileAccess.READ)
|
||
if file == null:
|
||
push_error("Lektion nicht lesbar: %s" % lesson_path)
|
||
return
|
||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||
file.close()
|
||
if parsed is Dictionary and parsed.get("beats") is Array:
|
||
_lesson = parsed
|
||
else:
|
||
push_error("Lektion ist ungültig: %s" % lesson_path)
|
||
|
||
|
||
## Startet den Unterricht bei interact in Reichweite, außerhalb laufender
|
||
## Dialoge und wenn nicht schon eine Stunde läuft.
|
||
func _unhandled_input(event: InputEvent) -> void:
|
||
if not _is_player_in_range or _is_running:
|
||
return
|
||
if DialogueSystem.is_dialogue_active:
|
||
return
|
||
if not event.is_action_pressed("interact"):
|
||
return
|
||
_run_lesson()
|
||
|
||
|
||
## Spielt die komplette Unterrichts-Szene als Coroutine: hinsetzen,
|
||
## Vorlesungs-Beats, Timed Events, Auswertung, Slot-Verbrauch.
|
||
func _run_lesson() -> void:
|
||
if _lesson.is_empty():
|
||
return
|
||
if TimeSystem.is_current_slot_used:
|
||
_bubble.show_line(exhausted_line)
|
||
return
|
||
var player := get_tree().get_first_node_in_group("player")
|
||
if player == null:
|
||
return
|
||
_is_running = true
|
||
player.set_control_locked(true)
|
||
player.global_position = _sit_marker.global_position
|
||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||
var quiz: CanvasLayer = QUIZ_SCENE.instantiate()
|
||
add_child(quiz)
|
||
var map: CanvasLayer = MAP_SCENE.instantiate()
|
||
add_child(map)
|
||
var correct_count := 0
|
||
var knowledge_flag := str(_lesson.get("knowledge_flag", ""))
|
||
for beat in _lesson.get("beats", []):
|
||
if beat.has("question"):
|
||
correct_count += await _run_question(quiz, beat["question"], knowledge_flag)
|
||
elif beat.has("map_question"):
|
||
correct_count += await _run_map_question(map, beat["map_question"], knowledge_flag)
|
||
elif beat.has("nachbar"):
|
||
await _say(_neighbor_bubble, str(beat["nachbar"]))
|
||
else:
|
||
await _say(_bubble, str(beat.get("teacher", "")))
|
||
TimeSystem.try_spend_slot()
|
||
var end_line := str(_lesson.get("end_line", "Der Unterricht ist beendet."))
|
||
if correct_count > 0:
|
||
end_line += " (Verstand +%d, Fachwissen +%d)" % [correct_count, correct_count]
|
||
await _say(_bubble, end_line)
|
||
quiz.queue_free()
|
||
map.queue_free()
|
||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||
player.set_control_locked(false)
|
||
_is_running = false
|
||
|
||
|
||
## Spielt ein Timed Event und wertet es aus; liefert 1 bei richtiger
|
||
## Antwort, sonst 0.
|
||
func _run_question(quiz: CanvasLayer, question: Dictionary, knowledge_flag: String) -> int:
|
||
var index: int = await quiz.ask(question)
|
||
if index == int(question.get("correct", 0)):
|
||
GameState.increase_stat("intellect", 1)
|
||
if not knowledge_flag.is_empty():
|
||
GameState.set_story_flag(knowledge_flag, int(GameState.get_story_flag(knowledge_flag, 0)) + 1)
|
||
if question.has("fragment_flag"):
|
||
GameState.set_story_flag(str(question["fragment_flag"]), str(question.get("fragment_text", "")))
|
||
await _say(_bubble, str(question.get("correct_line", "Richtig.")))
|
||
return 1
|
||
if index < 0:
|
||
await _say(_bubble, str(question.get("silent_line", DEFAULT_SILENT_LINE)))
|
||
return 0
|
||
FactionSystem.adjust_standing(STAFFEL_FACTION_ID, -1)
|
||
await _say(_neighbor_bubble, str(question.get("mock_line", "Ein Kichern aus der Reihe hinter dir.")))
|
||
return 0
|
||
|
||
|
||
## Spielt eine Karten-Runde auf dem Taktiktisch und wertet sie aus
|
||
## (CR 11); liefert 1 bei richtiger Region, sonst 0. Bei falscher Antwort
|
||
## benennt die Professorin den Fehler offen und ein Mitschüler liefert
|
||
## die richtige Antwort nach, damit die Klasse lebendig wirkt.
|
||
func _run_map_question(map: CanvasLayer, question: Dictionary, knowledge_flag: String) -> int:
|
||
var region_id: String = await map.ask(question)
|
||
if region_id == str(question.get("correct", "")):
|
||
GameState.increase_stat("intellect", 1)
|
||
if not knowledge_flag.is_empty():
|
||
GameState.set_story_flag(knowledge_flag, int(GameState.get_story_flag(knowledge_flag, 0)) + 1)
|
||
if question.has("fragment_flag"):
|
||
GameState.set_story_flag(str(question["fragment_flag"]), str(question.get("fragment_text", "")))
|
||
await _say(_bubble, str(question.get("correct_line", "Richtig.")))
|
||
return 1
|
||
if region_id.is_empty():
|
||
await _say(_bubble, str(question.get("silent_line", DEFAULT_SILENT_LINE)))
|
||
return 0
|
||
FactionSystem.adjust_standing(STAFFEL_FACTION_ID, -1)
|
||
await _say(_bubble, str(question.get("wrong_line", "Falsch. Wer korrigiert ihn?")))
|
||
await _say(_neighbor_bubble, _classmate_line(question))
|
||
return 0
|
||
|
||
|
||
## Baut die Korrektur-Zeile eines Mitschülers; ein leerer classmate-Name
|
||
## bleibt bewusst namenlos („jemand weiter vorn").
|
||
func _classmate_line(question: Dictionary) -> String:
|
||
var line := str(question.get("classmate_line", ""))
|
||
if line.is_empty():
|
||
return ""
|
||
var speaker := str(question.get("classmate", ""))
|
||
var name: String = CLASSMATE_NAMES.get(speaker, "Jemand weiter vorn")
|
||
return "%s: „%s\"" % [name, line]
|
||
|
||
|
||
## Zeigt eine Zeile über der Blase und wartet ihr Ende ab.
|
||
func _say(bubble: Node3D, text: String) -> void:
|
||
if text.is_empty():
|
||
return
|
||
bubble.show_line(text)
|
||
await bubble.line_finished
|
||
|
||
|
||
## Blendet den Prompt ein, sobald der Spieler die Reichweite betritt.
|
||
func _on_body_entered(_body: Node3D) -> void:
|
||
_is_player_in_range = true
|
||
_prompt_label.visible = true
|
||
|
||
|
||
## Blendet den Prompt aus, wenn der Spieler die Reichweite verlässt.
|
||
func _on_body_exited(_body: Node3D) -> void:
|
||
_is_player_in_range = false
|
||
_prompt_label.visible = false
|