feat: Legacy-Migration, Axel-Pflicht und Kombinations-Export

- Alte Freitext-Kombinationen werden beim Laden und Uebernehmen in die
  strukturierte Form migriert
- Sprungfolgen verlangen einen Axel als 2. oder 3. Sprung
- Dialoghinweis fuer Folgen (Axel vorhanden/fehlt)
- Export zeigt eine Kombination als einen Marker mit voller Caption
- 100 Model-, 169 Rules-, 66 Validation-, 70 Adult-, 297 Whiteboard-
  und 31 Export-Assertions (1075 gesamt)
- Doku und Findings aktualisiert
This commit is contained in:
torsten 2026-10-31 11:59:13 +01:00
parent 8f1cf1bf44
commit 05dee8da2b
16 changed files with 422 additions and 32 deletions

View file

@ -684,6 +684,15 @@ custom_minimum_size = Vector2(0, 48)
layout_mode = 2
theme_override_font_sizes/font_size = 16
[node name="JumpSequenceHint" type="Label" parent="ElementDialog/ElementBox/JumpCombinationBox"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(480, 0)
layout_mode = 2
theme_override_colors/font_color = Color(0.74902, 0.803922, 0.878431, 1)
theme_override_font_sizes/font_size = 13
autowrap_mode = 3
[node name="ElementFeaturesButton" type="Button" parent="ElementDialog/ElementBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 56)

View file

@ -231,6 +231,77 @@ func get_jump_parts() -> PackedStringArray:
return parts
## Parses a legacy free-text jump combination like "3Lz+2T+SEQ" without
## mutating the segment. Returns valid=false when the code is not a clean
## combination of listed jumps.
static func parse_legacy_combination(code: String) -> Dictionary:
var result := {
"valid": false,
"first": "",
"extras": PackedStringArray(),
"kind": JumpKind.SOLO,
}
var cleaned := code.strip_edges()
if not cleaned.contains("+"):
return result
var listed := PackedStringArray()
var has_sequence := false
for raw: String in cleaned.split("+"):
var token := raw.strip_edges()
var upper := token.to_upper()
if token.is_empty():
continue
if upper == "SEQ" or upper == "S":
has_sequence = true
continue
if token.length() < 2 or not token.substr(0, 1).is_valid_int():
continue
if token.substr(1).to_lower() == "eu":
continue
listed.append(token)
if listed.size() < 2 or listed.size() > JUMP_MAX_PARTS:
return result
var extras := PackedStringArray()
for index: int in range(1, listed.size()):
extras.append(listed[index])
result["valid"] = true
result["first"] = listed[0]
result["extras"] = extras
result["kind"] = (
JumpKind.SEQUENCE if has_sequence else JumpKind.COMBINATION
)
return result
## Converts a stored legacy free-text combination into the structured fields.
## Returns true when the segment changed.
func normalize_jump_combination() -> bool:
if (
element_type != ElementType.JUMP
or not combination_jumps.is_empty()
or not element_code.contains("+")
):
return false
var parsed := parse_legacy_combination(element_code)
if not bool(parsed.get("valid", false)):
return false
element_code = str(parsed.get("first", ""))
jump_kind = parsed.get("kind", JumpKind.SOLO)
combination_jumps = parsed.get("extras", PackedStringArray())
return true
static func is_axel(code: String) -> bool:
var cleaned := code.strip_edges()
return (
cleaned.length() >= 2
and cleaned.substr(1).to_lower() == "a"
)
## Short caption for the canvas and exports, e.g. "3Lz" or "CCoSp4 L3".
func get_element_caption() -> String:
var code := element_code.strip_edges()
@ -327,6 +398,16 @@ func validate() -> PackedStringArray:
errors.append(
"a jump combination must not exceed %d jumps" % JUMP_MAX_PARTS
)
if jump_kind == JumpKind.SEQUENCE:
var has_axel := false
for extra: String in combination_jumps:
if is_axel(extra):
has_axel = true
break
if not has_axel:
errors.append(
"a jump sequence needs an Axel-type second or third jump"
)
if (
element_duration_seconds < 0.0
or element_duration_seconds > ELEMENT_MAX_DURATION_SECONDS

View file

@ -526,6 +526,7 @@ func _validate_segment(
_pass(report, "level")
_validate_features(segment, code, section_id, report)
_validate_jump_sequence(segment, section_id, report)
func _validate_features(
@ -654,6 +655,40 @@ func _validate_features(
_fail(report, "level_features", false)
func _validate_jump_sequence(
segment: PathSegment,
section_id: String,
report: ValidationReport
) -> void:
if (
segment.element_type != PathSegment.ElementType.JUMP
or segment.jump_kind != PathSegment.JumpKind.SEQUENCE
):
return
var parts := _segment_jump_parts(segment)
if parts.size() < 2:
return
var has_axel := false
for index: int in range(1, parts.size()):
if AdultCategoryRules.Category.jump_type(
parts[index]
).to_lower() == "a":
has_axel = true
break
if has_axel:
_pass(report, "jump_sequence")
return
_append(
report,
ValidationIssue.Severity.WARNING,
"Folge „%s“ braucht einen Axel als 2. oder 3. Sprung."
% segment.get_element_caption(),
section_id,
segment.segment_id
)
_fail(report, "jump_sequence", false)
## 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.

View file

@ -13,6 +13,7 @@ const CHECK_ORDER := [
"required",
"level_features",
"once",
"jump_sequence",
"category",
"category_jumps",
"category_jump_types",
@ -34,6 +35,7 @@ const CHECK_LABELS := {
"required": "Pflichtfeatures",
"level_features": "Level aus Features",
"once": "Einmal pro Programm",
"jump_sequence": "Sprungfolge",
"category": "Kategorie",
"category_jumps": "Kategorie: Sprunganzahl",
"category_jump_types": "Kategorie: erlaubte Sprünge",

View file

@ -123,6 +123,7 @@ const COMPACT_LAYOUT_WIDTH := 1280.0
@onready var jump_kind_option: OptionButton = %JumpKindOption
@onready var jump_second_option: OptionButton = %JumpSecondOption
@onready var jump_third_option: OptionButton = %JumpThirdOption
@onready var jump_sequence_hint: Label = %JumpSequenceHint
@onready var element_features_button: Button = %ElementFeaturesButton
@onready var element_feature_hint: Label = %ElementFeatureHint
@onready var element_feature_menu: PopupMenu = %ElementFeatureMenu
@ -721,6 +722,8 @@ func _validation_skip_reason(check_code: String) -> String:
return "keine Features gesetzt"
"once":
return "keine Einmal-Features gesetzt"
"jump_sequence":
return "keine Sprungfolge"
return "keine passenden Daten"
@ -819,7 +822,11 @@ func _help_content() -> String:
+ "werden summiert."
)
lines.append(
"- Alte Freitext-Kombinationen wie 3Lz+2T bleiben als Fallback lesbar."
"- 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 "
@ -1472,6 +1479,7 @@ func _on_jump_extra_selected(_index: int) -> void:
if not code.is_empty():
extras.append(code)
_dialog_combination_jumps = extras
_update_jump_controls()
update_element_value_hint()
@ -1489,6 +1497,25 @@ func _update_jump_controls() -> void:
)
jump_second_option.visible = show_extras
jump_third_option.visible = show_extras
var is_sequence := (
is_jump and _dialog_jump_kind == PathSegment.JumpKind.SEQUENCE
)
jump_sequence_hint.visible = is_sequence
if is_sequence:
var has_axel := false
for extra: String in _dialog_combination_jumps:
if PathSegment.is_axel(extra):
has_axel = true
break
jump_sequence_hint.text = (
"Folge: Axel vorhanden."
if has_axel
else "Folge: mindestens ein Axel (1A/2A/3A) als 2. oder 3. Sprung."
)
jump_sequence_hint.add_theme_color_override(
"font_color",
Color("#22c55e") if has_axel else Color("#f59e0b")
)
func _select_jump_extra(option: OptionButton, code: String) -> void:
@ -1627,6 +1654,22 @@ func set_selected_element_with_features(
clamped = int(normalized["level"])
if _is_derived_level(type, cleaned):
clamped = _derived_level(type, cleaned, cleaned_features)
if (
type == PathSegment.ElementType.JUMP
and cleaned_combination.is_empty()
and cleaned.contains("+")
):
var parsed := PathSegment.parse_legacy_combination(cleaned)
if bool(parsed.get("valid", false)):
cleaned = str(parsed.get("first", cleaned))
cleaned_kind = parsed.get(
"kind",
PathSegment.JumpKind.SOLO
)
cleaned_combination = parsed.get(
"extras",
PackedStringArray()
)
var clamped_duration := -1.0
if type == PathSegment.ElementType.NONE:
cleaned = ""
@ -1706,6 +1749,7 @@ func add_element_marker(
str(normalized["code"]),
int(normalized["level"])
)
segment.normalize_jump_combination()
if _is_derived_level(type, segment.element_code):
segment.element_level = _derived_level(
type,
@ -3210,6 +3254,12 @@ func _install_routine(
_routine = routine
if _routine.rink == null or not _routine.rink.is_valid():
_routine.rink = RinkDimensions.new()
for section: RoutineSection in _routine.sections:
if section == null:
continue
for segment: PathSegment in section.segments:
if segment != null:
segment.normalize_jump_combination()
_sync_adult_category_option()
var valid_sections: Array[RoutineSection] = []

View file

@ -109,6 +109,22 @@ func _capture() -> void:
controller.jump_second_option.select(index)
controller.jump_second_option.item_selected.emit(index)
break
elif args.size() > 3 and args[3] == "seqwarn":
controller.select_segment(jump.segment_id)
controller.element_button.pressed.emit()
var sequence_kind := controller.jump_kind_option.get_item_index(
PathSegment.JumpKind.SEQUENCE
)
controller.jump_kind_option.select(sequence_kind)
controller.jump_kind_option.item_selected.emit(sequence_kind)
for index: int in range(controller.jump_second_option.item_count):
var metadata: Variant = controller.jump_second_option.get_item_metadata(
index
)
if metadata != null and str(metadata) == "2T":
controller.jump_second_option.select(index)
controller.jump_second_option.item_selected.emit(index)
break
elif args.size() > 3 and args[3] == "adultgold":
controller.set_adult_category("gold")
controller.open_validation_dialog()

View file

@ -38,13 +38,21 @@ func _run() -> void:
"SVG labels get a white outline"
)
_check(
_count(svg, 'class="element-marker"') == 2,
"SVG contains both element markers"
_count(svg, 'class="element-marker"') == 3,
"SVG contains all element markers"
)
_check(
svg.contains('data-element="3Lz"'),
"SVG names the jump marker"
)
_check(
svg.contains('data-element="2T+2S"'),
"SVG treats a combination as one marker"
)
_check(
svg.contains(">2T+2S</text>"),
"SVG draws the combination caption"
)
_check(
svg.contains('data-element="CCoSp4 L3"'),
"SVG names the spin marker with its level"
@ -80,6 +88,20 @@ func _run() -> void:
"section export excludes markers of other sections"
)
var section_two_svg := RoutineSvgExporter.build(routine, "section-2")
_check(
_count(section_two_svg, 'class="element-marker"') == 2,
"the second section exports jump and combination"
)
_check(
section_two_svg.contains('data-element="2T+2S"'),
"the second section exports the combination as one marker"
)
_check(
not section_two_svg.contains('data-element="CCoSp4 L3"'),
"the second section excludes the spin of section one"
)
var scene := WhiteboardScene.instantiate()
var controller := scene as WhiteboardController
if controller != null:
@ -176,7 +198,18 @@ func _make_routine() -> Routine:
"3Lz",
0
)
section_two.segments = [arc, jump_marker]
var combo_marker := _make_marker(
"seg-marker-combo",
Vector2(18.0, 5.0),
PathSegment.ElementType.JUMP,
"2T",
0
)
combo_marker.set_jump_combination(
PathSegment.JumpKind.COMBINATION,
PackedStringArray(["2S"])
)
section_two.segments = [arc, jump_marker, combo_marker]
routine.sections = [section_one, section_two]
return routine

View file

@ -361,6 +361,69 @@ func _test_jump_combinations() -> void:
"an empty combination is rejected"
)
var legacy_combo: PathSegment = PathSegmentModel.new()
legacy_combo.segment_id = "legacy-combo"
legacy_combo.curve = curve
legacy_combo.set_element(
PathSegmentModel.ElementType.JUMP,
"3Lz+2T",
0
)
_check(
legacy_combo.normalize_jump_combination(),
"legacy combination is migrated"
)
_check(
legacy_combo.element_code == "3Lz"
and legacy_combo.jump_kind == PathSegmentModel.JumpKind.COMBINATION
and legacy_combo.combination_jumps == PackedStringArray(["2T"]),
"legacy combination parts are structured"
)
_check(
legacy_combo.get_element_caption() == "3Lz+2T",
"legacy combination keeps its caption"
)
var legacy_sequence: PathSegment = PathSegmentModel.new()
legacy_sequence.segment_id = "legacy-sequence"
legacy_sequence.curve = curve
legacy_sequence.set_element(
PathSegmentModel.ElementType.JUMP,
"3S+2A+SEQ",
0
)
_check(
legacy_sequence.normalize_jump_combination(),
"legacy sequence is migrated"
)
_check(
legacy_sequence.jump_kind == PathSegmentModel.JumpKind.SEQUENCE
and legacy_sequence.combination_jumps == PackedStringArray(["2A"]),
"legacy sequence parts are structured"
)
_check(legacy_sequence.is_valid(), "legacy sequence with Axel is valid")
var sequence_without_axel: PathSegment = PathSegmentModel.new()
sequence_without_axel.segment_id = "sequence-no-axel"
sequence_without_axel.curve = curve
sequence_without_axel.set_element(
PathSegmentModel.ElementType.JUMP,
"3S",
0
)
sequence_without_axel.set_jump_combination(
PathSegmentModel.JumpKind.SEQUENCE,
PackedStringArray(["2T"])
)
_check(
not sequence_without_axel.is_valid()
and _contains_error(
sequence_without_axel.validate(),
"Axel-type second or third jump"
),
"a sequence without an Axel is rejected"
)
func _test_section_aggregation() -> void:
var section: RoutineSection = RoutineSectionModel.new()

View file

@ -34,6 +34,7 @@ func _init() -> void:
_test_missing_code()
_test_feature_selection()
_test_level_mismatch()
_test_jump_sequence()
_test_program_once_features()
_test_missing_rules()
_finish()
@ -324,6 +325,38 @@ func _test_level_mismatch() -> void:
)
func _test_jump_sequence() -> void:
var routine := _make_routine()
var segment := _add_marker(
routine.sections[0],
"sequence",
PathSegment.ElementType.JUMP,
"3S",
0,
PackedStringArray()
)
segment.set_jump_combination(
PathSegment.JumpKind.SEQUENCE,
PackedStringArray(["2T"])
)
var report := _validator.validate_report(routine)
_check(
report.get_check("jump_sequence").warnings == 1,
"a sequence without an Axel is reported"
)
_check(_has_message(report.issues, "Axel als 2. oder 3. Sprung"), "Axel message")
segment.set_jump_combination(
PathSegment.JumpKind.SEQUENCE,
PackedStringArray(["2A"])
)
report = _validator.validate_report(routine)
_check(
report.get_check("jump_sequence").passed == 1,
"a sequence with an Axel passes"
)
func _test_program_once_features() -> void:
var routine := _make_routine()
var section := routine.sections[0]

View file

@ -1447,6 +1447,62 @@ func _run() -> void:
"undo restores the solo jump"
)
var legacy_marker := controller.add_element_marker(
Vector2(0.0, 0.0),
PathSegment.ElementType.JUMP,
"3Lz+2T",
0
)
_check(
legacy_marker.element_code == "3Lz"
and legacy_marker.jump_kind == PathSegment.JumpKind.COMBINATION
and legacy_marker.combination_jumps == PackedStringArray(["2T"]),
"legacy free-text combinations are migrated on insert"
)
_check(
legacy_marker.get_element_caption() == "3Lz+2T",
"the migrated legacy marker keeps its caption"
)
controller.select_segment(combo_marker.segment_id)
controller.element_button.pressed.emit()
var sequence_kind_index := controller.jump_kind_option.get_item_index(
PathSegment.JumpKind.SEQUENCE
)
controller.jump_kind_option.select(sequence_kind_index)
controller.jump_kind_option.item_selected.emit(sequence_kind_index)
_check(
controller.jump_sequence_hint.visible
and controller.jump_sequence_hint.text.contains("mindestens ein Axel"),
"the sequence hint asks for an Axel"
)
_select_option_by_metadata(controller.jump_second_option, "2T")
_check(
controller.jump_sequence_hint.text.contains("mindestens ein Axel"),
"a sequence without an Axel keeps the warning"
)
_select_option_by_metadata(controller.jump_second_option, "2A")
_check(
controller.jump_sequence_hint.text.contains("Axel vorhanden"),
"selecting an Axel satisfies the sequence hint"
)
_check(
controller.element_value_label.text.contains("4,60"),
"the sequence base value sums 2T + 2A"
)
controller.element_dialog.confirmed.emit()
controller.element_dialog.hide()
_check(
combo_marker.get_element_caption() == "2T+2A+SEQ",
"the confirmed marker stores a structured sequence"
)
_check_approx(
controller.get_element_catalog().get_segment_base_value(combo_marker),
4.60,
"the structured sequence has the summed base value"
)
_check(controller.undo(), "the structured sequence can be undone")
controller.help_button.pressed.emit()
_check(controller.help_dialog.visible, "help button opens the help dialog")
_check(