- data/story/staffel.json: Aufstellung (Viertes Geschwader, Zweite Staffel, Staffelführer Dain, Kameraden Violet/Rhiannon/Ridoc/Sawyer/ Liam); StorySystem lädt sie (get_staffel, get_staffel_partner) - Ankunfts-Sequenz liest die Aufstellung sichtbar vor (daten-getrieben) - Sparring-Paarungen ziehen pro Kampf einen Staffel-Namen (NPC-Label + HUD-Balken); Staffel-Ansehen bleibt an Fraktion „staffel" gekoppelt - Buchführung: CR 5 nach CHANGEREQUESTS_DONE, ROADMAP nachgezogen Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
270 lines
10 KiB
GDScript
270 lines
10 KiB
GDScript
extends Node
|
||
## Story-Beats, Story-Flags und der 10-Tage-Fahrplan (Autoload, SPEC.md
|
||
## Abschnitt 8; v1-Ausbau Phase 1 nach STORY.md Abschnitt 5).
|
||
##
|
||
## Beat-Logik (Phase 4c): der Gauntlet-Klimax als geordnete Beat-Kette.
|
||
## Der aktuelle Beat liegt als Story-Flag im GameState (FLAG_GAUNTLET_BEAT)
|
||
## und reist damit im Spielstand mit. advance_gauntlet_beat() bewegt sich
|
||
## nur vorwärts entlang der Kette — der Wendepunkt ist unumkehrbar.
|
||
##
|
||
## Fahrplan (Phase 1 des v1-Ausbaus): data/story/days/day_01..10.json
|
||
## legen daten-getrieben fest, welche Räume pro Slot verfügbar sind,
|
||
## welche Szene erzwungen ist und wo der Tag endet (Schlafsaal bzw. an
|
||
## Imogen-Abenden ihr Zimmer — Letzteres greift erst ab dem Story-Flag
|
||
## imogen_nights_active, damit der Slice spielbar bleibt, bis Imogens
|
||
## Zimmer als Raum existiert).
|
||
##
|
||
## Messwerte (Phase 1): Wren-Vertrauen und Imogen-Offenheit (0–100),
|
||
## Cassian-Eskalationsstufe (0–3) und Cassian-Ausgang (heart/blade)
|
||
## liegen als Story-Flags im GameState und sind damit persistent; der
|
||
## Menschlichkeits-Messwert ist GameState.humanity (Klinge/Herz) und wird
|
||
## hier bewusst NICHT dupliziert.
|
||
##
|
||
## Der Zirkel (Phase 10, CR 2): Wahrheit-1-Fragmente liegen als
|
||
## Story-Flags mit Präfix w1_fragment_ (Wert = Muster-Board-Text). Der
|
||
## Zirkel-Fortschritt (0–100) errechnet sich aus Fragmenten (je 12),
|
||
## Xadens Muster-Bestätigung (+20, Flag zirkel_bestaetigt) und der
|
||
## anvertrauten Wahrheit 2 (+20, Beat truth_2_revealed) — er fließt als
|
||
## Daumen in die Bindungsqualität (DragonBondSystem). Der Gauntlet ist
|
||
## KEIN Gate: apply_w1_gauntlet_outcome() belohnt genug Fragmente mit
|
||
## Bestätigung + Fraktions-Bonus; mit zu wenigen IST der Gauntlet die
|
||
## Enthüllung.
|
||
|
||
signal gauntlet_beat_changed(new_beat: String)
|
||
signal story_meter_changed(meter: String, value: int)
|
||
|
||
const FLAG_GAUNTLET_BEAT := "gauntlet_beat"
|
||
const FLAG_TRUTH_3 := "truth_3_revealed"
|
||
const FLAG_IMOGEN_NIGHTS := "imogen_nights_active"
|
||
const FLAG_WREN_TRUST := "wren_trust"
|
||
const FLAG_IMOGEN_OPENNESS := "imogen_openness"
|
||
const FLAG_CASSIAN_ESCALATION := "cassian_escalation"
|
||
const FLAG_CASSIAN_OUTCOME := "cassian_outcome"
|
||
const FLAG_ZIRKEL_BESTAETIGT := "zirkel_bestaetigt"
|
||
const FLAG_W1_BESTAETIGT := "w1_bestaetigt"
|
||
const W1_FRAGMENT_PREFIX := "w1_fragment_"
|
||
const W1_CONFIRM_THRESHOLD := 3
|
||
const ZIRKEL_FRAGMENT_WEIGHT := 12
|
||
const ZIRKEL_BESTAETIGT_BONUS := 20
|
||
const ZIRKEL_TRUTH2_BONUS := 20
|
||
const WREN_TRUST_START := 50
|
||
const IMOGEN_OPENNESS_START := 60
|
||
const CASSIAN_ESCALATION_MAX := 3
|
||
const CASSIAN_OUTCOMES: Array[String] = ["none", "heart", "blade"]
|
||
const DAY_PLAN_PATH := "res://data/story/days/day_%02d.json"
|
||
const STAFFEL_PATH := "res://data/story/staffel.json"
|
||
const GAUNTLET_BEATS: Array[String] = [
|
||
"none",
|
||
"gauntlet_started",
|
||
"maren_intervention",
|
||
"maren_death",
|
||
"truth_1_revealed",
|
||
"truth_2_revealed",
|
||
"gauntlet_completed",
|
||
]
|
||
|
||
var _day_plans: Array[Dictionary] = []
|
||
var _staffel: Dictionary = {}
|
||
|
||
|
||
## Lädt den 10-Tage-Fahrplan aus data/story/days/ und die
|
||
## Staffel-Aufstellung (CR 5) aus data/story/staffel.json.
|
||
func _ready() -> void:
|
||
var staffel_file := FileAccess.open(STAFFEL_PATH, FileAccess.READ)
|
||
if staffel_file == null:
|
||
push_error("Staffel-Aufstellung nicht lesbar: %s" % STAFFEL_PATH)
|
||
else:
|
||
var staffel_parsed: Variant = JSON.parse_string(staffel_file.get_as_text())
|
||
staffel_file.close()
|
||
if staffel_parsed is Dictionary and staffel_parsed.get("kameraden") is Array:
|
||
_staffel = staffel_parsed
|
||
else:
|
||
push_error("Staffel-Aufstellung ist ungültig: %s" % STAFFEL_PATH)
|
||
for day in range(1, TimeSystem.MAX_DAYS + 1):
|
||
var path := DAY_PLAN_PATH % day
|
||
var file := FileAccess.open(path, FileAccess.READ)
|
||
if file == null:
|
||
push_error("Tagesplan fehlt: %s" % path)
|
||
_day_plans.append({})
|
||
continue
|
||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||
if parsed is Dictionary:
|
||
_day_plans.append(parsed)
|
||
else:
|
||
push_error("Tagesplan unlesbar: %s" % path)
|
||
_day_plans.append({})
|
||
|
||
|
||
## Liefert Tyrveils Staffel-Aufstellung (CR 5): Geschwader, Staffel,
|
||
## Staffelführer und die Kameraden-Liste aus data/story/staffel.json.
|
||
func get_staffel() -> Dictionary:
|
||
return _staffel
|
||
|
||
|
||
## Zieht eine zufällige Staffel-Kameradin/einen Kameraden — die
|
||
## Sparring-Paarungen kommen aus der eigenen Staffel (CR 5).
|
||
func get_staffel_partner() -> String:
|
||
var kameraden: Array = _staffel.get("kameraden", [])
|
||
if kameraden.is_empty():
|
||
return "Sparringspartner"
|
||
return str(kameraden.pick_random())
|
||
|
||
|
||
## Liefert den kompletten Tagesplan eines Tages (leer, wenn außerhalb).
|
||
func get_day_plan(day: int) -> Dictionary:
|
||
if day < 1 or day > _day_plans.size():
|
||
return {}
|
||
return _day_plans[day - 1]
|
||
|
||
|
||
## Liefert den Slot-Plan eines Tages ("morning"/"afternoon"/"evening").
|
||
func get_slot_plan(day: int, slot_id: String) -> Dictionary:
|
||
var slots: Dictionary = get_day_plan(day).get("slots", {})
|
||
return slots.get(slot_id, {})
|
||
|
||
|
||
## Prüft, ob ein Raum laut Fahrplan im Slot verfügbar ist.
|
||
func is_room_available(room_id: String, day: int, slot_id: String) -> bool:
|
||
var rooms: Array = get_slot_plan(day, slot_id).get("rooms", [])
|
||
return rooms.has(room_id)
|
||
|
||
|
||
## Liefert die im Slot erzwungene Szene ("" = keine).
|
||
func get_forced_scene(day: int, slot_id: String) -> String:
|
||
return str(get_slot_plan(day, slot_id).get("forced_scene", ""))
|
||
|
||
|
||
## Liefert den Ort, an dem der Tag endet: laut Fahrplan Imogens Zimmer an
|
||
## Imogen-Abenden — aber erst, wenn imogen_nights_active gesetzt ist
|
||
## (bis dahin bleibt der Schlafsaal das Tagesende, damit nichts blockiert).
|
||
func get_day_end_location(day: int) -> String:
|
||
var location := str(get_day_plan(day).get("day_end_location", "dormitory"))
|
||
if location == "imogen_room" and not bool(GameState.get_story_flag(FLAG_IMOGEN_NIGHTS, false)):
|
||
return "dormitory"
|
||
return location
|
||
|
||
|
||
## Zählt die gesammelten Wahrheit-1-Fragmente (Story-Flags mit Präfix
|
||
## w1_fragment_, leere Werte zählen nicht).
|
||
func get_w1_fragment_count() -> int:
|
||
var count := 0
|
||
for flag_name in GameState.story_flags:
|
||
if not str(flag_name).begins_with(W1_FRAGMENT_PREFIX):
|
||
continue
|
||
var value: Variant = GameState.story_flags[flag_name]
|
||
if value is String:
|
||
if not str(value).is_empty():
|
||
count += 1
|
||
elif bool(value):
|
||
count += 1
|
||
return count
|
||
|
||
|
||
## Liefert den Zirkel-Fortschritt 0–100 (dokumentierte Formel, siehe
|
||
## Klassen-Doku) — Daumen für die Bindungsqualität.
|
||
func get_zirkel_progress() -> int:
|
||
var progress := get_w1_fragment_count() * ZIRKEL_FRAGMENT_WEIGHT
|
||
if bool(GameState.get_story_flag(FLAG_ZIRKEL_BESTAETIGT, false)):
|
||
progress += ZIRKEL_BESTAETIGT_BONUS
|
||
if has_reached_beat("truth_2_revealed"):
|
||
progress += ZIRKEL_TRUTH2_BONUS
|
||
return clampi(progress, 0, 100)
|
||
|
||
|
||
## Wertet beim Gauntlet-Wendepunkt die Wahrheit-1-Sammlung aus (KEIN
|
||
## Gate): genug Fragmente = Bestätigung samt Fraktions-Bonus für die
|
||
## Gezeichneten (liefert true); mit zu wenigen ist der Gauntlet selbst
|
||
## die Enthüllung (liefert false, keine Strafe).
|
||
func apply_w1_gauntlet_outcome() -> bool:
|
||
if get_w1_fragment_count() < W1_CONFIRM_THRESHOLD:
|
||
return false
|
||
GameState.set_story_flag(FLAG_W1_BESTAETIGT, true)
|
||
FactionSystem.adjust_standing(FactionSystem.MARKED_FACTION_ID, 5)
|
||
return true
|
||
|
||
|
||
## Liefert Wrens Vertrauen (0–100, Start 50).
|
||
func get_wren_trust() -> int:
|
||
return int(GameState.get_story_flag(FLAG_WREN_TRUST, WREN_TRUST_START))
|
||
|
||
|
||
## Hebt oder senkt Wrens Vertrauen (Schutzentscheidungen, Eskorte).
|
||
func adjust_wren_trust(amount: int) -> void:
|
||
_set_meter(FLAG_WREN_TRUST, clampi(get_wren_trust() + amount, 0, 100))
|
||
|
||
|
||
## Liefert Imogens Offenheit (0–100, Start 60 — sinkt mit jedem
|
||
## verschwiegenen Geheimnis).
|
||
func get_imogen_openness() -> int:
|
||
return int(GameState.get_story_flag(FLAG_IMOGEN_OPENNESS, IMOGEN_OPENNESS_START))
|
||
|
||
|
||
## Hebt oder senkt Imogens Offenheit.
|
||
func adjust_imogen_openness(amount: int) -> void:
|
||
_set_meter(FLAG_IMOGEN_OPENNESS, clampi(get_imogen_openness() + amount, 0, 100))
|
||
|
||
|
||
## Liefert Cassians Eskalationsstufe (0–3).
|
||
func get_cassian_escalation() -> int:
|
||
return int(GameState.get_story_flag(FLAG_CASSIAN_ESCALATION, 0))
|
||
|
||
|
||
## Hebt Cassians Eskalationsstufe um eins (gedeckelt bei 3).
|
||
func escalate_cassian() -> void:
|
||
_set_meter(FLAG_CASSIAN_ESCALATION, clampi(get_cassian_escalation() + 1, 0, CASSIAN_ESCALATION_MAX))
|
||
|
||
|
||
## Liefert den Ausgang des Tag-9-Hinterhalts ("none"/"heart"/"blade").
|
||
func get_cassian_outcome() -> String:
|
||
return str(GameState.get_story_flag(FLAG_CASSIAN_OUTCOME, "none"))
|
||
|
||
|
||
## Setzt den Ausgang des Tag-9-Hinterhalts; unbekannte Werte werden mit
|
||
## Warnung ignoriert. Der Ausgang fließt später als Daumen ins Dreschen.
|
||
func set_cassian_outcome(outcome: String) -> void:
|
||
if not CASSIAN_OUTCOMES.has(outcome):
|
||
push_warning("Unbekannter Cassian-Ausgang: %s" % outcome)
|
||
return
|
||
GameState.set_story_flag(FLAG_CASSIAN_OUTCOME, outcome)
|
||
|
||
|
||
## Schreibt einen Messwert als Story-Flag und meldet die Änderung.
|
||
func _set_meter(flag_name: String, value: int) -> void:
|
||
GameState.set_story_flag(flag_name, value)
|
||
story_meter_changed.emit(flag_name, value)
|
||
|
||
|
||
## Liefert den aktuellen Gauntlet-Beat ("none", wenn noch keiner erreicht).
|
||
func get_gauntlet_beat() -> String:
|
||
return str(GameState.get_story_flag(FLAG_GAUNTLET_BEAT, "none"))
|
||
|
||
|
||
## Gibt zurück, ob die Kette den angegebenen Beat erreicht oder
|
||
## überschritten hat.
|
||
func has_reached_beat(beat: String) -> bool:
|
||
return GAUNTLET_BEATS.find(get_gauntlet_beat()) >= GAUNTLET_BEATS.find(beat)
|
||
|
||
|
||
## Setzt das Wahrheit-3-Flag: Die Drachen wählen Gezeichnete bewusst —
|
||
## Wiedererkennen statt Zufall (STORY.md Abschnitt 3, erfahrbar beim
|
||
## Dreschen).
|
||
func reveal_truth_3() -> void:
|
||
GameState.set_story_flag(FLAG_TRUTH_3, true)
|
||
|
||
|
||
## Gibt zurück, ob Wahrheit 3 bereits enthüllt wurde.
|
||
func has_truth_3() -> bool:
|
||
return bool(GameState.get_story_flag(FLAG_TRUTH_3, false))
|
||
|
||
|
||
## Rückt auf einen späteren Beat der Kette vor; Rückwärts-Sprünge und
|
||
## unbekannte Beats werden ignoriert (mit Warnung).
|
||
func advance_gauntlet_beat(new_beat: String) -> void:
|
||
var new_index := GAUNTLET_BEATS.find(new_beat)
|
||
if new_index < 0:
|
||
push_warning("Unbekannter Gauntlet-Beat: %s" % new_beat)
|
||
return
|
||
if new_index <= GAUNTLET_BEATS.find(get_gauntlet_beat()):
|
||
return
|
||
GameState.set_story_flag(FLAG_GAUNTLET_BEAT, new_beat)
|
||
gauntlet_beat_changed.emit(new_beat)
|