From 1245f438f11ceb1c7f632f7082b66cfbf177c8eb Mon Sep 17 00:00:00 2001 From: torsten Date: Fri, 13 Nov 2026 13:18:35 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20Hilfetext=20und=20Saisonvergleich?= =?UTF-8?q?=20aus=20dem=20Controller=20l=C3=B6sen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Erste Etappen der Controller-Zerlegung, Reihenfolge und Regeln in `docs/refactor-whiteboard-controller.md`. - `HelpContent` (src/whiteboard/view/help_content.gd): der Text des ?-Dialogs als reine Funktion, 137 Zeilen ohne Kopplung. - `SeasonComparisonText` (src/whiteboard/view/season_comparison_text.gd): `build(routine, report)` liefert die BBCode-Zeilen des Saisonvergleichs; der Controller setzt sie nur noch ins Label. - Eigener Test für den Vergleichstext (Gruppen, fehlendes Element, Summe, Befunde). Controller: 9.092 -> 8.839 Zeilen. Kein Verhalten geändert, Suite grün. Nächste Etappe laut Notiz: der Prüfdialog (ValidationReportView). --- docs/refactor-whiteboard-controller.md | 48 +-- docs/roadmap.md | 4 +- .../whiteboard/ctrl/whiteboard_controller.gd | 297 +----------------- .../src/whiteboard/view/help_content.gd | 145 +++++++++ .../src/whiteboard/view/help_content.gd.uid | 1 + .../whiteboard/view/season_comparison_text.gd | 174 ++++++++++ .../view/season_comparison_text.gd.uid | 1 + rinkplanner/tests/run_rules_audit_tests.gd | 27 ++ 8 files changed, 383 insertions(+), 314 deletions(-) create mode 100644 rinkplanner/src/whiteboard/view/help_content.gd create mode 100644 rinkplanner/src/whiteboard/view/help_content.gd.uid create mode 100644 rinkplanner/src/whiteboard/view/season_comparison_text.gd create mode 100644 rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid diff --git a/docs/refactor-whiteboard-controller.md b/docs/refactor-whiteboard-controller.md index 73e35b6..cb8df00 100644 --- a/docs/refactor-whiteboard-controller.md +++ b/docs/refactor-whiteboard-controller.md @@ -2,8 +2,9 @@ Stand: 2026-11-13 -Ziel: Der Controller ist mit **9.092 Zeilen und 465 Funktionen** der größte -Baustein im Projekt; die Roadmap nennt < 1.500 Zeilen pro Datei. Diese Notiz +Ziel: Der Controller war mit **9.092 Zeilen und 465 Funktionen** der größte +Baustein im Projekt; die Roadmap nennt < 1.500 Zeilen pro Datei. Nach den +Etappen 1 und 2 sind es 8.839 Zeilen. Diese Notiz hält die Reihenfolge fest, damit der Umbau in Etappen mit grüner Suite passiert und nicht als Big Bang. @@ -24,14 +25,15 @@ passiert und nicht als Big Bang. | Baustein | Inhalt | Zeilen (grob) | Kopplung | Etappe | | :--- | :--- | ---: | :--- | :--- | -| `HelpContent` | Hilfetext für den ?-Dialog | ~140 | keine | 1 ✅ | -| `ValidationReportView` | Zeilen für Prüf- und Saisonvergleichs-Dialog | ~400 | nur Daten | 2 | -| `ExportService` | PDF/SVG/PNG schreiben, Abschlussdialog-Daten | ~250 | Dateisystem | 3 | -| `SeasonPanel` | Saison-/Programm-/Kategorieauswahl und Regelnachführung | ~250 | Statusleiste | 4 | -| `SyncPanel` | Dropbox-Sync, Konflikte, Küren verwalten | ~900 | Dialoge, Threads | 5 | -| `HubPanel` | Kür-Hub (Login, Upload, Downloads) | ~650 | Dialoge, Threads | 6 | -| `PlaybackPanel` | Wiedergabe, Musik, Timeline-Labels | ~600 | Canvas, Audio | 7 | -| `ElementInspector` | Element-Dialog, Features, Level, Kombinationen | ~800 | Dialog, Regeln | 8 | +| `HelpContent` | Hilfetext für den ?-Dialog | 137 | keine | 1 ✅ | +| `SeasonComparisonText` | Zeilen für den Saisonvergleichs-Dialog | 175 | nur Daten | 2 ✅ | +| `ValidationReportView` | Zeilen für den Prüfdialog | ~350 | nur Daten | 3 | +| `ExportService` | PDF/SVG/PNG schreiben, Abschlussdialog-Daten | ~250 | Dateisystem | 4 | +| `SeasonPanel` | Saison-/Programm-/Kategorieauswahl und Regelnachführung | ~250 | Statusleiste | 5 | +| `SyncPanel` | Dropbox-Sync, Konflikte, Küren verwalten | ~900 | Dialoge, Threads | 6 | +| `HubPanel` | Kür-Hub (Login, Upload, Downloads) | ~650 | Dialoge, Threads | 7 | +| `PlaybackPanel` | Wiedergabe, Musik, Timeline-Labels | ~600 | Canvas, Audio | 8 | +| `ElementInspector` | Element-Dialog, Features, Level, Kombinationen | ~800 | Dialog, Regeln | 9 | Danach bleibt ein Controller von grob 2.000–2.500 Zeilen: Verdrahtung, Auswahl, Werkzeuge, Abschnitte, Undo/Redo, Statuszeile. @@ -44,36 +46,42 @@ Der Hilfetext ist ein reiner String. Verschoben nach `src/whiteboard/view/help_content.gd` (`HelpContent.build()`), der Controller setzt ihn nur noch in den Dialog. Kein Verhalten geändert. -### 2. `ValidationReportView` +### 2. `SeasonComparisonText` ✅ -Der komplette Textaufbau für den Prüfdialog (Kopf, Saisonhinweis, Kategorie, -Basiswert, Punktschätzung, Prüfliste, Befunde) und für den -Saisonvergleich wandert in eine Klasse, die `Routine`, `ValidationReport`, -`RulesPackage` und die Anzeige-Optionen bekommt und `PackedStringArray` -zurückgibt. +Der Text des Saisonvergleichs (Kopf, Gruppen, Summe, Befunde) liegt jetzt in +`src/whiteboard/view/season_comparison_text.gd`. `build(routine, report)` +gibt die BBCode-Zeilen zurück; der Controller setzt sie nur noch in das +Label. Kein Verhalten geändert. + +### 3. `ValidationReportView` + +Derselbe Schnitt für den Prüfdialog: Kopf, Saisonhinweis, Kategorie, +Basiswert, Punktschätzung, Prüfliste und Befunde. Weil dort Anzeige-Optionen +(„Was ist enthalten?", „Annahmen ändern") mit hineinspielen, bekommt die +Klasse einen kleinen Kontext (Dictionary) statt vieler Einzelparameter. Fertig, wenn der Controller nur noch `validation_text.text = ...` setzt und der Dialog unverändert aussieht (Whiteboard-Test grün, keine neuen Typfehler). -### 3. `ExportService` +### 4. `ExportService` Schreiben der Dateien, Pfadbildung und der Abschluss-Dialog bekommen einen eigenen Baustein; der Controller reicht Kür, Format und Abschnitt durch. -### 4. `SeasonPanel` +### 5. `SeasonPanel` Saison-, Programm- und Kategorieauswahl samt Regelnachführung (`_apply_rules_for_season`, `_sync_season_option`, `set_season`, …). Danach kennt nur noch dieser Baustein `RulesLibrary` und `RulesPackage`. -### 5–7. Sync, Hub, Playback +### 6–8. Sync, Hub, Playback Die drei Thread-/Dialog-Cluster. Sie hängen an Signalen und Fenstern; hier lohnt es, die Bausteine als eigene Nodes mit Signalen zu schneiden, statt als RefCounted mit Rückruf. -### 8. `ElementInspector` +### 9. `ElementInspector` Zuletzt: Element-Dialog, Feature-Auswahl, Fußzuordnung, Levelableitung. Der größte UI-Block und der, an dem am meisten hängt. diff --git a/docs/roadmap.md b/docs/roadmap.md index 896fc6e..bd77e9d 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -269,7 +269,9 @@ Schritte. - [ ] `WhiteboardController` in Services/Panels zerlegen: Datei-I/O, Sync, Playback, Validierung, Element-Inspector, Section-Liste. Ziel: < 1.500 - Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. + Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. In Etappen nach + `docs/refactor-whiteboard-controller.md`; Stand 2026-11-13: 8.839 Zeilen, + `HelpContent` und `SeasonComparisonText` ausgelagert. - [ ] Gemeinsamer Test-Harness (oder gdUnit4), Timeout pro Testlauf, Coverage; CI auf dem Gitea-/Forgejo-Remote mit `tools/test.sh` und `tools/check_export.sh`. diff --git a/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd b/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd index c5c97d8..98cdc85 100644 --- a/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd +++ b/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd @@ -1115,163 +1115,13 @@ func _run_upgrade_check() -> void: upgrade_pdf_button.disabled = true return _upgrade_report = SeasonUpgradeCheck.run(_routine, _rules_package, target) - upgrade_text.text = I18n.join_lines(_upgrade_report_lines(_upgrade_report)) + upgrade_text.text = I18n.join_lines( + SeasonComparisonText.build(_routine, _upgrade_report) + ) upgrade_apply_button.disabled = false upgrade_pdf_button.disabled = false -func _upgrade_report_lines(report: SeasonUpgradeCheck.Report) -> PackedStringArray: - var lines := PackedStringArray() - var title := _routine.title.strip_edges() - if title.is_empty(): - title = I18n.t("Unbenannte Kür") - lines.append( - "[b]%s — %s → %s[/b]" - % [ - _escape_bbcode(title), - report.source_season, - report.target_season, - ] - ) - - if not report.has_changes(): - lines.append("") - lines.append( - I18n.t("Keine Unterschiede: Die Kür passt in beide Saisons.") - ) - - _append_upgrade_group( - lines, - I18n.t("Elemente"), - report.changes_of(SeasonUpgradeCheck.KIND_MISSING_CODE), - I18n.t("nicht im Katalog") - ) - _append_upgrade_group( - lines, - I18n.t("Base Values"), - report.changes_of(SeasonUpgradeCheck.KIND_VALUE_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Elementtyp"), - report.changes_of(SeasonUpgradeCheck.KIND_TYPE_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Features"), - report.changes_of(SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE), - I18n.t("in der Ziel-Saison unbekannt") - ) - _append_upgrade_group( - lines, - I18n.t("Level"), - report.changes_of(SeasonUpgradeCheck.KIND_LEVEL_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Kategorie"), - report.changes_of(SeasonUpgradeCheck.KIND_CATEGORY_CHANGE) - ) - var missing_category := report.changes_of( - SeasonUpgradeCheck.KIND_CATEGORY_MISSING - ) - if not missing_category.is_empty(): - lines.append("") - lines.append("[b]%s[/b]" % I18n.t("Kategorie")) - lines.append( - "● %s: %s" - % [ - _escape_bbcode(missing_category[0].label), - I18n.t("in der Ziel-Saison nicht vorhanden"), - ] - ) - - lines.append("") - lines.append("[b]%s[/b]" % I18n.t("Summe")) - if report.base_value_before > 0.0 or report.base_value_after > 0.0: - lines.append( - I18n.t("Basiswert %s → %s (%s%s)") - % [ - _format_base_value(report.base_value_before), - _format_base_value(report.base_value_after), - "+" if report.value_delta() >= 0.0 else "−", - _format_base_value(absf(report.value_delta())), - ] - ) - else: - lines.append(I18n.t("Keine Elemente mit Base Value.")) - - if not report.issues.is_empty(): - lines.append("") - lines.append( - "[b]%s[/b]" % I18n.t("Befunde bei Prüfung gegen %s") % report.target_season - ) - for issue: ValidationIssue in report.issues: - var color := ( - "#ef4444" - if issue.severity == ValidationIssue.Severity.ERROR - else "#f59e0b" - ) - lines.append( - "[color=%s]●[/color] %s%s" - % [ - color, - _escape_bbcode(issue.message), - _upgrade_location(issue.section_id), - ] - ) - return lines - - -func _append_upgrade_group( - lines: PackedStringArray, - title: String, - changes: Array, - suffix: String = "" -) -> void: - if changes.is_empty(): - return - lines.append("") - lines.append("[b]%s[/b]" % title) - for change: SeasonUpgradeCheck.Change in changes: - var text := _escape_bbcode(change.label) - if change.kind == SeasonUpgradeCheck.KIND_MISSING_CODE: - text += ": " + I18n.t("nicht im Katalog") - elif change.kind == SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE: - text += ": %s — %s" % [ - I18n.t("Feature"), - _escape_bbcode(change.before), - ] - if not suffix.is_empty(): - text += " " + suffix - elif change.kind == SeasonUpgradeCheck.KIND_CATEGORY_CHANGE: - text = "%s: %s → %s" % [ - _escape_bbcode(change.label), - _escape_bbcode(change.before), - _escape_bbcode(change.after), - ] - elif change.after.is_empty(): - text += ": " + _escape_bbcode(change.before) - else: - text += ": %s → %s" % [ - _escape_bbcode(change.before), - _escape_bbcode(change.after), - ] - text += _upgrade_location(change.section_id) - lines.append("● %s" % text) - - -func _upgrade_location(section_id: String) -> String: - if section_id.is_empty() or _routine == null: - return "" - if _routine.sections.size() < 2: - return "" - var section := _routine.get_section_by_id(section_id) - if section == null: - return "" - return " (%s)" % I18n.section_title(section.title) - - func _on_upgrade_apply_pressed() -> void: if _upgrade_target_season.is_empty(): return @@ -1445,7 +1295,7 @@ static func _format_duration(seconds: int) -> String: func open_help_dialog() -> void: - help_text.text = _help_content() + help_text.text = HelpContent.build() var target := Vector2i(820, 680) var viewport_size := Vector2i(get_viewport_rect().size) if viewport_size.x > 0: @@ -1455,145 +1305,6 @@ func open_help_dialog() -> void: help_dialog.popup_centered(target) -func _help_content() -> String: - var lines := PackedStringArray() - lines.append("[b][font_size=22]Hilfe & Annahmen[/font_size][/b]") - lines.append( - "Diese Hilfe erklärt die Annahmen und Prüfungen der App. Sie ist " - + "keine offizielle ISU-Auslegung." - ) - lines.append("") - lines.append("[b][font_size=18]1. Kürzel und Base Value[/font_size][/b]") - lines.append( - "- Das Kürzel bezeichnet die Elementfamilie, z. B. 3Lz, CCoSp oder StSq." - ) - lines.append( - "- Der Level ist die Schwierigkeitsstufe. Bei Pirouetten und " - + "Schrittsequenzen folgt er aus den Features." - ) - lines.append( - "- Der Base Value wird aus Kürzel und Level im Saisonkatalog 2026/27 " - + "nachgeschlagen (ISU Communication 2786)." - ) - lines.append( - "- Sprünge haben keinen Level; ihr Base Value hängt von Rotation und " - + "Sprungtyp ab." - ) - lines.append( - "- Sprungkombinationen werden strukturiert gewählt: erster Sprung plus " - + "bis zu zwei weitere, als Kombination oder Folge. Die Base Values " - + "werden summiert." - ) - lines.append( - "- Eine Folge braucht einen Axel (1A/2A/3A) als 2. oder 3. Sprung." - ) - lines.append( - "- Alte Freitext-Kombinationen werden beim Laden oder Übernehmen " - + "automatisch in die strukturierte Form überführt." - ) - lines.append( - "- ChSq (Choreo-Sequenz) und ChSp (Choreographic Spin) sind fest " - + "Level 1." - ) - lines.append( - "- Unbekannte Freitext-Codes haben keinen Katalogwert und werden in " - + "der Schätzung nicht gewertet." - ) - lines.append("") - lines.append("[b][font_size=18]2. Level aus Features[/font_size][/b]") - lines.append( - "- Pirouetten haben 15 Features, Schrittsequenzen 5 " - + "(ISU Communication 2788)." - ) - lines.append( - "- 0 Features = Base, 1 = Level 1, 2 = Level 2, 3 = Level 3, " - + "4 oder mehr = Level 4." - ) - lines.append( - "- Level 4 bei Pirouetten verlangt zusätzlich eines von: schwieriger " - + "Ausgang, Kantenänderung, beide Richtungen, Temposteigerung, " - + "schwieriger Flug-Eingang oder Windmills." - ) - lines.append( - "- Bei Schrittsequenzen ist Feature 1 (Vielfalt) Pflicht." - ) - lines.append( - "- Features beschreiben die Ausführung. Die App kann sie nicht aus " - + "der gezeichneten Linie ableiten; sie werden im Element-Dialog " - + "ausgewählt." - ) - lines.append("") - lines.append("[b][font_size=18]3. Adult-Kategorie[/font_size][/b]") - lines.append( - "- Die Kategorie wird in der Statusleiste gewählt und mit der Kür " - + "gespeichert." - ) - lines.append( - "- Gold: max. 5 Sprünge, keine 2F/2Lz/2A/Triple, 3 Pirouetten inkl. " - + "ChSp, 1 Schrittsequenz, 2:50 ±10 s, Spins bis Level 3, Sequenz bis " - + "Level 2." - ) - lines.append( - "- Silver: max. 4 Einfachsprünge inkl. 1A, 2 Pirouetten, 1 ChSq, " - + "2:00 ±10 s, Level bis 2." - ) - lines.append( - "- Bronze: max. 4 Einfachsprünge ohne Axel, 1 Sprungkombination, " - + "2 Pirouetten, 1 ChSq, 1:40 ±10 s, Level bis 1." - ) - lines.append( - "- PCS-Faktor und Sturzabzug stehen in den Kategorie-Daten " - + "(Gold 2,67 und 1,0; Silver/Bronze 2,00 und 0,5)." - ) - lines.append("") - lines.append("[b][font_size=18]4. Punktschätzung[/font_size][/b]") - lines.append( - "- Basiswert: Summe der Base Values aller Elemente mit gültigem " - + "Katalogwert." - ) - lines.append( - "- PCS-Annahme: Durchschnitt pro Komponente × 3 Komponenten × " - + "Kategorie-Faktor." - ) - lines.append( - "- Der PCS-Durchschnitt ist eine Planungsannahme, kein Judge-Wert. " - + "Startwert 5,00; er kann über „Annahmen ändern“ angepasst werden." - ) - lines.append( - "- Sturzabzug: Anzahl Stürze × Kategorie-Abzug." - ) - lines.append( - "- Nicht enthalten: GOE, 1,1-Faktor, nicht katalogisierte " - + "Kombinationen und die offizielle Wettkampfwertung." - ) - lines.append( - "- Beispiel Gold: 5,00 × 3 × 2,67 = 40,05 PCS; Basiswert 9,50; " - + "geschätzte Summe 49,55." - ) - lines.append("") - lines.append("[b][font_size=18]5. Prüfung[/font_size][/b]") - lines.append( - "- Der Button „Prüfen“ zeigt Kürzel-, Level-, Feature- und " - + "Kategorie-Prüfungen sowie die Punktschätzung." - ) - lines.append( - "- Warnungen blockieren Speichern und Export nicht. Sie sind " - + "Planungshinweise." - ) - lines.append( - "- Wiederholungen: max. 2-mal pro gelistetem Sprung; " - + "Kombinationsbestandteile zählen mit." - ) - lines.append("") - lines.append("[b]Tipp:[/b] Für eine realistische PCS-Annahme helfen " - + "Protokolle früherer Wettkämpfe. Der Durchschnitt sollte zu deinem " - + "aktuellen Leistungsstand passen, nicht zum Wunschziel.") - lines.append("") - lines.append("[b]Quellen:[/b] ISU Communication 2786 (SoV 2026/27), " - + "2788 (Levels/GOE 2026/27), IAFSC Technical Announcement 2026/27.") - return I18n.join_lines(lines) - - func _on_validation_meta_clicked(meta: Variant) -> void: var key := str(meta) if key == "score_info": diff --git a/rinkplanner/src/whiteboard/view/help_content.gd b/rinkplanner/src/whiteboard/view/help_content.gd new file mode 100644 index 0000000..56718fb --- /dev/null +++ b/rinkplanner/src/whiteboard/view/help_content.gd @@ -0,0 +1,145 @@ +class_name HelpContent +extends RefCounted + +## Text of the in-app help dialog ("Hilfe & Annahmen"). +## +## Kept out of the controller so the scene wiring stays readable. The strings +## are German keys of the i18n catalog; `I18n.join_lines()` translates them. + +static func build() -> String: + var lines := PackedStringArray() + lines.append("[b][font_size=22]Hilfe & Annahmen[/font_size][/b]") + lines.append( + "Diese Hilfe erklärt die Annahmen und Prüfungen der App. Sie ist " + + "keine offizielle ISU-Auslegung." + ) + lines.append("") + lines.append("[b][font_size=18]1. Kürzel und Base Value[/font_size][/b]") + lines.append( + "- Das Kürzel bezeichnet die Elementfamilie, z. B. 3Lz, CCoSp oder StSq." + ) + lines.append( + "- Der Level ist die Schwierigkeitsstufe. Bei Pirouetten und " + + "Schrittsequenzen folgt er aus den Features." + ) + lines.append( + "- Der Base Value wird aus Kürzel und Level im Saisonkatalog 2026/27 " + + "nachgeschlagen (ISU Communication 2786)." + ) + lines.append( + "- Sprünge haben keinen Level; ihr Base Value hängt von Rotation und " + + "Sprungtyp ab." + ) + lines.append( + "- Sprungkombinationen werden strukturiert gewählt: erster Sprung plus " + + "bis zu zwei weitere, als Kombination oder Folge. Die Base Values " + + "werden summiert." + ) + lines.append( + "- Eine Folge braucht einen Axel (1A/2A/3A) als 2. oder 3. Sprung." + ) + lines.append( + "- Alte Freitext-Kombinationen werden beim Laden oder Übernehmen " + + "automatisch in die strukturierte Form überführt." + ) + lines.append( + "- ChSq (Choreo-Sequenz) und ChSp (Choreographic Spin) sind fest " + + "Level 1." + ) + lines.append( + "- Unbekannte Freitext-Codes haben keinen Katalogwert und werden in " + + "der Schätzung nicht gewertet." + ) + lines.append("") + lines.append("[b][font_size=18]2. Level aus Features[/font_size][/b]") + lines.append( + "- Pirouetten haben 15 Features, Schrittsequenzen 5 " + + "(ISU Communication 2788)." + ) + lines.append( + "- 0 Features = Base, 1 = Level 1, 2 = Level 2, 3 = Level 3, " + + "4 oder mehr = Level 4." + ) + lines.append( + "- Level 4 bei Pirouetten verlangt zusätzlich eines von: schwieriger " + + "Ausgang, Kantenänderung, beide Richtungen, Temposteigerung, " + + "schwieriger Flug-Eingang oder Windmills." + ) + lines.append( + "- Bei Schrittsequenzen ist Feature 1 (Vielfalt) Pflicht." + ) + lines.append( + "- Features beschreiben die Ausführung. Die App kann sie nicht aus " + + "der gezeichneten Linie ableiten; sie werden im Element-Dialog " + + "ausgewählt." + ) + lines.append("") + lines.append("[b][font_size=18]3. Adult-Kategorie[/font_size][/b]") + lines.append( + "- Die Kategorie wird in der Statusleiste gewählt und mit der Kür " + + "gespeichert." + ) + lines.append( + "- Gold: max. 5 Sprünge, keine 2F/2Lz/2A/Triple, 3 Pirouetten inkl. " + + "ChSp, 1 Schrittsequenz, 2:50 ±10 s, Spins bis Level 3, Sequenz bis " + + "Level 2." + ) + lines.append( + "- Silver: max. 4 Einfachsprünge inkl. 1A, 2 Pirouetten, 1 ChSq, " + + "2:00 ±10 s, Level bis 2." + ) + lines.append( + "- Bronze: max. 4 Einfachsprünge ohne Axel, 1 Sprungkombination, " + + "2 Pirouetten, 1 ChSq, 1:40 ±10 s, Level bis 1." + ) + lines.append( + "- PCS-Faktor und Sturzabzug stehen in den Kategorie-Daten " + + "(Gold 2,67 und 1,0; Silver/Bronze 2,00 und 0,5)." + ) + lines.append("") + lines.append("[b][font_size=18]4. Punktschätzung[/font_size][/b]") + lines.append( + "- Basiswert: Summe der Base Values aller Elemente mit gültigem " + + "Katalogwert." + ) + lines.append( + "- PCS-Annahme: Durchschnitt pro Komponente × 3 Komponenten × " + + "Kategorie-Faktor." + ) + lines.append( + "- Der PCS-Durchschnitt ist eine Planungsannahme, kein Judge-Wert. " + + "Startwert 5,00; er kann über „Annahmen ändern“ angepasst werden." + ) + lines.append( + "- Sturzabzug: Anzahl Stürze × Kategorie-Abzug." + ) + lines.append( + "- Nicht enthalten: GOE, 1,1-Faktor, nicht katalogisierte " + + "Kombinationen und die offizielle Wettkampfwertung." + ) + lines.append( + "- Beispiel Gold: 5,00 × 3 × 2,67 = 40,05 PCS; Basiswert 9,50; " + + "geschätzte Summe 49,55." + ) + lines.append("") + lines.append("[b][font_size=18]5. Prüfung[/font_size][/b]") + lines.append( + "- Der Button „Prüfen“ zeigt Kürzel-, Level-, Feature- und " + + "Kategorie-Prüfungen sowie die Punktschätzung." + ) + lines.append( + "- Warnungen blockieren Speichern und Export nicht. Sie sind " + + "Planungshinweise." + ) + lines.append( + "- Wiederholungen: max. 2-mal pro gelistetem Sprung; " + + "Kombinationsbestandteile zählen mit." + ) + lines.append("") + lines.append("[b]Tipp:[/b] Für eine realistische PCS-Annahme helfen " + + "Protokolle früherer Wettkämpfe. Der Durchschnitt sollte zu deinem " + + "aktuellen Leistungsstand passen, nicht zum Wunschziel.") + lines.append("") + lines.append("[b]Quellen:[/b] ISU Communication 2786 (SoV 2026/27), " + + "2788 (Levels/GOE 2026/27), IAFSC Technical Announcement 2026/27.") + return I18n.join_lines(lines) diff --git a/rinkplanner/src/whiteboard/view/help_content.gd.uid b/rinkplanner/src/whiteboard/view/help_content.gd.uid new file mode 100644 index 0000000..0f4329e --- /dev/null +++ b/rinkplanner/src/whiteboard/view/help_content.gd.uid @@ -0,0 +1 @@ +uid://bpmg0ef1gpgbu diff --git a/rinkplanner/src/whiteboard/view/season_comparison_text.gd b/rinkplanner/src/whiteboard/view/season_comparison_text.gd new file mode 100644 index 0000000..5441be0 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_comparison_text.gd @@ -0,0 +1,174 @@ +class_name SeasonComparisonText +extends RefCounted + +## Text of the season comparison dialog. +## +## Pure formatting: the routine and the comparison report go in, the BBCode +## lines for the RichTextLabel come out. Kept out of the controller so the +## dialog wiring stays readable and the text is testable on its own. + +static func build(routine: Routine, report: SeasonUpgradeCheck.Report) -> PackedStringArray: + var lines := PackedStringArray() + var title := routine.title.strip_edges() + if title.is_empty(): + title = I18n.t("Unbenannte Kür") + lines.append( + "[b]%s — %s → %s[/b]" + % [ + _escape(title), + report.source_season, + report.target_season, + ] + ) + + if not report.has_changes(): + lines.append("") + lines.append( + I18n.t("Keine Unterschiede: Die Kür passt in beide Saisons.") + ) + + _append_group( + routine, + lines, + I18n.t("Elemente"), + report.changes_of(SeasonUpgradeCheck.KIND_MISSING_CODE), + I18n.t("nicht im Katalog") + ) + _append_group( + routine, + lines, + I18n.t("Base Values"), + report.changes_of(SeasonUpgradeCheck.KIND_VALUE_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Elementtyp"), + report.changes_of(SeasonUpgradeCheck.KIND_TYPE_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Features"), + report.changes_of(SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE), + I18n.t("in der Ziel-Saison unbekannt") + ) + _append_group( + routine, + lines, + I18n.t("Level"), + report.changes_of(SeasonUpgradeCheck.KIND_LEVEL_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Kategorie"), + report.changes_of(SeasonUpgradeCheck.KIND_CATEGORY_CHANGE) + ) + var missing_category := report.changes_of( + SeasonUpgradeCheck.KIND_CATEGORY_MISSING + ) + if not missing_category.is_empty(): + lines.append("") + lines.append("[b]%s[/b]" % I18n.t("Kategorie")) + lines.append( + "● %s: %s" + % [ + _escape(missing_category[0].label), + I18n.t("in der Ziel-Saison nicht vorhanden"), + ] + ) + + lines.append("") + lines.append("[b]%s[/b]" % I18n.t("Summe")) + if report.base_value_before > 0.0 or report.base_value_after > 0.0: + lines.append( + I18n.t("Basiswert %s → %s (%s%s)") + % [ + _base_value(report.base_value_before), + _base_value(report.base_value_after), + "+" if report.value_delta() >= 0.0 else "−", + _base_value(absf(report.value_delta())), + ] + ) + else: + lines.append(I18n.t("Keine Elemente mit Base Value.")) + + if not report.issues.is_empty(): + lines.append("") + lines.append( + "[b]%s[/b]" % I18n.t("Befunde bei Prüfung gegen %s") % report.target_season + ) + for issue: ValidationIssue in report.issues: + var color := ( + "#ef4444" + if issue.severity == ValidationIssue.Severity.ERROR + else "#f59e0b" + ) + lines.append( + "[color=%s]●[/color] %s%s" + % [ + color, + _escape(issue.message), + _location(routine, issue.section_id), + ] + ) + return lines + + +static func _append_group( + routine: Routine, + lines: PackedStringArray, + title: String, + changes: Array, + suffix: String = "" +) -> void: + if changes.is_empty(): + return + lines.append("") + lines.append("[b]%s[/b]" % title) + for change: SeasonUpgradeCheck.Change in changes: + var text := _escape(change.label) + if change.kind == SeasonUpgradeCheck.KIND_MISSING_CODE: + text += ": " + I18n.t("nicht im Katalog") + elif change.kind == SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE: + text += ": %s — %s" % [ + I18n.t("Feature"), + _escape(change.before), + ] + if not suffix.is_empty(): + text += " " + suffix + elif change.kind == SeasonUpgradeCheck.KIND_CATEGORY_CHANGE: + text = "%s: %s → %s" % [ + _escape(change.label), + _escape(change.before), + _escape(change.after), + ] + elif change.after.is_empty(): + text += ": " + _escape(change.before) + else: + text += ": %s → %s" % [ + _escape(change.before), + _escape(change.after), + ] + text += _location(routine, change.section_id) + lines.append("● %s" % text) + + +static func _location(routine: Routine, section_id: String) -> String: + if section_id.is_empty() or routine == null: + return "" + if routine.sections.size() < 2: + return "" + var section := routine.get_section_by_id(section_id) + if section == null: + return "" + return " (%s)" % I18n.section_title(section.title) + + +static func _escape(text: String) -> String: + return text.replace("[", "[lb]") + + +static func _base_value(value: float) -> String: + return ("%.2f" % value).replace(".", ",") diff --git a/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid b/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid new file mode 100644 index 0000000..e304526 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid @@ -0,0 +1 @@ +uid://boq3jg287aydi diff --git a/rinkplanner/tests/run_rules_audit_tests.gd b/rinkplanner/tests/run_rules_audit_tests.gd index 33f4514..bd41066 100644 --- a/rinkplanner/tests/run_rules_audit_tests.gd +++ b/rinkplanner/tests/run_rules_audit_tests.gd @@ -19,6 +19,7 @@ func _init() -> void: _test_broken_fixture_is_reported() _test_season_pair_difference() _test_upgrade_check() + _test_season_comparison_text() _cleanup() _finish() @@ -264,6 +265,32 @@ func _test_upgrade_check() -> void: ) + +## Der Text des Saisonvergleichs ist reine Formatierung und damit testbar. +func _test_season_comparison_text() -> void: + var library := RulesLibrary.scan() + var current := library.get_package("2026/27") + var older := library.get_package("2025/26") + if current == null or older == null: + _check(false, "both seasons load for the comparison text") + return + var routine := _make_pair_routine() + routine.adult_category = "gold" + var report := SeasonUpgradeCheck.run(routine, current, older) + var text := "\n".join(SeasonComparisonText.build(routine, report)) + _check( + text.contains("2026/27") and text.contains("2025/26"), + "the comparison text names both seasons" + ) + _check(text.contains("[b]Elemente[/b]"), "the text has the element group") + _check(text.contains("ChSp"), "the text names the missing element") + _check(text.contains("[b]Summe[/b]"), "the text sums the base values") + _check( + text.contains("Befunde bei Prüfung gegen 2025/26"), + "the text adds the findings of the target season" + ) + + func _make_pair_routine() -> Routine: var routine := Routine.new() routine.routine_id = "season-pair"