Phase 4a: Unterrichts-Stationen, FactionSystem, Permadeath-Toggle
- training_station.gd: drei Stationen (Kampftraining -> Kraft, Landnavigation -> Schnelligkeit im Reiterquadranten; Geschichte & RSC -> Verstand im Klassenraum), je +2 auf den Stat (an STAT_MAX geklemmt), Rueckmeldung per Sprechblase, Doppel-Eingabe-Schutz - TimeSystem.try_spend_slot(): erster echter Verbraucher von advance_slot() - Vormittag/Nachmittag ruecken vor, der Abend wird als verbraucht markiert und blockiert weitere Aktivitaeten bis zum Schlafsaal; Slot-Freigabe bei Slot-Wechsel/Reset - FactionSystem als Fassade ueber neues gespeichertes GameState.faction_standings (-100..100, Signal faction_standing_changed), Fraktions-ID gezeichnete; Story-Logik folgt in 4b/4c - Permadeath-Toggle im Hauptmenue (fokus-navigierbar, Text synchron); GameState.reset() laesst is_permadeath_enabled bewusst unangetastet (Menue-Option), Save/Load stellt den Zustand wieder her - Debug-Overlay: Gezeichnete-Standing sichtbar, F9/F10 verschieben es testweise (reine Overlay-Debug-Hilfe ohne Input-Action) - Headless verifiziert (29 Checks): Slot-Kette Vormittag->Nachmittag-> Abend->blockiert->Schlafen, Stat-Zuwaechse aller drei Stationen, Faction-Signal + Save/Load-Roundtrip, Toggle inkl. Reset- und Persistenz-Semantik Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
2ee3c3f782
commit
ef60c96735
10 changed files with 345 additions and 10 deletions
|
|
@ -1,7 +1,28 @@
|
|||
extends Node
|
||||
## Squad-Ansehen und Fraktions-Standing (Autoload, SPEC.md Abschnitte 6 und 8).
|
||||
## Zugriffs-Fassade für Fraktions-Standings (Autoload, SPEC.md Abschnitte
|
||||
## 6 und 8).
|
||||
##
|
||||
## Verwaltet ab Phase 4 das Ansehen im Squad sowie das Standing bei der
|
||||
## Fraktion der Gezeichneten, u. a. geprägt durch die Klinge-↔-Herz-Achse
|
||||
## nach Marens Tod (STORY.md Abschnitt 6). Phase 0: leeres Skelett ohne
|
||||
## Logik.
|
||||
## Die Standing-Daten liegen wie Beziehungen und Story-Flags im GameState
|
||||
## (faction_standings) und werden dort gespeichert und geladen; diese
|
||||
## Fassade folgt dem RelationshipSystem-Muster. Wertebereich -100..100.
|
||||
## Änderungen meldet GameState.faction_standing_changed. Fraktions-IDs
|
||||
## sind snake_case-Strings; die Gezeichneten laufen unter
|
||||
## MARKED_FACTION_ID. Story-Logik, die das Standing verschiebt, folgt in
|
||||
## Phase 4b/4c.
|
||||
|
||||
const MARKED_FACTION_ID := "gezeichnete"
|
||||
|
||||
|
||||
## Liefert das Standing (-100..100) einer Fraktion, 0 für unbekannte.
|
||||
func get_standing(faction_id: String) -> int:
|
||||
return GameState.get_faction_standing(faction_id)
|
||||
|
||||
|
||||
## Setzt das Standing absolut (geklemmt auf -100..100).
|
||||
func set_standing(faction_id: String, value: int) -> void:
|
||||
GameState.set_faction_standing(faction_id, value)
|
||||
|
||||
|
||||
## Verschiebt das Standing relativ um amount (geklemmt auf -100..100).
|
||||
func adjust_standing(faction_id: String, amount: int) -> void:
|
||||
GameState.adjust_faction_standing(faction_id, amount)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ extends Node
|
|||
|
||||
signal blade_heart_tone_changed(new_tone: int)
|
||||
signal relationship_changed(npc_id: String, new_value: int)
|
||||
signal faction_standing_changed(faction_id: String, new_value: int)
|
||||
|
||||
const STAT_MIN := 0
|
||||
const STAT_MAX := 100
|
||||
|
|
@ -32,10 +33,13 @@ var humanity := 0
|
|||
var relationships: Dictionary = {}
|
||||
var completed_dialogues: Dictionary = {}
|
||||
var story_flags: Dictionary = {}
|
||||
var faction_standings: Dictionary = {}
|
||||
var is_permadeath_enabled := true
|
||||
|
||||
|
||||
## Setzt alle Werte auf die Startwerte eines neuen Spiels zurück.
|
||||
## is_permadeath_enabled bleibt bewusst unangetastet: Der Toggle ist eine
|
||||
## Menü-Option und soll ein neues Spiel überleben.
|
||||
func reset() -> void:
|
||||
strength = DEFAULT_STRENGTH
|
||||
agility = DEFAULT_AGILITY
|
||||
|
|
@ -45,7 +49,7 @@ func reset() -> void:
|
|||
relationships.clear()
|
||||
completed_dialogues.clear()
|
||||
story_flags.clear()
|
||||
is_permadeath_enabled = true
|
||||
faction_standings.clear()
|
||||
blade_heart_tone_changed.emit(blade_heart_tone)
|
||||
|
||||
|
||||
|
|
@ -124,6 +128,25 @@ func get_story_flag(flag_name: String, default: Variant = null) -> Variant:
|
|||
return story_flags.get(flag_name, default)
|
||||
|
||||
|
||||
## Liefert das Fraktions-Standing (-100..100), 0 für unbekannte Fraktionen.
|
||||
func get_faction_standing(faction_id: String) -> int:
|
||||
return faction_standings.get(faction_id, 0)
|
||||
|
||||
|
||||
## Setzt das Fraktions-Standing absolut (geklemmt auf -100..100) und
|
||||
## meldet Änderungen über faction_standing_changed.
|
||||
func set_faction_standing(faction_id: String, value: int) -> void:
|
||||
var new_value := clampi(value, RELATIONSHIP_MIN, RELATIONSHIP_MAX)
|
||||
if get_faction_standing(faction_id) != new_value:
|
||||
faction_standings[faction_id] = new_value
|
||||
faction_standing_changed.emit(faction_id, new_value)
|
||||
|
||||
|
||||
## Verschiebt das Fraktions-Standing relativ um amount (mit Klemmung).
|
||||
func adjust_faction_standing(faction_id: String, amount: int) -> void:
|
||||
set_faction_standing(faction_id, get_faction_standing(faction_id) + amount)
|
||||
|
||||
|
||||
## Serialisiert den kompletten Zustand als Dictionary für das SaveSystem.
|
||||
func to_save_dict() -> Dictionary:
|
||||
return {
|
||||
|
|
@ -135,6 +158,7 @@ func to_save_dict() -> Dictionary:
|
|||
"relationships": relationships.duplicate(),
|
||||
"completed_dialogues": completed_dialogues.duplicate(),
|
||||
"story_flags": story_flags.duplicate(),
|
||||
"faction_standings": faction_standings.duplicate(),
|
||||
"is_permadeath_enabled": is_permadeath_enabled,
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +186,10 @@ func apply_save_dict(data: Dictionary) -> void:
|
|||
var saved_flags: Dictionary = data.get("story_flags", {})
|
||||
for flag_name in saved_flags:
|
||||
story_flags[String(flag_name)] = saved_flags[flag_name]
|
||||
faction_standings.clear()
|
||||
var saved_standings: Dictionary = data.get("faction_standings", {})
|
||||
for faction_id in saved_standings:
|
||||
faction_standings[String(faction_id)] = clampi(int(saved_standings[faction_id]), RELATIONSHIP_MIN, RELATIONSHIP_MAX)
|
||||
blade_heart_tone_changed.emit(blade_heart_tone)
|
||||
for npc_id in relationships:
|
||||
relationship_changed.emit(npc_id, relationships[npc_id])
|
||||
|
|
|
|||
|
|
@ -20,11 +20,28 @@ const SLOT_NAMES := {
|
|||
|
||||
var current_slot := DaySlot.MORNING
|
||||
var day_count := 1
|
||||
var is_current_slot_used := false
|
||||
|
||||
|
||||
## Verbraucht den aktuellen Tages-Slot für eine Aktivität (Unterricht
|
||||
## etc.): Vormittag/Nachmittag rücken direkt auf den nächsten Slot vor,
|
||||
## der Abend wird als verbraucht markiert — danach ist bis zum Schlafsaal
|
||||
## keine Aktivität mehr möglich. Liefert false, wenn der Slot schon
|
||||
## verbraucht ist.
|
||||
func try_spend_slot() -> bool:
|
||||
if is_current_slot_used:
|
||||
return false
|
||||
if current_slot == DaySlot.EVENING:
|
||||
is_current_slot_used = true
|
||||
else:
|
||||
advance_slot()
|
||||
return true
|
||||
|
||||
|
||||
## Setzt den Zyklus auf Tag 1, Vormittag zurück (neues Spiel).
|
||||
func reset() -> void:
|
||||
day_count = 1
|
||||
is_current_slot_used = false
|
||||
_change_slot(DaySlot.MORNING)
|
||||
|
||||
|
||||
|
|
@ -53,8 +70,10 @@ func get_slot_name() -> String:
|
|||
return SLOT_NAMES[current_slot]
|
||||
|
||||
|
||||
## Setzt den Slot und meldet echte Wechsel über slot_changed.
|
||||
## Setzt den Slot, gibt den Aktivitäts-Verbrauch frei und meldet echte
|
||||
## Wechsel über slot_changed.
|
||||
func _change_slot(new_slot: DaySlot) -> void:
|
||||
is_current_slot_used = false
|
||||
if new_slot == current_slot:
|
||||
return
|
||||
current_slot = new_slot
|
||||
|
|
|
|||
78
scripts/gameplay/training_station.gd
Normal file
78
scripts/gameplay/training_station.gd
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
extends StaticBody3D
|
||||
## Unterrichts-Station als Tagesaktivität (Phase 4a, SPEC.md Abschnitte 6
|
||||
## und 7).
|
||||
##
|
||||
## Interaktion über die interact-Action in Reichweite (Area3D am Root).
|
||||
## Eine Aktivität verbraucht den aktuellen Tages-Slot über
|
||||
## TimeSystem.try_spend_slot() — der erste echte Verbraucher von
|
||||
## advance_slot(): Vormittag -> Nachmittag -> Abend; nach der
|
||||
## Abend-Aktivität geht nichts mehr, bis der Schlafsaal den Tag beendet.
|
||||
## Der Stat-Zuwachs (stat_gain, Standard +2) läuft über
|
||||
## GameState.increase_stat() und ist dort am STAT_MAX geklemmt.
|
||||
## Rückmeldung über die Sprechblase der Station — bewusst kein voller
|
||||
## Dialogbaum, das ist eine Aktivität, kein NPC-Gespräch. Ein kurzer
|
||||
## Cooldown schützt vor versehentlichen Doppel-Eingaben.
|
||||
|
||||
const STAT_LABELS := {
|
||||
"strength": "Kraft",
|
||||
"agility": "Schnelligkeit",
|
||||
"intellect": "Verstand",
|
||||
}
|
||||
const INPUT_COOLDOWN_MS := 800
|
||||
|
||||
@export var station_name := "Training"
|
||||
@export var stat_name := "strength"
|
||||
@export var stat_gain := 2
|
||||
@export var success_line := "Das sitzt. Weiter im Plan."
|
||||
@export var exhausted_line := "Für heute reicht es — der Schlafsaal wartet."
|
||||
|
||||
var _is_player_in_range := false
|
||||
var _last_use_ms := -INPUT_COOLDOWN_MS
|
||||
|
||||
@onready var _prompt_label: Label3D = $PromptLabel
|
||||
@onready var _interaction_area: Area3D = $InteractionArea
|
||||
@onready var _bubble: Node3D = $SpeechBubble
|
||||
|
||||
|
||||
## Verbindet die Reichweiten-Signale des Interaktions-Triggers.
|
||||
func _ready() -> void:
|
||||
_interaction_area.body_entered.connect(_on_body_entered)
|
||||
_interaction_area.body_exited.connect(_on_body_exited)
|
||||
|
||||
|
||||
## Startet die Aktivität bei interact in Reichweite, außerhalb laufender
|
||||
## Dialoge und nach Ablauf des Doppel-Eingabe-Schutzes.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not _is_player_in_range:
|
||||
return
|
||||
if DialogueSystem.is_dialogue_active:
|
||||
return
|
||||
if not event.is_action_pressed("interact"):
|
||||
return
|
||||
if Time.get_ticks_msec() - _last_use_ms < INPUT_COOLDOWN_MS:
|
||||
return
|
||||
_last_use_ms = Time.get_ticks_msec()
|
||||
_train()
|
||||
|
||||
|
||||
## Verbraucht den Tages-Slot und erhöht den Stat; ist der Slot schon
|
||||
## verbraucht, gibt es nur die Absage-Zeile.
|
||||
func _train() -> void:
|
||||
if not TimeSystem.try_spend_slot():
|
||||
_bubble.show_line(exhausted_line)
|
||||
return
|
||||
GameState.increase_stat(stat_name, stat_gain)
|
||||
var stat_label: String = STAT_LABELS.get(stat_name, stat_name)
|
||||
_bubble.show_line("%s (%s +%d)" % [success_line, stat_label, stat_gain])
|
||||
|
||||
|
||||
## 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
|
||||
1
scripts/gameplay/training_station.gd.uid
Normal file
1
scripts/gameplay/training_station.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dkadufpy8ooaj
|
||||
|
|
@ -47,8 +47,15 @@ func _on_dialogue_finished(_dialogue_id: String) -> void:
|
|||
|
||||
|
||||
## Merkt sich das zuletzt benutzte Eingabegerät anhand des Event-Typs;
|
||||
## Stick-Rauschen unterhalb der Deadzone wird ignoriert.
|
||||
## Stick-Rauschen unterhalb der Deadzone wird ignoriert. F9/F10
|
||||
## verschieben testweise das Gezeichneten-Standing (reine Debug-Hilfe des
|
||||
## Overlays, bewusst ohne Input-Action — fliegt mit dem Overlay raus).
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.physical_keycode == KEY_F9:
|
||||
FactionSystem.adjust_standing(FactionSystem.MARKED_FACTION_ID, -5)
|
||||
elif event.physical_keycode == KEY_F10:
|
||||
FactionSystem.adjust_standing(FactionSystem.MARKED_FACTION_ID, 5)
|
||||
if event is InputEventKey or event is InputEventMouseButton or event is InputEventMouseMotion:
|
||||
_active_device = "Tastatur/Maus"
|
||||
elif event is InputEventJoypadButton:
|
||||
|
|
@ -76,6 +83,7 @@ func _process(_delta: float) -> void:
|
|||
for npc_id in TRACKED_NPC_IDS:
|
||||
relationship_parts.append("%s %+d" % [npc_id.capitalize(), RelationshipSystem.get_relationship(npc_id)])
|
||||
lines.append("Beziehungen: %s" % " ".join(relationship_parts))
|
||||
lines.append("Gezeichnete-Standing: %+d (F9/F10 zum Testen)" % FactionSystem.get_standing(FactionSystem.MARKED_FACTION_ID))
|
||||
var npc_states := PackedStringArray()
|
||||
for npc in get_tree().get_nodes_in_group("npc"):
|
||||
if npc.has_method("get_state_name"):
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const CONTINUE_SCENE := "res://scenes/hub/rider_quadrant.tscn"
|
|||
|
||||
@onready var _start_button: Button = $CenterContainer/VBoxContainer/StartButton
|
||||
@onready var _continue_button: Button = $CenterContainer/VBoxContainer/ContinueButton
|
||||
@onready var _permadeath_button: Button = $CenterContainer/VBoxContainer/PermadeathButton
|
||||
@onready var _quit_button: Button = $CenterContainer/VBoxContainer/QuitButton
|
||||
|
||||
|
||||
|
|
@ -25,7 +26,9 @@ func _ready() -> void:
|
|||
_continue_button.visible = SaveSystem.has_save()
|
||||
_start_button.pressed.connect(_on_start_pressed)
|
||||
_continue_button.pressed.connect(_on_continue_pressed)
|
||||
_permadeath_button.pressed.connect(_on_permadeath_pressed)
|
||||
_quit_button.pressed.connect(_on_quit_pressed)
|
||||
_update_permadeath_text()
|
||||
_start_button.grab_focus.call_deferred()
|
||||
|
||||
|
||||
|
|
@ -71,6 +74,19 @@ func _on_continue_pressed() -> void:
|
|||
get_tree().change_scene_to_file(CONTINUE_SCENE)
|
||||
|
||||
|
||||
## Schaltet Permadeath um (SPEC Abschnitt 6: Toggle, Default AN). Die
|
||||
## Wahl übersteht GameState.reset() und wird beim Speichern im Spielstand
|
||||
## abgelegt; Fortsetzen stellt den gespeicherten Zustand wieder her.
|
||||
func _on_permadeath_pressed() -> void:
|
||||
GameState.is_permadeath_enabled = not GameState.is_permadeath_enabled
|
||||
_update_permadeath_text()
|
||||
|
||||
|
||||
## Beendet das Spiel.
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
## Hält den Toggle-Text synchron zum GameState.
|
||||
func _update_permadeath_text() -> void:
|
||||
_permadeath_button.text = "Permadeath: %s" % ("AN" if GameState.is_permadeath_enabled else "AUS")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue