feat: Pruefdialog zeigt konkrete Pruefliste

- ValidationReport/ValidationCheck mit geprueft/bestanden je Kategorie
- Dialog nennt Umfang und Pruefliste statt Quellenangabe
- Kategorien: Kuerzel, Typ, Level, ChSq-Level, Features, Pflichtfeatures,
  Level aus Features, Einmal pro Programm
- Tooltip am Pruefen-Button nennt den Pruefumfang
- 54 Validierungs-Assertions, Whiteboard 237 (896 gesamt)
- Doku aktualisiert
This commit is contained in:
torsten 2026-10-31 10:18:24 +01:00
parent b788c1be04
commit b7dd88c65b
11 changed files with 545 additions and 262 deletions

View file

@ -66,6 +66,8 @@ Implementiert in `rinkplanner/src/core/rules/`:
| `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 |
| `ValidationReport` | Befunde, Element-/Abschnittszahl und Prüfstatistik |
| `ValidationCheck` | eine Prüfkategorie mit geprüft/bestanden/Befunden |
### Entscheidungen
@ -133,9 +135,11 @@ 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
und Abschnitts-/Segmentbezug. `validate_report()` ergänzt eine Prüfstatistik:
Element- und Abschnittszahl sowie pro Kategorie, wie viele Fälle geprüft und
bestanden wurden. 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 Prüfliste und 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ß.
@ -192,9 +196,11 @@ Begrenzung auf zwei Features pro Fuß.
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 nennt Saison,
Quelle und Anzahl der geprüften Elemente und listet Fehler und Warnungen
mit Abschnitt und Element; ein leeres Ergebnis wird positiv bestätigt.
Speichern und Export bleiben möglich.
Element- und Abschnittszahl und zeigt eine Prüfliste (Kürzel, Elementtyp,
Level, ChSq-Level, Feature-Auswahl, Pflichtfeatures, Level aus Features,
Einmal pro Programm) mit „bestanden/geprüft“-Zählern. Darunter stehen die
Befunde 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
Abschnittsliste. Neue Sections werden angelegt, umbenannt, gelöscht und
hoch-/runtergeschoben; `sequence_order` wird nach jeder Änderung
@ -349,9 +355,10 @@ Aktueller Stand:
schwierige Variationen, Level-4-Voraussetzungen, Pflichtfeatures bei
Schrittsequenzen, feste Level (`ChSq`), Feature-Validierung und die
Speicherung am Segment.
- **Validierung:** 28 Assertions für unbekannte Kürzel, Typ-Mismatches,
- **Validierung:** 54 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.
Pflichtfeatures, Level-Abweichungen, programmweite Einmal-Features und die
Prüfstatistik je Kategorie.
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
Rink-Kontur und die reine Bogen-Geometrie.
- **Whiteboard:** 237 Assertions für Controller-Verdrahtung, Segmenterzeugung,

View file

@ -8,12 +8,13 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
| Ziel | Ergebnis |
| :--- | :--- |
| Prüfmodell | `RoutineValidator` + `ValidationIssue` in `src/core/rules/` |
| Prüfmodell | `RoutineValidator`, `ValidationReport`, `ValidationCheck`, `ValidationIssue` |
| 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 |
| Oberfläche | Button „Prüfen“ in der Statusleiste, Dialog mit Prüfliste und Befunden |
| Prüfstatistik | Je Kategorie geprüft/bestanden plus Element- und Abschnittszahl |
| Verhalten | Prüfung ist nicht blockierend; Speichern und Export bleiben möglich |
| Tests | 866 Assertions gesamt, `./tools/test.sh` grün (neu: 28 Validierung) |
| Tests | 896 Assertions gesamt, `./tools/test.sh` grün (neu: 54 Validierung) |
## Entscheidungen
@ -54,13 +55,18 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
- Der Button **Prüfen** sitzt links neben „Segment löschen“ in der
Statusleiste.
- Der Dialog `Kür prüfen` nennt zuerst Katalog und Level-Regeln mit Saison und
Quelle, damit klar ist, wogegen geprüft wurde.
- Danach folgt eine Zusammenfassung (`n Fehler, m Warnungen · x Elemente
geprüft`) 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.“
- Der Dialog `Kür prüfen` nennt im Kopf den Umfang: `Geprüft: 4 Elemente in
1 Abschnitt (Saison 2025/26)`.
- Darunter steht eine Prüfliste mit einer Zeile pro Kategorie:
Kürzel im Katalog, Elementtyp passt, Level gültig, ChSq-Level,
Feature-Auswahl gültig, Pflichtfeatures, Level aus Features und
Einmal pro Programm. Jede Zeile zeigt `bestanden/geprüft`, Befundzahlen
und ein ✓/✗/–.
- Nicht anwendbare Kategorien erscheinen als „nicht geprüft“, z. B. wenn
keine Features gesetzt sind oder kein `ChSq` vorkommt.
- Danach folgen die Befunde mit farbigem Punkt, Schweregrad, Abschnitt,
Element und Meldung.
- Ein leeres Ergebnis wird positiv bestätigt: „Keine Befunde.“
- Die Dialoggröße wird auf die Viewport-Größe begrenzt, damit sie auch in
kleinen Fenstern und im Headless-Test positionierbar bleibt.
@ -78,7 +84,7 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
## Tests
Neu: `tests/run_validation_tests.gd` (28 Assertions)
Neu: `tests/run_validation_tests.gd` (54 Assertions)
- saubere Kür ohne Befunde
- unbekanntes Kürzel, Typ-Mismatch, nicht verfügbares Level
@ -88,10 +94,11 @@ Neu: `tests/run_validation_tests.gd` (28 Assertions)
- Level-Abweichung
- programmweites Einmal-Feature mit Verweis auf das erste Segment
- fehlendes Regelwerk
- Prüfstatistik je Kategorie (geprüft/bestanden/Befunde, übersprungene Checks)
Erweitert: `tests/run_whiteboard_tests.gd` (228 → 237 Assertions) prüft
`validate_routine()`, den Prüfdialog mit Fehlertext, die genannten Quellen
und eine saubere Kür.
`validate_routine()`, den Prüfdialog mit Prüfliste, Umfang und Befunden
sowie eine saubere Kür.
Visuell geprüft über `tests/manual/capture_elements.gd ... validate` bei
1400 × 876.

View file

@ -170,9 +170,21 @@ Abschnitt und Segment. Geprüft werden:
- Features, die laut Daten nur einmal pro Programm zählen
Der Button **Prüfen** in der Statusleiste öffnet die Befunde in einem Dialog.
Der Dialog nennt zuerst Katalog und Level-Regeln mit Saison und Quelle sowie
die Anzahl der geprüften Elemente. Die Prüfung blockiert Speichern und Export
nicht. Noch nicht geprüft werden
Der Kopf nennt den Umfang (`Geprüft: 4 Elemente in 1 Abschnitt (Saison
2025/26)`), darunter listet die Prüfliste jede Kategorie mit
`bestanden/geprüft` und Befundzahl:
- Kürzel im Katalog
- Elementtyp passt
- Level gültig
- ChSq-Level
- Feature-Auswahl gültig
- Pflichtfeatures
- Level aus Features
- Einmal pro Programm
Nicht anwendbare Kategorien erscheinen als „nicht geprüft“. Erst danach folgen
die konkreten Befunde. 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ß.

View file

@ -15,71 +15,78 @@ func _init(catalog: ElementCatalog, rules: ElementLevelRules) -> void:
_rules = rules
## Returns all findings in section order. An empty array means the element
## data is consistent with the loaded rule set.
## Returns the findings only. Use [method validate_report] when the UI also
## needs the counts of what was checked.
func validate(routine: Routine) -> Array[ValidationIssue]:
var issues: Array[ValidationIssue] = []
return validate_report(routine).issues
## Returns findings plus the element/section counts and per-check statistics.
func validate_report(routine: Routine) -> ValidationReport:
var report := ValidationReport.new()
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."
)
_append(
report,
ValidationIssue.Severity.ERROR,
"Keine Kür geladen."
)
return issues
return report
if _catalog == null or _rules == null:
_append(
report,
ValidationIssue.Severity.ERROR,
"Regelwerk ist nicht geladen; Prüfung nicht möglich."
)
return report
var seen_once: Dictionary[String, String] = {}
for section: RoutineSection in routine.sections:
if section == null:
continue
report.section_count += 1
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
)
report.element_count += 1
_validate_segment(segment, section.section_id, report)
_collect_program_features(segment, section.section_id, seen_once, report)
return issues
return report
func _validate_segment(
segment: PathSegment,
section_id: String,
issues: Array[ValidationIssue]
report: ValidationReport
) -> 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
)
_add(
report,
"code",
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
)
_add(
report,
"code",
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(
else:
_pass(report, "code")
if definition.element_type != segment.element_type:
_add(
report,
"type",
ValidationIssue.Severity.ERROR,
"Kürzel „%s“ gehört zu %s, nicht zu %s."
% [
@ -90,23 +97,26 @@ func _validate_segment(
section_id,
segment.segment_id
)
)
else:
_pass(report, "type")
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
)
if segment.element_level == fixed_level:
_pass(report, "fixed_level")
else:
_add(
report,
"fixed_level",
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
@ -114,111 +124,134 @@ func _validate_segment(
):
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],
_add(
report,
"level",
ValidationIssue.Severity.ERROR,
"%s ist für „%s“ nicht verfügbar."
% [
ElementDefinition.level_label(segment.element_level),
code,
],
section_id,
segment.segment_id
)
else:
_pass(report, "level")
elif segment.element_level != 0:
_add(
report,
"level",
ValidationIssue.Severity.WARNING,
"„%s“ hat Level %d; Sprünge sind nicht levelbar."
% [code, segment.element_level],
section_id,
segment.segment_id
)
else:
_pass(report, "level")
_validate_features(segment, code, section_id, issues)
_validate_features(segment, code, section_id, report)
func _validate_features(
segment: PathSegment,
code: String,
section_id: String,
issues: Array[ValidationIssue]
report: ValidationReport
) -> 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
)
_add(
report,
"features",
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],
var counts: Dictionary[String, int] = {}
var feature_failed := false
for raw: String in segment.element_features:
var feature_code := raw.strip_edges()
if feature_code.is_empty():
_append(
report,
ValidationIssue.Severity.ERROR,
"Leerer Feature-Code bei „%s“." % code,
section_id,
segment.segment_id
)
)
feature_failed = true
continue
var feature := _rules.get_feature(segment.element_type, feature_code)
if feature == null:
_append(
report,
ValidationIssue.Severity.ERROR,
"Unbekanntes Feature „%s“ für „%s“." % [raw, code],
section_id,
segment.segment_id
)
feature_failed = true
continue
var used: int = counts.get(feature_code, 0)
if used >= feature.max_per_element:
_append(
report,
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
)
feature_failed = true
continue
counts[feature_code] = used + 1
if feature_failed:
_fail(report, "features", true)
else:
_pass(report, "features")
var required: PackedStringArray = _rules.get_required_features(
segment.element_type
)
if not required.is_empty():
var missing := PackedStringArray()
for required_code: String in required:
if counts.has(required_code):
continue
var required_feature := _rules.get_feature(
segment.element_type,
required_code
)
missing.append(
required_feature.display_name
if required_feature != null
else required_code
)
if missing.is_empty():
_pass(report, "required")
else:
for name: String in missing:
_append(
report,
ValidationIssue.Severity.WARNING,
"Pflichtfeature fehlt bei „%s“: %s." % [code, name],
section_id,
segment.segment_id
)
_fail(report, "required", false)
if feature_failed:
return
var result := _rules.calculate_level(
segment.element_type,
@ -229,20 +262,22 @@ func _validate_features(
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
)
)
if result.level == segment.element_level:
_pass(report, "level_features")
return
_append(
report,
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
)
_fail(report, "level_features", false)
## Features marked as once-per-program may only count in the first element
@ -252,7 +287,7 @@ func _collect_program_features(
segment: PathSegment,
section_id: String,
seen_once: Dictionary[String, String],
issues: Array[ValidationIssue]
report: ValidationReport
) -> void:
for raw: String in segment.element_features:
var feature := _rules.get_feature(
@ -262,18 +297,19 @@ func _collect_program_features(
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
)
)
if not seen_once.has(key):
seen_once[key] = segment.segment_id
_pass(report, "once")
continue
seen_once[key] = segment.segment_id
_append(
report,
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
)
_fail(report, "once", false)
static func count_severity(
@ -287,10 +323,41 @@ static func count_severity(
return count
func _issue(
func _add(
report: ValidationReport,
check_code: String,
severity: ValidationIssue.Severity,
message: String,
section_id: String = "",
segment_id: String = ""
) -> ValidationIssue:
return ValidationIssue.new(severity, message, section_id, segment_id)
) -> void:
_append(report, severity, message, section_id, segment_id)
_fail(report, check_code, severity == ValidationIssue.Severity.ERROR)
func _append(
report: ValidationReport,
severity: ValidationIssue.Severity,
message: String,
section_id: String = "",
segment_id: String = ""
) -> void:
report.issues.append(
ValidationIssue.new(severity, message, section_id, segment_id)
)
func _pass(report: ValidationReport, check_code: String) -> void:
var check := report.get_check(check_code)
if check != null:
check.pass_check()
func _fail(
report: ValidationReport,
check_code: String,
is_error: bool
) -> void:
var check := report.get_check(check_code)
if check != null:
check.fail_check(is_error)

View file

@ -0,0 +1,42 @@
class_name ValidationCheck
extends RefCounted
## One category of checks performed by [RoutineValidator]. Counts let the
## validation dialog show what was actually checked, not just the findings.
var code: String = ""
var label: String = ""
var checked: int = 0
var passed: int = 0
var findings: int = 0
var errors: int = 0
var warnings: int = 0
func _init(p_code: String = "", p_label: String = "") -> void:
code = p_code
label = p_label
func pass_check() -> void:
checked += 1
passed += 1
func fail_check(is_error: bool) -> void:
checked += 1
findings += 1
if is_error:
errors += 1
else:
warnings += 1
func is_skipped() -> bool:
return checked == 0
func summary() -> String:
if checked == 0:
return "nicht geprüft"
return "%d/%d" % [passed, checked]

View file

@ -0,0 +1 @@
uid://dy7kgyonxt8gq

View file

@ -0,0 +1,44 @@
class_name ValidationReport
extends RefCounted
## Result of [RoutineValidator.validate_report]. Contains the findings, the
## element/section counts and one [ValidationCheck] per check category.
const CHECK_ORDER := [
"code",
"type",
"level",
"fixed_level",
"features",
"required",
"level_features",
"once",
]
const CHECK_LABELS := {
"code": "Kürzel im Katalog",
"type": "Elementtyp passt",
"level": "Level gültig",
"fixed_level": "ChSq-Level",
"features": "Feature-Auswahl gültig",
"required": "Pflichtfeatures",
"level_features": "Level aus Features",
"once": "Einmal pro Programm",
}
var issues: Array[ValidationIssue] = []
var element_count: int = 0
var section_count: int = 0
var checks: Array[ValidationCheck] = []
func _init() -> void:
for code: String in CHECK_ORDER:
checks.append(ValidationCheck.new(code, CHECK_LABELS[code]))
func get_check(code: String) -> ValidationCheck:
for check: ValidationCheck in checks:
if check.code == code:
return check
return null

View file

@ -0,0 +1 @@
uid://be37vd2vbcluq

View file

@ -198,8 +198,8 @@ func _ready() -> void:
"Level rules: %s" % ", ".join(_level_rules.get_errors())
)
validation_button.tooltip_text = (
"Prüft gegen Katalog %s und Level-Regeln %s"
% [_element_catalog.season, _level_rules.season]
"Prüft Kürzel, Elementtyp, Level, Features und Einmal-Regeln (Saison %s)"
% _element_catalog.season
)
_setup_tool_options()
_setup_file_menu()
@ -442,59 +442,52 @@ func validate_routine() -> Array[ValidationIssue]:
return validator.validate(_routine)
## Opens the validation dialog with the current findings.
## Opens the validation dialog with the current findings and the checks that
## were performed.
func open_validation_dialog() -> void:
var issues := validate_routine()
var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new(
_element_catalog,
_level_rules
)
var report := validator.validate_report(_routine)
var errors := RoutineValidator.count_severity(
issues,
report.issues,
ValidationIssue.Severity.ERROR
)
var warnings := RoutineValidator.count_severity(
issues,
report.issues,
ValidationIssue.Severity.WARNING
)
var season := (
_element_catalog.season if _element_catalog != null else "unbekannt"
)
var lines := PackedStringArray()
var element_count := _count_elements()
if _element_catalog != null:
lines.append(
"[b]Katalog %s:[/b] %s"
% [
_element_catalog.season,
_escape_bbcode(_element_catalog.source),
]
)
if _level_rules != null:
lines.append(
"[b]Level-Regeln %s:[/b] %s"
% [
_level_rules.season,
_escape_bbcode(_level_rules.source),
]
)
lines.append(
"[b]Geprüft: %s in %s (Saison %s)[/b]"
% [
_element_count_label(report.element_count),
_section_count_label(report.section_count),
season,
]
)
lines.append("")
lines.append("[b]Prüfungen[/b]")
for check: ValidationCheck in report.checks:
lines.append(_validation_check_line(check))
lines.append("")
lines.append("[b]Befunde[/b]")
if issues.is_empty():
if element_count == 0:
lines.append(
"[b]Keine Befunde.[/b] Es sind keine Elemente vorhanden."
)
elif element_count == 1:
lines.append(
"[b]Keine Befunde.[/b] Das Element passt zu Katalog und Level-Regeln."
)
if report.issues.is_empty():
if report.element_count == 0:
lines.append("Keine Elemente vorhanden.")
else:
lines.append(
"[b]Keine Befunde.[/b] Alle %d Elemente passen zu Katalog und Level-Regeln."
% element_count
)
lines.append("Keine Befunde.")
else:
lines.append(
"[b]%d Fehler, %d Warnungen[/b] · %s geprüft"
% [errors, warnings, _element_count_label(element_count)]
"[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings]
)
lines.append("")
for issue: ValidationIssue in issues:
for issue: ValidationIssue in report.issues:
var color := (
"#ef4444"
if issue.severity == ValidationIssue.Severity.ERROR
@ -520,23 +513,44 @@ func open_validation_dialog() -> void:
validation_dialog.popup_centered(target)
func _count_elements() -> int:
if _routine == null:
return 0
var count := 0
for section: RoutineSection in _routine.sections:
if section == null:
continue
for segment: PathSegment in section.segments:
if segment != null and segment.is_element():
count += 1
return count
func _validation_check_line(check: ValidationCheck) -> String:
var color := "#22c55e"
var icon := "✓"
if check.is_skipped():
color = "#64748b"
icon = "–"
elif check.findings > 0:
color = "#ef4444" if check.errors > 0 else "#f59e0b"
icon = "✗"
var detail := check.summary()
var findings := PackedStringArray()
if check.errors > 0:
findings.append("%d Fehler" % check.errors)
if check.warnings > 0:
findings.append(
"%d Warnung%s"
% [check.warnings, "" if check.warnings == 1 else "en"]
)
if not findings.is_empty():
detail += " · " + " · ".join(findings)
return "[color=%s]%s[/color] %s — %s" % [
color,
icon,
_escape_bbcode(check.label),
detail,
]
func _element_count_label(count: int) -> String:
return "1 Element" if count == 1 else "%d Elemente" % count
func _section_count_label(count: int) -> String:
return "1 Abschnitt" if count == 1 else "%d Abschnitten" % count
func _validation_location(issue: ValidationIssue) -> String:
var parts := PackedStringArray()
if not issue.section_id.is_empty():

View file

@ -76,27 +76,58 @@ func _test_clean_routine() -> void:
var issues := _validator.validate(routine)
_check(issues.is_empty(), "a consistent routine has no findings (%s)" % _messages(issues))
var report := _validator.validate_report(routine)
_check(report.element_count == 2, "the report counts the elements")
_check(report.section_count == 1, "the report counts the sections")
_check(report.get_check("code").passed == 2, "both codes were checked")
_check(report.get_check("type").passed == 2, "both types were checked")
_check(report.get_check("level").passed == 2, "both levels were checked")
_check(
report.get_check("fixed_level").is_skipped(),
"fixed-level check is skipped without ChSq"
)
_check(report.get_check("features").passed == 2, "both feature sets were checked")
_check(
report.get_check("required").passed == 1,
"the compulsory sequence feature was checked"
)
_check(report.get_check("level_features").passed == 2, "both derived levels match")
_check(report.get_check("once").passed == 6, "once-per-program features were checked")
func _test_unknown_code() -> void:
var issues := _validate_one(
var report := _report_one(
PathSegment.ElementType.SPIN,
"3X",
0,
PackedStringArray()
)
var issues := report.issues
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "unknown code is an error")
_check(_has_message(issues, "nicht im Katalog"), "unknown code message")
_check(report.get_check("code").errors == 1, "the code check records the error")
_check(
report.get_check("type").is_skipped(),
"the type check is skipped without a definition"
)
func _test_type_mismatch() -> void:
var issues := _validate_one(
var report := _report_one(
PathSegment.ElementType.SPIN,
"3Lz",
0,
PackedStringArray()
)
var issues := report.issues
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "type mismatch is an error")
_check(_has_message(issues, "gehört zu Sprung"), "type mismatch message")
_check(report.get_check("code").passed == 1, "the code itself exists")
_check(report.get_check("type").errors == 1, "the type check records the mismatch")
_check(
report.get_check("level").is_skipped(),
"the level check is skipped after a type mismatch"
)
func _test_unavailable_level() -> void:
@ -128,7 +159,8 @@ func _test_jump_level_and_features() -> void:
2,
PackedStringArray(["difficult_exit"])
)
var issues := _validator.validate(routine)
var report := _validator.validate_report(routine)
var issues := report.issues
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 2,
"jump level and features are two warnings"
@ -136,58 +168,83 @@ func _test_jump_level_and_features() -> void:
_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")
_check(
report.get_check("level").warnings == 1,
"the level check records the jump warning"
)
_check(
report.get_check("features").warnings == 1,
"the feature check records the jump warning"
)
func _test_fixed_level() -> void:
var issues := _validate_one(
var report := _report_one(
PathSegment.ElementType.SEQUENCE,
"ChSq",
2,
PackedStringArray()
)
var issues := report.issues
_check(
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
"a wrong fixed level is an error"
)
_check(_has_message(issues, "fest"), "fixed level message")
_check(report.get_check("fixed_level").errors == 1, "the fixed-level check fails")
_check(
report.get_check("level").is_skipped(),
"the generic level check is skipped for fixed levels"
)
var valid := _validate_one(
var valid := _report_one(
PathSegment.ElementType.SEQUENCE,
"ChSq",
1,
PackedStringArray()
)
_check(valid.is_empty(), "ChSq at Level 1 is valid")
_check(valid.issues.is_empty(), "ChSq at Level 1 is valid")
_check(valid.get_check("fixed_level").passed == 1, "the fixed-level check passes")
func _test_missing_code() -> void:
var issues := _validate_one(
var report := _report_one(
PathSegment.ElementType.SPIN,
"",
0,
PackedStringArray()
)
var issues := report.issues
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"a missing code is a warning"
)
_check(_has_message(issues, "ohne Kürzel"), "missing code message")
_check(
report.get_check("code").warnings == 1,
"the code check records the missing code"
)
func _test_feature_selection() -> void:
var unknown := _validate_one(
var unknown_report := _report_one(
PathSegment.ElementType.SPIN,
"CCoSp",
0,
PackedStringArray(["nope"])
)
var unknown := unknown_report.issues
_check(
_count(unknown, ValidationIssueScript.Severity.ERROR) == 1,
"an unknown feature is an error"
)
_check(_has_message(unknown, "Unbekanntes Feature"), "unknown feature message")
_check(
unknown_report.get_check("features").errors == 1,
"the feature check records the unknown code"
)
var too_many := _validate_one(
var too_many_report := _report_one(
PathSegment.ElementType.SPIN,
"CCoSp",
0,
@ -195,37 +252,52 @@ func _test_feature_selection() -> void:
["difficult_variation", "difficult_variation", "difficult_variation"]
)
)
var too_many := too_many_report.issues
_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(
var missing_report := _report_one(
PathSegment.ElementType.SEQUENCE,
"StSq",
1,
PackedStringArray(["body_movements"])
)
var missing := missing_report.issues
_check(
_count(missing, ValidationIssueScript.Severity.WARNING) == 1,
"a missing compulsory sequence feature is a warning"
)
_check(_has_message(missing, "Pflichtfeature fehlt"), "compulsory feature message")
_check(
missing_report.get_check("required").warnings == 1,
"the required-feature check records the warning"
)
_check(
missing_report.get_check("level_features").is_skipped(),
"the level check is skipped when a required feature is missing"
)
func _test_level_mismatch() -> void:
var issues := _validate_one(
var report := _report_one(
PathSegment.ElementType.SPIN,
"CCoSp",
4,
PackedStringArray(["difficult_variation", "difficult_exit"])
)
var issues := report.issues
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"a feature/level mismatch is a warning"
)
_check(_has_message(issues, "Features ergeben"), "level mismatch message")
_check(
report.get_check("level_features").warnings == 1,
"the derived-level check records the mismatch"
)
func _test_program_once_features() -> void:
@ -247,7 +319,8 @@ func _test_program_once_features() -> void:
1,
PackedStringArray(["difficult_exit"])
)
var issues := _validator.validate(routine)
var report := _validator.validate_report(routine)
var issues := report.issues
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"repeated once-per-program features warn once per repeated occurrence"
@ -257,6 +330,11 @@ func _test_program_once_features() -> void:
_has_message(issues, "zuerst in Segment „spin-a“"),
"once-per-program message names the first segment"
)
_check(
report.get_check("once").passed == 1
and report.get_check("once").warnings == 1,
"the once-per-program check counts both occurrences"
)
func _test_missing_rules() -> void:
@ -283,9 +361,18 @@ func _validate_one(
level: int,
features: PackedStringArray
) -> Array[ValidationIssue]:
return _report_one(type, code, level, features).issues
func _report_one(
type: PathSegment.ElementType,
code: String,
level: int,
features: PackedStringArray
) -> ValidationReport:
var routine := _make_routine()
_add_marker(routine.sections[0], "segment", type, code, level, features)
return _validator.validate(routine)
return _validator.validate_report(routine)
func _make_routine() -> Routine:

View file

@ -1126,18 +1126,18 @@ func _run() -> void:
"validation dialog shows the catalog finding"
)
_check(
controller.validation_text.text.contains("Katalog 2025/26")
and controller.validation_text.text.contains("2707"),
"validation dialog names the catalog and its source"
controller.validation_text.text.contains("Geprüft: 1 Element in 1 Abschnitt")
and controller.validation_text.text.contains("Saison 2025/26"),
"validation dialog states the scope of the check"
)
_check(
controller.validation_text.text.contains("Level-Regeln 2025/26")
and controller.validation_text.text.contains("2701"),
"validation dialog names the level rules and their source"
controller.validation_text.text.contains("Kürzel im Katalog")
and controller.validation_text.text.contains("0/1"),
"validation dialog lists the failed check with its count"
)
_check(
controller.validation_text.text.contains("1 Element geprüft"),
"validation dialog reports how many elements were checked"
controller.validation_text.text.contains("Befunde"),
"validation dialog separates checks from findings"
)
controller.validation_dialog.hide()
@ -1156,8 +1156,9 @@ func _run() -> void:
controller.open_validation_dialog()
_check(
controller.validation_text.text.contains("Keine Befunde")
and controller.validation_text.text.contains("Das Element passt"),
"clean validation names the rule set and the checked element count"
and controller.validation_text.text.contains("Kürzel im Katalog")
and controller.validation_text.text.contains("1/1"),
"clean validation lists the passed checks"
)
controller.validation_dialog.hide()