feat: Elementvalidierung mit Pruefdialog
- RoutineValidator und ValidationIssue gegen Katalog und Level-Regeln - Prueft Kuerzel/Typ/Level, Feature-Auswahl, Level-Abgleich sowie ChSq- und Sprung-Sonderfaelle - Programmweite once_per_program-Features als Warnung - Pruefen-Button und Dialog in der Statusleiste, nicht blockierend - 28 Validierungs-Assertions, Whiteboard-Tests auf 233 erweitert (866 gesamt) - Doku: isu-rules, Findings, Architektur und Roadmap aktualisiert
This commit is contained in:
parent
0613ffca3e
commit
223a072f5d
17 changed files with 1017 additions and 15 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
Stand: 2026-10-31
|
Stand: 2026-10-31
|
||||||
Grundlage: `rinkplanner/rinkplanner_definition_agent_guidelines.md`
|
Grundlage: `rinkplanner/rinkplanner_definition_agent_guidelines.md`
|
||||||
Übergeordnete Reihenfolge: `docs/roadmap.md`
|
Übergeordnete Reihenfolge: `docs/roadmap.md`
|
||||||
Letzte Session: `docs/findings-2026-10-31-isu-levels.md`
|
Letzte Session: `docs/findings-2026-10-31-validierung.md`
|
||||||
(Session davor: `docs/findings-2026-10-31-isu-katalog.md`)
|
(Session davor: `docs/findings-2026-10-31-isu-levels.md`)
|
||||||
|
|
||||||
## 1. Leitentscheidung
|
## 1. Leitentscheidung
|
||||||
|
|
||||||
|
|
@ -64,6 +64,8 @@ Implementiert in `rinkplanner/src/core/rules/`:
|
||||||
| `ElementCatalog` | saisonaler JSON-Katalog, Lookup nach Kürzel/Level, Vorschläge, Prüfung |
|
| `ElementCatalog` | saisonaler JSON-Katalog, Lookup nach Kürzel/Level, Vorschläge, Prüfung |
|
||||||
| `ElementFeature` | Level-Feature mit Zählgrenze und Programm-Flag |
|
| `ElementFeature` | Level-Feature mit Zählgrenze und Programm-Flag |
|
||||||
| `ElementLevelRules` | saisonale Feature-Sätze, Pflichtfeatures und Level-Berechnung |
|
| `ElementLevelRules` | saisonale Feature-Sätze, Pflichtfeatures und Level-Berechnung |
|
||||||
|
| `RoutineValidator` | prüft Elementdaten gegen Katalog und Level-Regeln |
|
||||||
|
| `ValidationIssue` | Befund mit Schweregrad, Meldung und Abschnitts-/Segmentbezug |
|
||||||
|
|
||||||
### Entscheidungen
|
### Entscheidungen
|
||||||
|
|
||||||
|
|
@ -128,6 +130,16 @@ und zeigt es an, ersetzt aber das manuell gewählte `element_level` nicht
|
||||||
stillschweigend. So bleiben Altdaten und bewusste Overrides sichtbar, und die
|
stillschweigend. So bleiben Altdaten und bewusste Overrides sichtbar, und die
|
||||||
spätere Validierung kann Abweichungen melden.
|
spätere Validierung kann Abweichungen melden.
|
||||||
|
|
||||||
|
**D10 – Validierung liefert Befunde statt eines Ja/Nein.**
|
||||||
|
`RoutineValidator` prüft Elementdaten gegen Katalog und Level-Regeln und
|
||||||
|
liefert `ValidationIssue`-Objekte mit Schweregrad (Fehler/Warnung), Meldung
|
||||||
|
und Abschnitts-/Segmentbezug. Die Prüfung ist bewusst getrennt von
|
||||||
|
`Routine.validate()`: Das Modell prüft Struktur und Pfade, der Validator
|
||||||
|
prüft fachliche Elementdaten. Die Oberfläche zeigt die Befunde in einem
|
||||||
|
Dialog; sie blockiert Speichern oder Export nicht. Noch nicht abgedeckt sind
|
||||||
|
Programmtypen, Elementanzahl, Wiederholungs-/Kombinationsregeln und die
|
||||||
|
Begrenzung auf zwei Features pro Fuß.
|
||||||
|
|
||||||
## 4. View- und Controller-Grenzen
|
## 4. View- und Controller-Grenzen
|
||||||
|
|
||||||
- **View** (`Node2D`/`Control`) liest das Modell und zeichnet. Sie verändert
|
- **View** (`Node2D`/`Control`) liest das Modell und zeichnet. Sie verändert
|
||||||
|
|
@ -178,6 +190,10 @@ spätere Validierung kann Abweichungen melden.
|
||||||
gewählten Level; das gewählte Level bleibt autoritativ.
|
gewählten Level; das gewählte Level bleibt autoritativ.
|
||||||
Die Timing-Details (Dauer/Tempo/Profil) werden beim Setzen und für
|
Die Timing-Details (Dauer/Tempo/Profil) werden beim Setzen und für
|
||||||
Punktmarker ausgeblendet, damit die Leiste auch im Landscape kompakt bleibt.
|
Punktmarker ausgeblendet, damit die Leiste auch im Landscape kompakt bleibt.
|
||||||
|
- **Prüfung:** Der Button „Prüfen“ in der Statusleiste validiert alle
|
||||||
|
Elementsegmente gegen Katalog und Level-Regeln. Der Dialog listet Fehler
|
||||||
|
und Warnungen mit Abschnitt und Element; ein leeres Ergebnis wird positiv
|
||||||
|
bestätigt. Speichern und Export bleiben möglich.
|
||||||
- **Section-Verwaltung:** Ein Panel rechts zeigt die chronologische
|
- **Section-Verwaltung:** Ein Panel rechts zeigt die chronologische
|
||||||
Abschnittsliste. Neue Sections werden angelegt, umbenannt, gelöscht und
|
Abschnittsliste. Neue Sections werden angelegt, umbenannt, gelöscht und
|
||||||
hoch-/runtergeschoben; `sequence_order` wird nach jeder Änderung
|
hoch-/runtergeschoben; `sequence_order` wird nach jeder Änderung
|
||||||
|
|
@ -332,15 +348,18 @@ Aktueller Stand:
|
||||||
schwierige Variationen, Level-4-Voraussetzungen, Pflichtfeatures bei
|
schwierige Variationen, Level-4-Voraussetzungen, Pflichtfeatures bei
|
||||||
Schrittsequenzen, feste Level (`ChSq`), Feature-Validierung und die
|
Schrittsequenzen, feste Level (`ChSq`), Feature-Validierung und die
|
||||||
Speicherung am Segment.
|
Speicherung am Segment.
|
||||||
|
- **Validierung:** 28 Assertions für unbekannte Kürzel, Typ-Mismatches,
|
||||||
|
nicht verfügbare Level, Sprung-/ChSq-Sonderfälle, Feature-Fehler,
|
||||||
|
Pflichtfeatures, Level-Abweichungen und programmweite Einmal-Features.
|
||||||
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
||||||
Rink-Kontur und die reine Bogen-Geometrie.
|
Rink-Kontur und die reine Bogen-Geometrie.
|
||||||
- **Whiteboard:** 228 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
- **Whiteboard:** 233 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
||||||
Linien-/Bogenpfade, Klemmen an der Bande, Auswahl, Griff- und
|
Linien-/Bogenpfade, Klemmen an der Bande, Auswahl, Griff- und
|
||||||
Richtungs-/Kanten-Bearbeitung, Segmentlöschung, Element-Marker (Setzen,
|
Richtungs-/Kanten-Bearbeitung, Segmentlöschung, Element-Marker (Setzen,
|
||||||
Typwechsel, Inspector inkl. Standzeit, Base-Value- und Feature-Hinweis,
|
Typwechsel, Inspector inkl. Standzeit, Base-Value- und Feature-Hinweis,
|
||||||
Feature-Menü, Verschieben, Löschen), Section-Verwaltung,
|
Feature-Menü, Verschieben, Löschen), Section-Verwaltung,
|
||||||
Ghosting-Zustand, Segment-Labels inklusive Dialog und Sichtbarkeits-Schalter,
|
Ghosting-Zustand, Segment-Labels inklusive Dialog und Sichtbarkeits-Schalter,
|
||||||
Speichern/Laden, Schema-Prüfung, Dirty-State,
|
Speichern/Laden, Schema-Prüfung, Dirty-State, Prüfdialog,
|
||||||
Navigationsmodus und den Maus-Drag-Pfad.
|
Navigationsmodus und den Maus-Drag-Pfad.
|
||||||
- **History:** 53 Assertions für Undo/Redo von Segmenten, Kanten, Labels, Sections,
|
- **History:** 53 Assertions für Undo/Redo von Segmenten, Kanten, Labels, Sections,
|
||||||
Zeichengesten und Griff-Bearbeitung, Toolbar-Buttons, Erhalt der Ansicht
|
Zeichengesten und Griff-Bearbeitung, Toolbar-Buttons, Erhalt der Ansicht
|
||||||
|
|
|
||||||
94
docs/findings-2026-10-31-validierung.md
Normal file
94
docs/findings-2026-10-31-validierung.md
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
# Findings – Session: Elementvalidierung (2026-10-31)
|
||||||
|
|
||||||
|
Ergänzung zu `docs/findings-2026-10-31-isu-levels.md`.
|
||||||
|
Nach Katalog und Level-Features folgt die dritte ISU-Ausbaustufe: eine
|
||||||
|
strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
|
||||||
|
|
||||||
|
## Ergebnis
|
||||||
|
|
||||||
|
| Ziel | Ergebnis |
|
||||||
|
| :--- | :--- |
|
||||||
|
| Prüfmodell | `RoutineValidator` + `ValidationIssue` in `src/core/rules/` |
|
||||||
|
| Prüfumfang | Kürzel, Typ, Level, Feature-Auswahl, Level-Abgleich, Einmal-Features |
|
||||||
|
| Befunde | Schweregrad, deutsche Meldung, Abschnitts- und Segmentbezug |
|
||||||
|
| Oberfläche | Button „Prüfen“ in der Statusleiste, Dialog mit Fehlern/Warnungen |
|
||||||
|
| Verhalten | Prüfung ist nicht blockierend; Speichern und Export bleiben möglich |
|
||||||
|
| Tests | 866 Assertions gesamt, `./tools/test.sh` grün (neu: 28 Validierung) |
|
||||||
|
|
||||||
|
## Entscheidungen
|
||||||
|
|
||||||
|
- **Getrennt von `Routine.validate()`.** Das Modell prüft weiterhin Struktur,
|
||||||
|
Pfade und Rink-Grenzen. `RoutineValidator` prüft fachliche Elementdaten
|
||||||
|
gegen Katalog und Level-Regeln. So bleibt das Modell unabhängig von
|
||||||
|
saisonalen Daten.
|
||||||
|
- **Befunde statt Ja/Nein.** Jeder Befund trägt `severity`, `message`,
|
||||||
|
`section_id` und `segment_id`. Die UI kann Fehler und Warnungen
|
||||||
|
unterscheiden und auf die Quelle zeigen.
|
||||||
|
- **Deutsche, Nutzer-nahe Meldungen.** Die Meldungen nennen Kürzel, Level
|
||||||
|
und ggf. das erste Segment, z. B. „Kürzel „ChStSq“ ist nicht im Katalog
|
||||||
|
2025/26.“
|
||||||
|
- **Nicht blockierend.** Die Prüfung ist ein Hinweis, keine Speichersperre.
|
||||||
|
Unvollständige Kür während der Arbeit bleiben speicherbar.
|
||||||
|
- **Einmal-Features als Warnung.** `once_per_program` aus den Level-Daten
|
||||||
|
wird programmweit ausgewertet: Das erste Vorkommen merkt sich das Segment,
|
||||||
|
weitere Vorkommen erzeugen eine Warnung mit Verweis auf das erste Segment.
|
||||||
|
- **`ChSq` und Sprünge als Sonderfälle.** `ChSq` muss das feste Level 1
|
||||||
|
tragen; Sprünge mit Level ungleich 0 und mit Features werden gewarnt.
|
||||||
|
|
||||||
|
## Geprüfte Fälle
|
||||||
|
|
||||||
|
- Kürzel nicht im Katalog
|
||||||
|
- Kürzel gehört zu einem anderen Elementtyp
|
||||||
|
- Level ist für die Elementfamilie nicht verfügbar
|
||||||
|
- `ChSq` mit falschem Level
|
||||||
|
- Sprung mit Level ungleich 0
|
||||||
|
- Sprung mit Level-Features
|
||||||
|
- Element ohne Kürzel (Warnung)
|
||||||
|
- unbekanntes Feature
|
||||||
|
- Feature zu oft gewählt (z. B. drei schwierige Variationen)
|
||||||
|
- Pflichtfeature einer Schrittsequenz fehlt
|
||||||
|
- Feature-Ergebnis weicht vom gewählten Level ab
|
||||||
|
- Feature mit `once_per_program` in mehreren Elementen
|
||||||
|
|
||||||
|
## Oberfläche
|
||||||
|
|
||||||
|
- Der Button **Prüfen** sitzt links neben „Segment löschen“ in der
|
||||||
|
Statusleiste.
|
||||||
|
- Der Dialog `Kür prüfen` zeigt eine Zusammenfassung (`n Fehler, m Warnungen`)
|
||||||
|
und darunter die Befunde mit farbigem Punkt, Schweregrad, Abschnitt, Element
|
||||||
|
und Meldung.
|
||||||
|
- Ein leeres Ergebnis wird positiv bestätigt: „Keine Befunde. Alle Elemente
|
||||||
|
passen zu Katalog und Level-Regeln.“
|
||||||
|
- Die Dialoggröße wird auf die Viewport-Größe begrenzt, damit sie auch in
|
||||||
|
kleinen Fenstern und im Headless-Test positionierbar bleibt.
|
||||||
|
|
||||||
|
## Grenzen
|
||||||
|
|
||||||
|
1. **Programmtyp und Elementanzahl:** Es gibt noch kein Modell für
|
||||||
|
Kurzprogramm/Kür, Adult-Level oder erlaubte Elementanzahl.
|
||||||
|
2. **Wiederholungen und Kombinationen:** Sprungkombinationen und -folgen sind
|
||||||
|
Freitext; Wiederholungsregeln werden nicht geprüft.
|
||||||
|
3. **Max. zwei Features pro Fuß:** Das Modell kennt keine Füße, die
|
||||||
|
Begrenzung bleibt offen.
|
||||||
|
4. **Feature-Positionsregeln:** „Feature nicht zusammen mit einer bereits
|
||||||
|
verwendeten Variationsposition“ ist nicht modelliert.
|
||||||
|
5. **Adult-Abweichungen:** Geprüft wird das reguläre ISU-Regelwerk 2025/26.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
Neu: `tests/run_validation_tests.gd` (28 Assertions)
|
||||||
|
|
||||||
|
- saubere Kür ohne Befunde
|
||||||
|
- unbekanntes Kürzel, Typ-Mismatch, nicht verfügbares Level
|
||||||
|
- Sprung-Level/-Features, festes `ChSq`-Level
|
||||||
|
- fehlendes Kürzel
|
||||||
|
- unbekanntes/überzähliges Feature, fehlendes Pflichtfeature
|
||||||
|
- Level-Abweichung
|
||||||
|
- programmweites Einmal-Feature mit Verweis auf das erste Segment
|
||||||
|
- fehlendes Regelwerk
|
||||||
|
|
||||||
|
Erweitert: `tests/run_whiteboard_tests.gd` (228 → 233 Assertions) prüft
|
||||||
|
`validate_routine()`, den Prüfdialog mit Fehlertext und eine saubere Kür.
|
||||||
|
|
||||||
|
Visuell geprüft über `tests/manual/capture_elements.gd ... validate` bei
|
||||||
|
1400 × 876.
|
||||||
|
|
@ -157,6 +157,23 @@ abgeleitete Level und – bei Abweichung – das manuell gewählte Level, z. B.
|
||||||
`Features: 2 · Level 2 · gewählt: Level 4`. Das gewählte Level bleibt
|
`Features: 2 · Level 2 · gewählt: Level 4`. Das gewählte Level bleibt
|
||||||
autoritativ; die Feature-Prüfung ersetzt es nicht stillschweigend.
|
autoritativ; die Feature-Prüfung ersetzt es nicht stillschweigend.
|
||||||
|
|
||||||
|
## Prüfung
|
||||||
|
|
||||||
|
`RoutineValidator` prüft alle Elementsegmente gegen Katalog und Level-Regeln
|
||||||
|
und liefert `ValidationIssue`-Befunde mit Schweregrad, Meldung und Bezug zu
|
||||||
|
Abschnitt und Segment. Geprüft werden:
|
||||||
|
|
||||||
|
- unbekannte Kürzel und Kürzel mit falschem Elementtyp
|
||||||
|
- nicht verfügbare Level, Sprung-Level ungleich 0 und das feste Level von `ChSq`
|
||||||
|
- unbekannte Features, zu häufige Features und fehlende Pflichtfeatures
|
||||||
|
- Abweichungen zwischen Feature-Ergebnis und gewähltem Level
|
||||||
|
- Features, die laut Daten nur einmal pro Programm zählen
|
||||||
|
|
||||||
|
Der Button **Prüfen** in der Statusleiste öffnet die Befunde in einem Dialog.
|
||||||
|
Die Prüfung blockiert Speichern und Export nicht. Noch nicht geprüft werden
|
||||||
|
Programmtyp, erlaubte Elementanzahl, Wiederholungs- und Kombinationsregeln
|
||||||
|
sowie die Begrenzung auf zwei Features pro Fuß.
|
||||||
|
|
||||||
## Neue Saison einpflegen
|
## Neue Saison einpflegen
|
||||||
|
|
||||||
1. Neue ISU-Communication (Scale of Values) beschaffen und als JSON nach dem
|
1. Neue ISU-Communication (Scale of Values) beschaffen und als JSON nach dem
|
||||||
|
|
@ -177,9 +194,10 @@ mit ausgeliefert.
|
||||||
|
|
||||||
## Nächste Ausbaustufen
|
## Nächste Ausbaustufen
|
||||||
|
|
||||||
- Programmweite Feature-Grenzen (`once_per_program`, max. 2 Features pro Fuß)
|
- Max. zwei Features pro Fuß und Feature-Positionsregeln
|
||||||
- Abgleich zwischen gewähltem Level und Feature-Ergebnis in der Validierung
|
- Programmtypen, erlaubte Elementanzahl sowie Wiederholungs- und
|
||||||
|
Kombinationsregeln
|
||||||
- GOE-Tabellen und `V`-/Unterrotations-Varianten
|
- GOE-Tabellen und `V`-/Unterrotations-Varianten
|
||||||
- Sprungkombinationen und -folgen als zusammengesetzte Elemente
|
- Sprungkombinationen und -folgen als zusammengesetzte Elemente
|
||||||
- Programmvalidierung (erlaubte Elementanzahl, Wiederholungen, Adult-Regeln)
|
- Adult-spezifische Programmregeln
|
||||||
- Vorschlagsliste im Inspector direkt aus `suggest()`
|
- Vorschlagsliste im Inspector direkt aus `suggest()`
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Rinkplanner – Roadmap
|
# Rinkplanner – Roadmap
|
||||||
|
|
||||||
Stand: 2026-10-31 (ISU-Katalog und Level-Features; Sync-Komfort und UI-Refactoring zurückgestellt)
|
Stand: 2026-10-31 (ISU-Katalog, Level-Features und Elementvalidierung; Sync-Komfort und UI-Refactoring zurückgestellt)
|
||||||
Diese Reihenfolge ist die verbindliche Arbeitsgrundlage für Phase 1. Änderungen
|
Diese Reihenfolge ist die verbindliche Arbeitsgrundlage für Phase 1. Änderungen
|
||||||
nur bewusst und nach Rücksprache. Erkenntnisse der letzten Session:
|
nur bewusst und nach Rücksprache. Erkenntnisse der letzten Session:
|
||||||
`docs/findings-2026-10-30-element-marker.md`.
|
`docs/findings-2026-10-30-element-marker.md`.
|
||||||
|
|
@ -119,8 +119,11 @@ Voraussetzung für Phase 1.
|
||||||
- [x] Features und Kriterien für die Level-Vergabe
|
- [x] Features und Kriterien für die Level-Vergabe
|
||||||
– Pirouetten (14 Features) und Schrittsequenzen (4 Features),
|
– Pirouetten (14 Features) und Schrittsequenzen (4 Features),
|
||||||
Level-Berechnung und Auswahl im Inspector; Details in `docs/isu-rules.md`
|
Level-Berechnung und Auswahl im Inspector; Details in `docs/isu-rules.md`
|
||||||
- [ ] Validierung von Elementen und Kombinationen
|
- [x] Validierung von Elementen (Katalog, Level, Features, Level-Abgleich)
|
||||||
- [ ] Programmweite Feature-Grenzen (`once_per_program`, max. 2 pro Fuß)
|
mit Prüfdialog in der Statusleiste
|
||||||
|
- [x] Programmweite Einmal-Features (`once_per_program`) als Warnung
|
||||||
|
- [ ] Max. zwei Features pro Fuß und Feature-Positionsregeln
|
||||||
|
- [ ] Kombinations-, Wiederholungs- und Programmtyp-Regeln
|
||||||
- [ ] Optional: Kürzelvorschläge im Inspector aus `suggest()`
|
- [ ] Optional: Kürzelvorschläge im Inspector aus `suggest()`
|
||||||
- [ ] Optional: GOE-Tabellen sowie `V`-/Unterrotationsvarianten
|
- [ ] Optional: GOE-Tabellen sowie `V`-/Unterrotationsvarianten
|
||||||
|
|
||||||
|
|
@ -146,11 +149,11 @@ fachlichen Validierung angefasst.
|
||||||
Übernahme des Feedbacks der Tester
|
Übernahme des Feedbacks der Tester
|
||||||
|
|
||||||
Die Reihenfolge ist bewusst: native Builds, Datenaustausch und Element-Marker
|
Die Reihenfolge ist bewusst: native Builds, Datenaustausch und Element-Marker
|
||||||
sind erledigt. Im PoC läuft jetzt das ISU-Regelwerk – Katalog und
|
sind erledigt. Im PoC läuft jetzt das ISU-Regelwerk – Katalog, Level-Features
|
||||||
Level-Features stehen, als Nächstes folgt die Validierung. Sync-Komfort und
|
und Elementvalidierung stehen; als Nächstes folgen Programmregeln und
|
||||||
UI-Refactoring sind zurückgestellt, weil der bestehende Stand für Tests genügt
|
Kombinationen. Sync-Komfort und UI-Refactoring sind zurückgestellt, weil der
|
||||||
und die endgültige Sync-Architektur (PHP-Webserver) sowie das UI-Feedback der
|
bestehende Stand für Tests genügt und die endgültige Sync-Architektur
|
||||||
Tester ohnehin noch ausstehen.
|
(PHP-Webserver) sowie das UI-Feedback der Tester ohnehin noch ausstehen.
|
||||||
|
|
||||||
## Querschnittsaufgaben
|
## Querschnittsaufgaben
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -502,6 +502,14 @@ theme_override_font_sizes/font_size = 15
|
||||||
text = "Abschnitt 1 · 0 Segmente"
|
text = "Abschnitt 1 · 0 Segmente"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="ValidationButton" type="Button" parent="Layout/StatusBar/StatusBarContent"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(120, 56)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_font_sizes/font_size = 15
|
||||||
|
text = "Prüfen"
|
||||||
|
tooltip_text = "Elemente gegen Katalog und Level-Regeln prüfen"
|
||||||
|
|
||||||
[node name="DeleteSegmentButton" type="Button" parent="Layout/StatusBar/StatusBarContent"]
|
[node name="DeleteSegmentButton" type="Button" parent="Layout/StatusBar/StatusBarContent"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(160, 56)
|
custom_minimum_size = Vector2(160, 56)
|
||||||
|
|
@ -932,3 +940,19 @@ text = "Ziel: user://exports"
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
hide_on_item_selection = false
|
hide_on_item_selection = false
|
||||||
hide_on_checkable_item_selection = false
|
hide_on_checkable_item_selection = false
|
||||||
|
|
||||||
|
[node name="ValidationDialog" type="AcceptDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
title = "Kür prüfen"
|
||||||
|
size = Vector2i(720, 520)
|
||||||
|
ok_button_text = "Schließen"
|
||||||
|
|
||||||
|
[node name="ValidationText" type="RichTextLabel" parent="ValidationDialog"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
offset_left = 12.0
|
||||||
|
offset_top = 12.0
|
||||||
|
offset_right = 708.0
|
||||||
|
offset_bottom = 456.0
|
||||||
|
bbcode_enabled = true
|
||||||
|
scroll_active = true
|
||||||
|
selection_enabled = true
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,16 @@ func get_level4_features(type: PathSegment.ElementType) -> PackedStringArray:
|
||||||
return _level4_by_type[type].duplicate()
|
return _level4_by_type[type].duplicate()
|
||||||
|
|
||||||
|
|
||||||
|
## Fixed level for elements that are not feature-based (ChSq), or -1.
|
||||||
|
func get_fixed_level(type: PathSegment.ElementType, code: String) -> int:
|
||||||
|
if type != PathSegment.ElementType.SEQUENCE:
|
||||||
|
return -1
|
||||||
|
var key := _normalize(code)
|
||||||
|
if not _fixed_levels.has(key):
|
||||||
|
return -1
|
||||||
|
return _fixed_levels[key]
|
||||||
|
|
||||||
|
|
||||||
func get_thresholds() -> Array[Dictionary]:
|
func get_thresholds() -> Array[Dictionary]:
|
||||||
var copy: Array[Dictionary] = []
|
var copy: Array[Dictionary] = []
|
||||||
copy.assign(_thresholds)
|
copy.assign(_thresholds)
|
||||||
|
|
|
||||||
296
rinkplanner/src/core/rules/routine_validator.gd
Normal file
296
rinkplanner/src/core/rules/routine_validator.gd
Normal file
|
|
@ -0,0 +1,296 @@
|
||||||
|
class_name RoutineValidator
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
## Validates the element data of a routine against the season's catalog and
|
||||||
|
## level rules. It does not validate paths or section bookkeeping (the model
|
||||||
|
## does that) and it does not know program types, element counts, jump
|
||||||
|
## combinations or repetition limits yet.
|
||||||
|
|
||||||
|
var _catalog: ElementCatalog
|
||||||
|
var _rules: ElementLevelRules
|
||||||
|
|
||||||
|
|
||||||
|
func _init(catalog: ElementCatalog, rules: ElementLevelRules) -> void:
|
||||||
|
_catalog = catalog
|
||||||
|
_rules = rules
|
||||||
|
|
||||||
|
|
||||||
|
## Returns all findings in section order. An empty array means the element
|
||||||
|
## data is consistent with the loaded rule set.
|
||||||
|
func validate(routine: Routine) -> Array[ValidationIssue]:
|
||||||
|
var issues: Array[ValidationIssue] = []
|
||||||
|
if routine == null:
|
||||||
|
issues.append(_issue(ValidationIssue.Severity.ERROR, "Keine Kür geladen."))
|
||||||
|
return issues
|
||||||
|
if _catalog == null or _rules == null:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Regelwerk ist nicht geladen; Prüfung nicht möglich."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return issues
|
||||||
|
|
||||||
|
var seen_once: Dictionary[String, String] = {}
|
||||||
|
for section: RoutineSection in routine.sections:
|
||||||
|
if section == null:
|
||||||
|
continue
|
||||||
|
for segment: PathSegment in section.segments:
|
||||||
|
if segment == null or not segment.is_element():
|
||||||
|
continue
|
||||||
|
_validate_segment(segment, section.section_id, issues)
|
||||||
|
_collect_program_features(
|
||||||
|
segment,
|
||||||
|
section.section_id,
|
||||||
|
seen_once,
|
||||||
|
issues
|
||||||
|
)
|
||||||
|
|
||||||
|
return issues
|
||||||
|
|
||||||
|
|
||||||
|
func _validate_segment(
|
||||||
|
segment: PathSegment,
|
||||||
|
section_id: String,
|
||||||
|
issues: Array[ValidationIssue]
|
||||||
|
) -> void:
|
||||||
|
var code := segment.element_code.strip_edges()
|
||||||
|
if code.is_empty():
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Element ohne Kürzel; Base Value und Level sind nicht prüfbar.",
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
var definition := _catalog.find(code)
|
||||||
|
if definition == null:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Kürzel „%s“ ist nicht im Katalog %s."
|
||||||
|
% [code, _catalog.season],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif definition.element_type != segment.element_type:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Kürzel „%s“ gehört zu %s, nicht zu %s."
|
||||||
|
% [
|
||||||
|
code,
|
||||||
|
PathSegment.element_type_name(definition.element_type),
|
||||||
|
PathSegment.element_type_name(segment.element_type),
|
||||||
|
],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
var fixed_level := _rules.get_fixed_level(segment.element_type, code)
|
||||||
|
if fixed_level >= 0:
|
||||||
|
if segment.element_level != fixed_level:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"„%s“ ist fest %s (gewählt: %s)."
|
||||||
|
% [
|
||||||
|
code,
|
||||||
|
ElementDefinition.level_label(fixed_level),
|
||||||
|
ElementDefinition.level_label(segment.element_level),
|
||||||
|
],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif (
|
||||||
|
definition != null
|
||||||
|
and definition.element_type == segment.element_type
|
||||||
|
):
|
||||||
|
if definition.is_leveled():
|
||||||
|
if not definition.has_level(segment.element_level):
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"%s ist für „%s“ nicht verfügbar."
|
||||||
|
% [
|
||||||
|
ElementDefinition.level_label(segment.element_level),
|
||||||
|
code,
|
||||||
|
],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif segment.element_level != 0:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"„%s“ hat Level %d; Sprünge sind nicht levelbar."
|
||||||
|
% [code, segment.element_level],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
_validate_features(segment, code, section_id, issues)
|
||||||
|
|
||||||
|
|
||||||
|
func _validate_features(
|
||||||
|
segment: PathSegment,
|
||||||
|
code: String,
|
||||||
|
section_id: String,
|
||||||
|
issues: Array[ValidationIssue]
|
||||||
|
) -> void:
|
||||||
|
if segment.element_type == PathSegment.ElementType.JUMP:
|
||||||
|
if not segment.element_features.is_empty():
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"„%s“ hat %d Level-Features; Sprünge sind nicht levelbar."
|
||||||
|
% [code, segment.element_features.size()],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
var counts: Dictionary[String, int] = {}
|
||||||
|
for raw: String in segment.element_features:
|
||||||
|
var feature_code := raw.strip_edges()
|
||||||
|
if feature_code.is_empty():
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Leerer Feature-Code bei „%s“." % code,
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
var feature := _rules.get_feature(segment.element_type, feature_code)
|
||||||
|
if feature == null:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Unbekanntes Feature „%s“ für „%s“." % [raw, code],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
var used: int = counts.get(feature_code, 0)
|
||||||
|
if used >= feature.max_per_element:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Feature „%s“ ist bei „%s“ zu oft gewählt (max. %d)."
|
||||||
|
% [feature.display_name, code, feature.max_per_element],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
counts[feature_code] = used + 1
|
||||||
|
|
||||||
|
if segment.element_features.is_empty():
|
||||||
|
return
|
||||||
|
|
||||||
|
for required: String in _rules.get_required_features(segment.element_type):
|
||||||
|
if counts.has(required):
|
||||||
|
continue
|
||||||
|
var required_feature := _rules.get_feature(
|
||||||
|
segment.element_type,
|
||||||
|
required
|
||||||
|
)
|
||||||
|
var required_name := (
|
||||||
|
required_feature.display_name if required_feature != null else required
|
||||||
|
)
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Pflichtfeature fehlt bei „%s“: %s."
|
||||||
|
% [code, required_name],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
var result := _rules.calculate_level(
|
||||||
|
segment.element_type,
|
||||||
|
code,
|
||||||
|
segment.element_features
|
||||||
|
)
|
||||||
|
if not result.missing_required.is_empty():
|
||||||
|
return
|
||||||
|
if not result.ignored_features.is_empty():
|
||||||
|
return
|
||||||
|
if result.level != segment.element_level:
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Features ergeben bei „%s“ %s, gewählt ist %s."
|
||||||
|
% [
|
||||||
|
code,
|
||||||
|
ElementDefinition.level_label(result.level),
|
||||||
|
ElementDefinition.level_label(segment.element_level),
|
||||||
|
],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
## Features marked as once-per-program may only count in the first element
|
||||||
|
## that uses them. The technical rule additionally depends on categories and
|
||||||
|
## positions; the data flag is the simplified part that can be checked today.
|
||||||
|
func _collect_program_features(
|
||||||
|
segment: PathSegment,
|
||||||
|
section_id: String,
|
||||||
|
seen_once: Dictionary[String, String],
|
||||||
|
issues: Array[ValidationIssue]
|
||||||
|
) -> void:
|
||||||
|
for raw: String in segment.element_features:
|
||||||
|
var feature := _rules.get_feature(
|
||||||
|
segment.element_type,
|
||||||
|
raw.strip_edges()
|
||||||
|
)
|
||||||
|
if feature == null or not feature.once_per_program:
|
||||||
|
continue
|
||||||
|
var key := feature.code.to_lower()
|
||||||
|
if seen_once.has(key):
|
||||||
|
issues.append(
|
||||||
|
_issue(
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Feature „%s“ zählt nur einmal pro Programm (zuerst in Segment „%s“)."
|
||||||
|
% [feature.display_name, seen_once[key]],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
seen_once[key] = segment.segment_id
|
||||||
|
|
||||||
|
|
||||||
|
static func count_severity(
|
||||||
|
issues: Array[ValidationIssue],
|
||||||
|
severity: int
|
||||||
|
) -> int:
|
||||||
|
var count := 0
|
||||||
|
for issue: ValidationIssue in issues:
|
||||||
|
if issue.severity == severity:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
func _issue(
|
||||||
|
severity: ValidationIssue.Severity,
|
||||||
|
message: String,
|
||||||
|
section_id: String = "",
|
||||||
|
segment_id: String = ""
|
||||||
|
) -> ValidationIssue:
|
||||||
|
return ValidationIssue.new(severity, message, section_id, segment_id)
|
||||||
1
rinkplanner/src/core/rules/routine_validator.gd.uid
Normal file
1
rinkplanner/src/core/rules/routine_validator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cqkqfkkh0blq4
|
||||||
37
rinkplanner/src/core/rules/validation_issue.gd
Normal file
37
rinkplanner/src/core/rules/validation_issue.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
class_name ValidationIssue
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
## One finding from [RoutineValidator]. Messages are user-facing German; the
|
||||||
|
## section and segment IDs allow the UI to point at the source.
|
||||||
|
|
||||||
|
enum Severity {
|
||||||
|
INFO,
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
}
|
||||||
|
|
||||||
|
var severity: Severity = Severity.INFO
|
||||||
|
var message: String = ""
|
||||||
|
var section_id: String = ""
|
||||||
|
var segment_id: String = ""
|
||||||
|
|
||||||
|
|
||||||
|
func _init(
|
||||||
|
p_severity: Severity = Severity.INFO,
|
||||||
|
p_message: String = "",
|
||||||
|
p_section_id: String = "",
|
||||||
|
p_segment_id: String = ""
|
||||||
|
) -> void:
|
||||||
|
severity = p_severity
|
||||||
|
message = p_message
|
||||||
|
section_id = p_section_id
|
||||||
|
segment_id = p_segment_id
|
||||||
|
|
||||||
|
|
||||||
|
func severity_label() -> String:
|
||||||
|
match severity:
|
||||||
|
Severity.ERROR:
|
||||||
|
return "Fehler"
|
||||||
|
Severity.WARNING:
|
||||||
|
return "Warnung"
|
||||||
|
return "Hinweis"
|
||||||
1
rinkplanner/src/core/rules/validation_issue.gd.uid
Normal file
1
rinkplanner/src/core/rules/validation_issue.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://jct14gm67ytr
|
||||||
|
|
@ -51,6 +51,7 @@ const EXPORTS_DIR := "user://exports"
|
||||||
const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn")
|
const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn")
|
||||||
const ELEMENT_CATALOG_SCRIPT := preload("res://src/core/rules/element_catalog.gd")
|
const ELEMENT_CATALOG_SCRIPT := preload("res://src/core/rules/element_catalog.gd")
|
||||||
const ELEMENT_LEVEL_RULES_SCRIPT := preload("res://src/core/rules/element_level_rules.gd")
|
const ELEMENT_LEVEL_RULES_SCRIPT := preload("res://src/core/rules/element_level_rules.gd")
|
||||||
|
const ROUTINE_VALIDATOR_SCRIPT := preload("res://src/core/rules/routine_validator.gd")
|
||||||
const FEATURE_MENU_RESET_ID := 1000000
|
const FEATURE_MENU_RESET_ID := 1000000
|
||||||
const EXPORT_IMAGE_SIZE := Vector2i(2560, 1600)
|
const EXPORT_IMAGE_SIZE := Vector2i(2560, 1600)
|
||||||
const AUTOSAVE_PATH := "user://autosave.tres"
|
const AUTOSAVE_PATH := "user://autosave.tres"
|
||||||
|
|
@ -116,6 +117,9 @@ const COMPACT_LAYOUT_WIDTH := 1280.0
|
||||||
@onready var element_features_button: Button = %ElementFeaturesButton
|
@onready var element_features_button: Button = %ElementFeaturesButton
|
||||||
@onready var element_feature_hint: Label = %ElementFeatureHint
|
@onready var element_feature_hint: Label = %ElementFeatureHint
|
||||||
@onready var element_feature_menu: PopupMenu = %ElementFeatureMenu
|
@onready var element_feature_menu: PopupMenu = %ElementFeatureMenu
|
||||||
|
@onready var validation_button: Button = %ValidationButton
|
||||||
|
@onready var validation_dialog: AcceptDialog = %ValidationDialog
|
||||||
|
@onready var validation_text: RichTextLabel = %ValidationText
|
||||||
@onready var element_duration_spin: SpinBox = %ElementDurationSpin
|
@onready var element_duration_spin: SpinBox = %ElementDurationSpin
|
||||||
@onready var segment_label_dialog: ConfirmationDialog = %SegmentLabelDialog
|
@onready var segment_label_dialog: ConfirmationDialog = %SegmentLabelDialog
|
||||||
@onready var segment_label_edit: LineEdit = %SegmentLabelEdit
|
@onready var segment_label_edit: LineEdit = %SegmentLabelEdit
|
||||||
|
|
@ -257,6 +261,7 @@ func _ready() -> void:
|
||||||
segment_label_edit.text_submitted.connect(_on_label_submitted)
|
segment_label_edit.text_submitted.connect(_on_label_submitted)
|
||||||
element_button.pressed.connect(_open_element_dialog)
|
element_button.pressed.connect(_open_element_dialog)
|
||||||
element_dialog.confirmed.connect(_on_element_confirmed)
|
element_dialog.confirmed.connect(_on_element_confirmed)
|
||||||
|
validation_button.pressed.connect(open_validation_dialog)
|
||||||
element_type_option.item_selected.connect(_on_element_type_selected)
|
element_type_option.item_selected.connect(_on_element_type_selected)
|
||||||
|
|
||||||
resized.connect(_apply_responsive_layout)
|
resized.connect(_apply_responsive_layout)
|
||||||
|
|
@ -423,6 +428,98 @@ func get_level_rules() -> ElementLevelRules:
|
||||||
return _level_rules
|
return _level_rules
|
||||||
|
|
||||||
|
|
||||||
|
## Cross-checks all element segments against the catalog and level rules.
|
||||||
|
## Paths and section bookkeeping are validated by the model itself.
|
||||||
|
func validate_routine() -> Array[ValidationIssue]:
|
||||||
|
var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new(
|
||||||
|
_element_catalog,
|
||||||
|
_level_rules
|
||||||
|
)
|
||||||
|
return validator.validate(_routine)
|
||||||
|
|
||||||
|
|
||||||
|
## Opens the validation dialog with the current findings.
|
||||||
|
func open_validation_dialog() -> void:
|
||||||
|
var issues := validate_routine()
|
||||||
|
var errors := RoutineValidator.count_severity(
|
||||||
|
issues,
|
||||||
|
ValidationIssue.Severity.ERROR
|
||||||
|
)
|
||||||
|
var warnings := RoutineValidator.count_severity(
|
||||||
|
issues,
|
||||||
|
ValidationIssue.Severity.WARNING
|
||||||
|
)
|
||||||
|
|
||||||
|
var lines := PackedStringArray()
|
||||||
|
if issues.is_empty():
|
||||||
|
lines.append(
|
||||||
|
"[b]Keine Befunde.[/b] Alle Elemente passen zu Katalog und Level-Regeln."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
lines.append(
|
||||||
|
"[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings]
|
||||||
|
)
|
||||||
|
lines.append("")
|
||||||
|
for issue: ValidationIssue in issues:
|
||||||
|
var color := "#ef4444" if issue.severity == ValidationIssue.Severity.ERROR else "#f59e0b"
|
||||||
|
lines.append(
|
||||||
|
"[color=%s]●[/color] [b]%s[/b]%s: %s"
|
||||||
|
% [
|
||||||
|
color,
|
||||||
|
issue.severity_label(),
|
||||||
|
_validation_location(issue),
|
||||||
|
_escape_bbcode(issue.message),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
validation_text.text = "\n".join(lines)
|
||||||
|
var target := Vector2i(720, 520)
|
||||||
|
var viewport_size := Vector2i(get_viewport_rect().size)
|
||||||
|
if viewport_size.x > 0:
|
||||||
|
target.x = mini(target.x, viewport_size.x)
|
||||||
|
if viewport_size.y > 0:
|
||||||
|
target.y = mini(target.y, viewport_size.y)
|
||||||
|
validation_dialog.popup_centered(target)
|
||||||
|
|
||||||
|
|
||||||
|
func _validation_location(issue: ValidationIssue) -> String:
|
||||||
|
var parts := PackedStringArray()
|
||||||
|
if not issue.section_id.is_empty():
|
||||||
|
var section := _routine.get_section_by_id(issue.section_id)
|
||||||
|
parts.append(
|
||||||
|
"Abschnitt „%s“"
|
||||||
|
% (section.title if section != null else issue.section_id)
|
||||||
|
)
|
||||||
|
if not issue.segment_id.is_empty():
|
||||||
|
var segment := _find_routine_segment(issue.segment_id)
|
||||||
|
if segment != null and segment.is_element():
|
||||||
|
var label := segment.element_code.strip_edges()
|
||||||
|
if label.is_empty():
|
||||||
|
label = PathSegment.element_type_name(segment.element_type)
|
||||||
|
parts.append("Element „%s“" % label)
|
||||||
|
else:
|
||||||
|
parts.append(issue.segment_id)
|
||||||
|
if parts.is_empty():
|
||||||
|
return ""
|
||||||
|
return " (%s)" % " · ".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
func _find_routine_segment(segment_id: String) -> PathSegment:
|
||||||
|
if _routine == null or segment_id.is_empty():
|
||||||
|
return null
|
||||||
|
for section: RoutineSection in _routine.sections:
|
||||||
|
if section == null:
|
||||||
|
continue
|
||||||
|
var segment := section.get_segment_by_id(segment_id)
|
||||||
|
if segment != null:
|
||||||
|
return segment
|
||||||
|
return null
|
||||||
|
|
||||||
|
|
||||||
|
static func _escape_bbcode(text: String) -> String:
|
||||||
|
return text.replace("[", "[lb]")
|
||||||
|
|
||||||
|
|
||||||
func get_selected_element_features() -> PackedStringArray:
|
func get_selected_element_features() -> PackedStringArray:
|
||||||
var segment := get_selected_segment()
|
var segment := get_selected_segment()
|
||||||
if segment == null:
|
if segment == null:
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ $GODOT --headless --path rinkplanner --script res://tests/run_rules_tests.gd
|
||||||
# Run ISU level-feature tests
|
# Run ISU level-feature tests
|
||||||
$GODOT --headless --path rinkplanner --script res://tests/run_level_tests.gd
|
$GODOT --headless --path rinkplanner --script res://tests/run_level_tests.gd
|
||||||
|
|
||||||
|
# Run routine element-validation tests
|
||||||
|
$GODOT --headless --path rinkplanner --script res://tests/run_validation_tests.gd
|
||||||
|
|
||||||
# Run canvas transform/geometry tests
|
# Run canvas transform/geometry tests
|
||||||
$GODOT --headless --path rinkplanner --script res://tests/run_canvas_tests.gd
|
$GODOT --headless --path rinkplanner --script res://tests/run_canvas_tests.gd
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ func _capture() -> void:
|
||||||
PackedStringArray(["difficult_variation", "difficult_exit"])
|
PackedStringArray(["difficult_variation", "difficult_exit"])
|
||||||
)
|
)
|
||||||
controller.element_button.pressed.emit()
|
controller.element_button.pressed.emit()
|
||||||
|
elif args.size() > 3 and args[3] == "validate":
|
||||||
|
controller.open_validation_dialog()
|
||||||
elif args.size() > 3 and args[3] == "spin":
|
elif args.size() > 3 and args[3] == "spin":
|
||||||
var elapsed := 0.0
|
var elapsed := 0.0
|
||||||
for segment: PathSegment in controller.get_active_section().segments:
|
for segment: PathSegment in controller.get_active_section().segments:
|
||||||
|
|
|
||||||
356
rinkplanner/tests/run_validation_tests.gd
Normal file
356
rinkplanner/tests/run_validation_tests.gd
Normal file
|
|
@ -0,0 +1,356 @@
|
||||||
|
extends SceneTree
|
||||||
|
|
||||||
|
## Headless tests for routine element validation.
|
||||||
|
##
|
||||||
|
## Run with:
|
||||||
|
## godot --headless --path rinkplanner --script res://tests/run_validation_tests.gd
|
||||||
|
|
||||||
|
const ElementCatalogScript := preload("res://src/core/rules/element_catalog.gd")
|
||||||
|
const ElementLevelRulesScript := preload("res://src/core/rules/element_level_rules.gd")
|
||||||
|
const RoutineValidatorScript := preload("res://src/core/rules/routine_validator.gd")
|
||||||
|
const ValidationIssueScript := preload("res://src/core/rules/validation_issue.gd")
|
||||||
|
const RoutineModel := preload("res://src/core/model/routine.gd")
|
||||||
|
const RoutineSectionModel := preload("res://src/core/model/routine_section.gd")
|
||||||
|
const PathSegmentModel := preload("res://src/core/model/path_segment.gd")
|
||||||
|
|
||||||
|
var _assertions: int = 0
|
||||||
|
var _failures: PackedStringArray = PackedStringArray()
|
||||||
|
var _catalog: ElementCatalog
|
||||||
|
var _rules: ElementLevelRules
|
||||||
|
var _validator: RoutineValidator
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
_catalog = ElementCatalogScript.load_default()
|
||||||
|
_rules = ElementLevelRulesScript.load_default()
|
||||||
|
_validator = RoutineValidatorScript.new(_catalog, _rules)
|
||||||
|
|
||||||
|
_test_clean_routine()
|
||||||
|
_test_unknown_code()
|
||||||
|
_test_type_mismatch()
|
||||||
|
_test_unavailable_level()
|
||||||
|
_test_jump_level_and_features()
|
||||||
|
_test_fixed_level()
|
||||||
|
_test_missing_code()
|
||||||
|
_test_feature_selection()
|
||||||
|
_test_level_mismatch()
|
||||||
|
_test_program_once_features()
|
||||||
|
_test_missing_rules()
|
||||||
|
_finish()
|
||||||
|
|
||||||
|
|
||||||
|
func _test_clean_routine() -> void:
|
||||||
|
var routine := _make_routine()
|
||||||
|
var section := routine.sections[0]
|
||||||
|
_add_marker(
|
||||||
|
section,
|
||||||
|
"spin",
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
4,
|
||||||
|
PackedStringArray(
|
||||||
|
[
|
||||||
|
"difficult_variation",
|
||||||
|
"difficult_variation",
|
||||||
|
"difficult_exit",
|
||||||
|
"change_of_edge",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_add_marker(
|
||||||
|
section,
|
||||||
|
"sequence",
|
||||||
|
PathSegment.ElementType.SEQUENCE,
|
||||||
|
"StSq",
|
||||||
|
4,
|
||||||
|
PackedStringArray(
|
||||||
|
[
|
||||||
|
"variety_of_turns",
|
||||||
|
"both_rotations",
|
||||||
|
"body_movements",
|
||||||
|
"turn_combinations",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
var issues := _validator.validate(routine)
|
||||||
|
_check(issues.is_empty(), "a consistent routine has no findings (%s)" % _messages(issues))
|
||||||
|
|
||||||
|
|
||||||
|
func _test_unknown_code() -> void:
|
||||||
|
var issues := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"3X",
|
||||||
|
0,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "unknown code is an error")
|
||||||
|
_check(_has_message(issues, "nicht im Katalog"), "unknown code message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_type_mismatch() -> void:
|
||||||
|
var issues := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"3Lz",
|
||||||
|
0,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "type mismatch is an error")
|
||||||
|
_check(_has_message(issues, "gehört zu Sprung"), "type mismatch message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_unavailable_level() -> void:
|
||||||
|
var routine := _make_routine()
|
||||||
|
var segment := _add_marker(
|
||||||
|
routine.sections[0],
|
||||||
|
"spin",
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
0,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
segment.element_level = 7
|
||||||
|
var issues := _validator.validate(routine)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
|
"an unavailable level is an error"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "nicht verfügbar"), "unavailable level message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_jump_level_and_features() -> void:
|
||||||
|
var routine := _make_routine()
|
||||||
|
var segment := _add_marker(
|
||||||
|
routine.sections[0],
|
||||||
|
"jump",
|
||||||
|
PathSegment.ElementType.JUMP,
|
||||||
|
"3Lz",
|
||||||
|
2,
|
||||||
|
PackedStringArray(["difficult_exit"])
|
||||||
|
)
|
||||||
|
var issues := _validator.validate(routine)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 2,
|
||||||
|
"jump level and features are two warnings"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "nicht levelbar"), "jump level warning")
|
||||||
|
_check(_has_message(issues, "Level-Features"), "jump feature warning")
|
||||||
|
_check(segment.element_level == 2, "the validator does not mutate the segment")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_fixed_level() -> void:
|
||||||
|
var issues := _validate_one(
|
||||||
|
PathSegment.ElementType.SEQUENCE,
|
||||||
|
"ChSq",
|
||||||
|
2,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
|
"a wrong fixed level is an error"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "fest"), "fixed level message")
|
||||||
|
|
||||||
|
var valid := _validate_one(
|
||||||
|
PathSegment.ElementType.SEQUENCE,
|
||||||
|
"ChSq",
|
||||||
|
1,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
_check(valid.is_empty(), "ChSq at Level 1 is valid")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_missing_code() -> void:
|
||||||
|
var issues := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
|
"a missing code is a warning"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "ohne Kürzel"), "missing code message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_feature_selection() -> void:
|
||||||
|
var unknown := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
0,
|
||||||
|
PackedStringArray(["nope"])
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(unknown, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
|
"an unknown feature is an error"
|
||||||
|
)
|
||||||
|
_check(_has_message(unknown, "Unbekanntes Feature"), "unknown feature message")
|
||||||
|
|
||||||
|
var too_many := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
0,
|
||||||
|
PackedStringArray(
|
||||||
|
["difficult_variation", "difficult_variation", "difficult_variation"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(too_many, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
|
"too many difficult variations is an error"
|
||||||
|
)
|
||||||
|
_check(_has_message(too_many, "zu oft"), "over-limit feature message")
|
||||||
|
|
||||||
|
var missing := _validate_one(
|
||||||
|
PathSegment.ElementType.SEQUENCE,
|
||||||
|
"StSq",
|
||||||
|
1,
|
||||||
|
PackedStringArray(["body_movements"])
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(missing, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
|
"a missing compulsory sequence feature is a warning"
|
||||||
|
)
|
||||||
|
_check(_has_message(missing, "Pflichtfeature fehlt"), "compulsory feature message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_level_mismatch() -> void:
|
||||||
|
var issues := _validate_one(
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
4,
|
||||||
|
PackedStringArray(["difficult_variation", "difficult_exit"])
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
|
"a feature/level mismatch is a warning"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "Features ergeben"), "level mismatch message")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_program_once_features() -> void:
|
||||||
|
var routine := _make_routine()
|
||||||
|
var section := routine.sections[0]
|
||||||
|
_add_marker(
|
||||||
|
section,
|
||||||
|
"spin-a",
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
1,
|
||||||
|
PackedStringArray(["difficult_exit"])
|
||||||
|
)
|
||||||
|
_add_marker(
|
||||||
|
section,
|
||||||
|
"spin-b",
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
1,
|
||||||
|
PackedStringArray(["difficult_exit"])
|
||||||
|
)
|
||||||
|
var issues := _validator.validate(routine)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
|
"repeated once-per-program features warn once per repeated occurrence"
|
||||||
|
)
|
||||||
|
_check(_has_message(issues, "nur einmal pro Programm"), "once-per-program message")
|
||||||
|
_check(
|
||||||
|
_has_message(issues, "zuerst in Segment „spin-a“"),
|
||||||
|
"once-per-program message names the first segment"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _test_missing_rules() -> void:
|
||||||
|
var broken := RoutineValidatorScript.new(null, null)
|
||||||
|
var routine := _make_routine()
|
||||||
|
_add_marker(
|
||||||
|
routine.sections[0],
|
||||||
|
"spin",
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
0,
|
||||||
|
PackedStringArray()
|
||||||
|
)
|
||||||
|
var issues := broken.validate(routine)
|
||||||
|
_check(
|
||||||
|
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
|
"a missing rule set is an error"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _validate_one(
|
||||||
|
type: PathSegment.ElementType,
|
||||||
|
code: String,
|
||||||
|
level: int,
|
||||||
|
features: PackedStringArray
|
||||||
|
) -> Array[ValidationIssue]:
|
||||||
|
var routine := _make_routine()
|
||||||
|
_add_marker(routine.sections[0], "segment", type, code, level, features)
|
||||||
|
return _validator.validate(routine)
|
||||||
|
|
||||||
|
|
||||||
|
func _make_routine() -> Routine:
|
||||||
|
var routine: Routine = RoutineModel.new()
|
||||||
|
routine.routine_id = "validation-test"
|
||||||
|
routine.title = "Validation"
|
||||||
|
var section: RoutineSection = RoutineSectionModel.new()
|
||||||
|
section.section_id = "section-001"
|
||||||
|
section.title = "Abschnitt 1"
|
||||||
|
section.sequence_order = 0
|
||||||
|
var sections: Array[RoutineSection] = [section]
|
||||||
|
routine.sections = sections
|
||||||
|
return routine
|
||||||
|
|
||||||
|
|
||||||
|
func _add_marker(
|
||||||
|
section: RoutineSection,
|
||||||
|
segment_id: String,
|
||||||
|
type: PathSegment.ElementType,
|
||||||
|
code: String,
|
||||||
|
level: int,
|
||||||
|
features: PackedStringArray
|
||||||
|
) -> PathSegment:
|
||||||
|
var segment: PathSegment = PathSegmentModel.new()
|
||||||
|
segment.segment_id = segment_id
|
||||||
|
var curve := Curve2D.new()
|
||||||
|
curve.add_point(Vector2.ZERO)
|
||||||
|
segment.curve = curve
|
||||||
|
segment.set_element(type, code, level)
|
||||||
|
segment.set_element_features(features)
|
||||||
|
section.segments.append(segment)
|
||||||
|
return segment
|
||||||
|
|
||||||
|
|
||||||
|
func _count(issues: Array[ValidationIssue], severity: int) -> int:
|
||||||
|
return RoutineValidatorScript.count_severity(issues, severity)
|
||||||
|
|
||||||
|
|
||||||
|
func _has_message(issues: Array[ValidationIssue], fragment: String) -> bool:
|
||||||
|
for issue: ValidationIssue in issues:
|
||||||
|
if issue.message.contains(fragment):
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
func _messages(issues: Array[ValidationIssue]) -> String:
|
||||||
|
var parts := PackedStringArray()
|
||||||
|
for issue: ValidationIssue in issues:
|
||||||
|
parts.append(issue.message)
|
||||||
|
return "; ".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
func _check(condition: bool, message: String) -> void:
|
||||||
|
_assertions += 1
|
||||||
|
if not condition:
|
||||||
|
_failures.append(message)
|
||||||
|
|
||||||
|
|
||||||
|
func _finish() -> void:
|
||||||
|
if _failures.is_empty():
|
||||||
|
print("PASS: %d assertions" % _assertions)
|
||||||
|
quit(0)
|
||||||
|
return
|
||||||
|
|
||||||
|
for failure: String in _failures:
|
||||||
|
printerr("FAIL: %s" % failure)
|
||||||
|
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
|
||||||
|
quit(1)
|
||||||
1
rinkplanner/tests/run_validation_tests.gd.uid
Normal file
1
rinkplanner/tests/run_validation_tests.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bdfvwb07656pb
|
||||||
|
|
@ -1103,6 +1103,43 @@ func _run() -> void:
|
||||||
)
|
)
|
||||||
DirAccess.remove_absolute(save_as_path)
|
DirAccess.remove_absolute(save_as_path)
|
||||||
|
|
||||||
|
# Validation dialog.
|
||||||
|
controller.new_routine()
|
||||||
|
controller.add_element_marker(
|
||||||
|
Vector2(0.0, 0.0),
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"3X",
|
||||||
|
0
|
||||||
|
)
|
||||||
|
var issues := controller.validate_routine()
|
||||||
|
_check(issues.size() == 1, "validation reports one finding")
|
||||||
|
_check(
|
||||||
|
issues.size() > 0
|
||||||
|
and issues[0].severity == ValidationIssue.Severity.ERROR,
|
||||||
|
"an unknown element code is reported as an error"
|
||||||
|
)
|
||||||
|
controller.message_dialog.hide()
|
||||||
|
controller.open_validation_dialog()
|
||||||
|
_check(controller.validation_dialog.visible, "validation button opens the dialog")
|
||||||
|
_check(
|
||||||
|
controller.validation_text.text.contains("nicht im Katalog"),
|
||||||
|
"validation dialog shows the catalog finding"
|
||||||
|
)
|
||||||
|
controller.validation_dialog.hide()
|
||||||
|
|
||||||
|
controller.new_routine()
|
||||||
|
controller.add_element_marker(
|
||||||
|
Vector2(0.0, 0.0),
|
||||||
|
PathSegment.ElementType.SPIN,
|
||||||
|
"CCoSp",
|
||||||
|
4
|
||||||
|
)
|
||||||
|
var clean_issues := controller.validate_routine()
|
||||||
|
_check(
|
||||||
|
clean_issues.is_empty(),
|
||||||
|
"a consistent routine has no validation findings"
|
||||||
|
)
|
||||||
|
|
||||||
scene.queue_free()
|
scene.queue_free()
|
||||||
await process_frame
|
await process_frame
|
||||||
_finish()
|
_finish()
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ fi
|
||||||
"$GODOT" --headless --path "$PROJECT_DIR" \
|
"$GODOT" --headless --path "$PROJECT_DIR" \
|
||||||
--script res://tests/run_level_tests.gd
|
--script res://tests/run_level_tests.gd
|
||||||
|
|
||||||
|
"$GODOT" --headless --path "$PROJECT_DIR" \
|
||||||
|
--script res://tests/run_validation_tests.gd
|
||||||
|
|
||||||
"$GODOT" --headless --path "$PROJECT_DIR" \
|
"$GODOT" --headless --path "$PROJECT_DIR" \
|
||||||
--script res://tests/run_canvas_tests.gd
|
--script res://tests/run_canvas_tests.gd
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue