feat: ISU-Elementkatalog mit Base Values für 2025/26

- ElementDefinition/ElementCatalog in src/core/rules mit JSON-Daten
- 24 Sprünge, 16 Pirouetten und 2 Sequenzen aus ISU Communication 2707
- Lookup nach Familie/Level, kanonischen Suffixen und Anzeigenamen
- Level-Suffixe werden beim Übernehmen ins Level-Feld normalisiert
- Base-Value-Hinweis samt Quellen-Tooltip im Element-Inspector
- 160 neue Regelwerk-Assertions; Whiteboard-Tests erweitert (766 gesamt)
- JSON über include_filter in allen Export-Presets
- Docs: isu-rules.md, Findings, Architektur und Roadmap aktualisiert
This commit is contained in:
torsten 2026-10-31 09:01:47 +01:00
parent d1a6faa53e
commit 789fbc2826
17 changed files with 1577 additions and 34 deletions

View file

@ -7,7 +7,7 @@ advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
include_filter="*.json"
exclude_filter="tests/*,prototype/*,docs/*,addons/*,assets/models/*"
export_path="build/linux/rinkplanner.x86_64"
patches=PackedStringArray()
@ -39,7 +39,7 @@ advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
include_filter="*.json"
exclude_filter="tests/*,prototype/*,docs/*,addons/*,assets/models/*"
export_path="build/windows/rinkplanner.exe"
patches=PackedStringArray()
@ -94,7 +94,7 @@ advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
include_filter="*.json"
exclude_filter="tests/*,prototype/*,docs/*,addons/*,assets/models/*"
export_path="build/macos/rinkplanner.zip"
patches=PackedStringArray()
@ -214,7 +214,7 @@ advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
include_filter="*.json"
exclude_filter="tests/*,prototype/*,docs/*,addons/*,assets/models/*"
export_path="build/android/rinkplanner.apk"
patches=PackedStringArray()

View file

@ -565,7 +565,7 @@ caret_blink = true
[node name="ElementDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Element"
size = Vector2i(520, 420)
size = Vector2i(520, 460)
ok_button_text = "Übernehmen"
cancel_button_text = "Abbrechen"
@ -573,7 +573,7 @@ cancel_button_text = "Abbrechen"
offset_left = 12.0
offset_top = 12.0
offset_right = 508.0
offset_bottom = 350.0
offset_bottom = 390.0
theme_override_constants/separation = 8
[node name="ElementTypeLabel" type="Label" parent="ElementDialog/ElementBox"]
@ -615,6 +615,13 @@ custom_minimum_size = Vector2(0, 56)
layout_mode = 2
theme_override_font_sizes/font_size = 17
[node name="ElementValueLabel" type="Label" parent="ElementDialog/ElementBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.74902, 0.803922, 0.878431, 1)
theme_override_font_sizes/font_size = 15
text = "Base Value: –"
[node name="ElementDurationLabel" type="Label" parent="ElementDialog/ElementBox"]
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
@ -631,6 +638,7 @@ step = 0.1
suffix = " s"
[node name="ElementHint" type="Label" parent="ElementDialog/ElementBox"]
custom_minimum_size = Vector2(480, 0)
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 14

View file

@ -0,0 +1,365 @@
{
"schema_version": 1,
"season": "2025/26",
"discipline": "Single & Pair Skating",
"valid_from": "2025-07-01",
"source": "ISU Communication No. 2707, Scale of Values valid as of July 1, 2025",
"elements": [
{
"code": "1T",
"name": "Single toe loop",
"type": "jump",
"base_value": 0.4
},
{
"code": "1S",
"name": "Single Salchow",
"type": "jump",
"base_value": 0.4
},
{
"code": "1Lo",
"name": "Single loop",
"type": "jump",
"base_value": 0.5
},
{
"code": "1F",
"name": "Single flip",
"type": "jump",
"base_value": 0.5
},
{
"code": "1Lz",
"name": "Single Lutz",
"type": "jump",
"base_value": 0.6
},
{
"code": "1A",
"name": "Single Axel",
"type": "jump",
"base_value": 1.1
},
{
"code": "2T",
"name": "Double toe loop",
"type": "jump",
"base_value": 1.3
},
{
"code": "2S",
"name": "Double Salchow",
"type": "jump",
"base_value": 1.3
},
{
"code": "2Lo",
"name": "Double loop",
"type": "jump",
"base_value": 1.7
},
{
"code": "2F",
"name": "Double flip",
"type": "jump",
"base_value": 1.8
},
{
"code": "2Lz",
"name": "Double Lutz",
"type": "jump",
"base_value": 2.1
},
{
"code": "2A",
"name": "Double Axel",
"type": "jump",
"base_value": 3.3
},
{
"code": "3T",
"name": "Triple toe loop",
"type": "jump",
"base_value": 4.2
},
{
"code": "3S",
"name": "Triple Salchow",
"type": "jump",
"base_value": 4.3
},
{
"code": "3Lo",
"name": "Triple loop",
"type": "jump",
"base_value": 4.9
},
{
"code": "3F",
"name": "Triple flip",
"type": "jump",
"base_value": 5.3
},
{
"code": "3Lz",
"name": "Triple Lutz",
"type": "jump",
"base_value": 5.9
},
{
"code": "3A",
"name": "Triple Axel",
"type": "jump",
"base_value": 8.0
},
{
"code": "4T",
"name": "Quadruple toe loop",
"type": "jump",
"base_value": 9.5
},
{
"code": "4S",
"name": "Quadruple Salchow",
"type": "jump",
"base_value": 9.7
},
{
"code": "4Lo",
"name": "Quadruple loop",
"type": "jump",
"base_value": 10.5
},
{
"code": "4F",
"name": "Quadruple flip",
"type": "jump",
"base_value": 11.0
},
{
"code": "4Lz",
"name": "Quadruple Lutz",
"type": "jump",
"base_value": 11.5
},
{
"code": "4A",
"name": "Quadruple Axel",
"type": "jump",
"base_value": 12.5
},
{
"code": "USp",
"name": "Upright spin",
"type": "spin",
"base_values": {
"B": 1.0,
"1": 1.2,
"2": 1.5,
"3": 1.9,
"4": 2.4
}
},
{
"code": "LSp",
"name": "Layback spin",
"type": "spin",
"base_values": {
"B": 1.2,
"1": 1.5,
"2": 1.9,
"3": 2.4,
"4": 2.7
}
},
{
"code": "CSp",
"name": "Camel spin",
"type": "spin",
"base_values": {
"B": 1.1,
"1": 1.4,
"2": 1.8,
"3": 2.3,
"4": 2.6
}
},
{
"code": "SSp",
"name": "Sit spin",
"type": "spin",
"base_values": {
"B": 1.1,
"1": 1.3,
"2": 1.6,
"3": 2.1,
"4": 2.5
}
},
{
"code": "FUSp",
"name": "Flying upright spin",
"type": "spin",
"base_values": {
"B": 1.5,
"1": 1.7,
"2": 2.0,
"3": 2.4,
"4": 2.9
}
},
{
"code": "FLSp",
"name": "Flying layback spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.4,
"3": 2.9,
"4": 3.2
}
},
{
"code": "FCSp",
"name": "Flying camel spin",
"type": "spin",
"base_values": {
"B": 1.6,
"1": 1.9,
"2": 2.3,
"3": 2.8,
"4": 3.2
}
},
{
"code": "FSSp",
"name": "Flying sit spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.3,
"3": 2.6,
"4": 3.0
}
},
{
"code": "CUSp",
"name": "Change foot upright spin",
"type": "spin",
"base_values": {
"B": 1.5,
"1": 1.7,
"2": 2.0,
"3": 2.4,
"4": 2.9
}
},
{
"code": "FCUSp",
"name": "Flying change foot upright spin",
"type": "spin",
"base_values": {
"B": 1.5,
"1": 1.7,
"2": 2.0,
"3": 2.4,
"4": 2.9
}
},
{
"code": "CLSp",
"name": "Change foot layback spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.4,
"3": 2.9,
"4": 3.2
}
},
{
"code": "FCLSp",
"name": "Flying change foot layback spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.4,
"3": 2.9,
"4": 3.2
}
},
{
"code": "CoSp",
"name": "Combination spin",
"type": "spin",
"base_values": {
"B": 1.5,
"1": 1.7,
"2": 2.0,
"3": 2.5,
"4": 3.0
}
},
{
"code": "FCoSp",
"name": "Flying combination spin",
"type": "spin",
"base_values": {
"B": 1.5,
"1": 1.7,
"2": 2.0,
"3": 2.5,
"4": 3.0
}
},
{
"code": "CCoSp",
"name": "Change foot combination spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.5,
"3": 3.0,
"4": 3.5
}
},
{
"code": "FCCoSp",
"name": "Flying change foot combination spin",
"type": "spin",
"base_values": {
"B": 1.7,
"1": 2.0,
"2": 2.5,
"3": 3.0,
"4": 3.5
}
},
{
"code": "StSq",
"name": "Step sequence",
"type": "sequence",
"base_values": {
"B": 1.5,
"1": 1.8,
"2": 2.6,
"3": 3.3,
"4": 3.9
}
},
{
"code": "ChSq",
"name": "Choreographic step sequence",
"type": "sequence",
"base_values": {
"1": 3.0
}
}
]
}

View file

@ -0,0 +1,304 @@
class_name ElementCatalog
extends RefCounted
## Season-specific ISU element catalog (Scale of Values).
##
## The catalog is pure data (JSON) plus read-only lookups. It stays independent
## of the whiteboard controller so annual SoV updates only replace the data
## file. Lookups accept family codes ("CCoSp", "StSq") and canonical codes with
## a level suffix ("CCoSp4", "StSqB"). Jump levels are ignored because jumps
## have a single base value.
const DEFAULT_PATH := "res://src/core/rules/data/isu_sov_2025_26.json"
const SUPPORTED_SCHEMA_VERSION := 1
const TYPE_BY_NAME := {
"jump": PathSegment.ElementType.JUMP,
"spin": PathSegment.ElementType.SPIN,
"sequence": PathSegment.ElementType.SEQUENCE,
}
var schema_version: int = 0
var season: String = ""
var discipline: String = ""
var valid_from: String = ""
var source: String = ""
var _definitions: Array[ElementDefinition] = []
var _by_key: Dictionary[String, ElementDefinition] = {}
var _errors: PackedStringArray = PackedStringArray()
static func load_default() -> ElementCatalog:
return load_from(DEFAULT_PATH)
static func load_from(path: String) -> ElementCatalog:
var catalog := ElementCatalog.new()
catalog._parse_file(path)
return catalog
## All definitions in file order (jumps, spins, sequences).
func get_definitions() -> Array[ElementDefinition]:
var copy: Array[ElementDefinition] = []
copy.assign(_definitions)
return copy
func get_definition_count() -> int:
return _definitions.size()
## Looks up a family by code. The lookup is case-insensitive and also accepts
## canonical codes with a level suffix, e.g. "CCoSp4" or "StSqB".
func find(code: String) -> ElementDefinition:
var key := _normalize(code)
if key.is_empty():
return null
if _by_key.has(key):
return _by_key[key]
var stripped := _strip_level_suffix(key)
if stripped != key and _by_key.has(stripped):
return _by_key[stripped]
return null
func has_code(code: String) -> bool:
return find(code) != null
## Level encoded in a canonical code suffix ("CCoSp4" -> 4, "StSqB" -> 0),
## or -1 when the code has no suffix.
func get_level_suffix(code: String) -> int:
return _level_from_code(code)
## Returns the base value for a code and level, or -1 when the code is unknown,
## the level is missing or the code belongs to another element type.
## A level of -1 is inferred from a trailing suffix ("4", "B"). An explicit
## suffix in [param code] wins over [param level], because the canonical code is
## self-describing.
func get_base_value(
code: String,
level: int = -1,
expected_type: PathSegment.ElementType = PathSegment.ElementType.NONE
) -> float:
var definition := find(code)
if definition == null:
return -1.0
if (
expected_type != PathSegment.ElementType.NONE
and definition.element_type != expected_type
):
return -1.0
var resolved := _level_from_code(code)
if resolved < 0:
resolved = level
if resolved < 0:
resolved = 0
# Some elements only exist at one level (ChSq1). A bare family code then
# resolves to that single level instead of reporting it as unknown.
if not definition.has_level(resolved) and resolved == 0:
var levels := definition.get_levels()
if levels.size() == 1:
resolved = levels[0]
return definition.get_base_value(resolved)
## Base value of an element-tagged segment. Sequences without a code and
## elements outside the catalog return -1.
func get_segment_base_value(segment: PathSegment) -> float:
if segment == null or not segment.is_element():
return -1.0
if segment.element_code.strip_edges().is_empty():
return -1.0
return get_base_value(
segment.element_code,
segment.element_level,
segment.element_type
)
## Family codes for one element type, in file order.
func get_codes(
type: PathSegment.ElementType = PathSegment.ElementType.NONE
) -> PackedStringArray:
var codes := PackedStringArray()
for definition: ElementDefinition in _definitions:
if type != PathSegment.ElementType.NONE and definition.element_type != type:
continue
codes.append(definition.code)
return codes
## Family codes for the inspector, matched against code or display name.
func suggest(
type: PathSegment.ElementType,
query: String,
limit: int = 8
) -> PackedStringArray:
var codes := PackedStringArray()
if limit <= 0:
return codes
var needle := query.strip_edges().to_lower()
for definition: ElementDefinition in _definitions:
if type != PathSegment.ElementType.NONE and definition.element_type != type:
continue
if (
not needle.is_empty()
and not definition.code.to_lower().begins_with(needle)
and not definition.display_name.to_lower().contains(needle)
):
continue
codes.append(definition.code)
if codes.size() >= limit:
break
return codes
func get_errors() -> PackedStringArray:
return _errors.duplicate()
func validate() -> PackedStringArray:
var errors := _errors.duplicate()
if schema_version != SUPPORTED_SCHEMA_VERSION:
errors.append(
"unsupported catalog schema %d (expected %d)"
% [schema_version, SUPPORTED_SCHEMA_VERSION]
)
if season.strip_edges().is_empty():
errors.append("catalog season must not be empty")
if source.strip_edges().is_empty():
errors.append("catalog source must not be empty")
if _definitions.is_empty():
errors.append("catalog contains no elements")
return errors
func is_valid() -> bool:
return validate().is_empty()
func _parse_file(path: String) -> void:
var file := FileAccess.open(path, FileAccess.READ)
if file == null:
_errors.append("cannot open element catalog '%s'" % path)
return
var json := JSON.new()
var error := json.parse(file.get_as_text())
if error != OK:
_errors.append(
"invalid catalog JSON at line %d: %s"
% [json.get_error_line(), json.get_error_message()]
)
return
if typeof(json.data) != TYPE_DICTIONARY:
_errors.append("catalog root must be a JSON object")
return
_parse_root(json.data as Dictionary)
func _parse_root(data: Dictionary) -> void:
schema_version = int(data.get("schema_version", 0))
season = str(data.get("season", "")).strip_edges()
discipline = str(data.get("discipline", "")).strip_edges()
valid_from = str(data.get("valid_from", "")).strip_edges()
source = str(data.get("source", "")).strip_edges()
var entries: Variant = data.get("elements", [])
if typeof(entries) != TYPE_ARRAY:
_errors.append("catalog 'elements' must be an array")
return
for entry: Variant in entries:
if typeof(entry) != TYPE_DICTIONARY:
_errors.append("catalog contains a non-object element entry")
continue
var definition := _parse_definition(entry as Dictionary)
if definition == null:
continue
for message: String in definition.validate():
_errors.append("%s: %s" % [definition.code, message])
var key := _normalize(definition.code)
if _by_key.has(key):
_errors.append("duplicate element code '%s'" % definition.code)
continue
_by_key[key] = definition
_definitions.append(definition)
func _parse_definition(entry: Dictionary) -> ElementDefinition:
var code := str(entry.get("code", "")).strip_edges()
var type_name := str(entry.get("type", "")).strip_edges().to_lower()
if not TYPE_BY_NAME.has(type_name):
_errors.append("unknown element type '%s' for code '%s'" % [type_name, code])
return null
var definition := ElementDefinition.new()
definition.code = code
definition.display_name = str(entry.get("name", "")).strip_edges()
definition.element_type = TYPE_BY_NAME[type_name]
if entry.has("base_values"):
var values: Variant = entry["base_values"]
if typeof(values) != TYPE_DICTIONARY:
_errors.append("'base_values' of '%s' must be an object" % code)
return null
for level_key: Variant in values as Dictionary:
var level := ElementDefinition.parse_level_key(str(level_key))
if level < 0:
_errors.append(
"'%s' contains invalid level key '%s'" % [code, str(level_key)]
)
continue
var raw: Variant = (values as Dictionary)[level_key]
if typeof(raw) != TYPE_FLOAT and typeof(raw) != TYPE_INT:
_errors.append("'%s' level '%s' must be numeric" % [code, str(level_key)])
continue
definition.base_values[level] = float(raw)
elif entry.has("base_value"):
var raw: Variant = entry["base_value"]
if typeof(raw) != TYPE_FLOAT and typeof(raw) != TYPE_INT:
_errors.append("'%s' base_value must be numeric" % code)
return null
definition.base_values[0] = float(raw)
else:
_errors.append("'%s' has no base value" % code)
return null
return definition
static func _normalize(code: String) -> String:
return code.strip_edges().to_lower()
static func _strip_level_suffix(key: String) -> String:
if key.length() < 2:
return key
var last := key.substr(key.length() - 1, 1)
if last == "b" or (last >= "1" and last <= "4"):
return key.substr(0, key.length() - 1)
return key
static func _level_from_code(code: String) -> int:
var key := _normalize(code)
if key.length() < 2:
return -1
var last := key.substr(key.length() - 1, 1)
if last == "b":
return 0
if last >= "1" and last <= "4":
return int(last)
return -1

View file

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

View file

@ -0,0 +1,109 @@
class_name ElementDefinition
extends Resource
## One element family from the ISU Scale of Values.
##
## A family combines the base code with its difficulty levels, e.g. "CCoSp"
## with Base and levels 1-4. Jumps are not levelled: they keep a single base
## value at level 0. Values come from a season-specific catalog file so annual
## SoV updates never touch the model or the canvas.
const MAX_LEVEL := PathSegment.ELEMENT_MAX_LEVEL
@export var code: String = ""
@export var display_name: String = ""
@export var element_type: PathSegment.ElementType = PathSegment.ElementType.NONE
## Base value per level. Key 0 is "Base", keys 1-4 are the graded levels.
@export var base_values: Dictionary[int, float] = {}
func is_leveled() -> bool:
return element_type != PathSegment.ElementType.JUMP
func has_level(level: int) -> bool:
return base_values.has(level)
## Returns the base value for [param level], or -1 when the level is unknown.
## Jumps ignore the level and always use their single value.
func get_base_value(level: int) -> float:
var resolved := level
if not is_leveled():
resolved = 0
if not base_values.has(resolved):
return -1.0
return base_values[resolved]
## Levels present in this definition, ascending. Empty for invalid data.
func get_levels() -> Array[int]:
var levels: Array[int] = []
levels.assign(base_values.keys())
levels.sort()
return levels
## Canonical code for a level, e.g. "CCoSpB", "CCoSp4" or "3Lz".
func get_code_for_level(level: int) -> String:
if not is_leveled():
return code
return code + level_key(level)
## All canonical codes of this family.
func get_codes() -> PackedStringArray:
var codes := PackedStringArray()
for level: int in get_levels():
codes.append(get_code_for_level(level))
return codes
static func level_key(level: int) -> String:
return "B" if level <= 0 else str(level)
## Parses "B" (base) or "0"-"4" and returns -1 for anything else.
static func parse_level_key(key: String) -> int:
var cleaned := key.strip_edges().to_upper()
if cleaned == "B":
return 0
if cleaned.is_valid_int():
var level := int(cleaned)
if level >= 0 and level <= MAX_LEVEL:
return level
return -1
static func level_label(level: int) -> String:
return "Base" if level <= 0 else "Level %d" % level
func validate() -> PackedStringArray:
var errors := PackedStringArray()
if code.strip_edges().is_empty():
errors.append("code must not be empty")
if display_name.strip_edges().is_empty():
errors.append("display_name must not be empty")
if element_type == PathSegment.ElementType.NONE:
errors.append("element_type must not be NONE")
if base_values.is_empty():
errors.append("base_values must not be empty")
return errors
for level: int in base_values:
if level < 0 or level > MAX_LEVEL:
errors.append("base_values contains invalid level %d" % level)
if base_values[level] <= 0.0:
errors.append("base value at level %d must be positive" % level)
if not is_leveled():
if base_values.size() != 1 or not base_values.has(0):
errors.append("jumps must carry exactly one base value at level 0")
return errors
func is_valid() -> bool:
return validate().is_empty()

View file

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

View file

@ -49,6 +49,7 @@ const PROFILE_SPEEDS := [3.0, 3.8, 4.3, 5.0, 6.0]
const ROUTINES_DIR := "user://routines"
const EXPORTS_DIR := "user://exports"
const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn")
const ELEMENT_CATALOG_SCRIPT := preload("res://src/core/rules/element_catalog.gd")
const EXPORT_IMAGE_SIZE := Vector2i(2560, 1600)
const AUTOSAVE_PATH := "user://autosave.tres"
const SYNC_SETTINGS_PATH := "user://sync.cfg"
@ -109,6 +110,7 @@ const COMPACT_LAYOUT_WIDTH := 1280.0
@onready var element_dialog_type_option: OptionButton = %ElementDialogTypeOption
@onready var element_code_edit: LineEdit = %ElementCodeEdit
@onready var element_level_option: OptionButton = %ElementLevelOption
@onready var element_value_label: Label = %ElementValueLabel
@onready var element_duration_spin: SpinBox = %ElementDurationSpin
@onready var segment_label_dialog: ConfirmationDialog = %SegmentLabelDialog
@onready var segment_label_edit: LineEdit = %SegmentLabelEdit
@ -149,6 +151,7 @@ var _direction: PathSegment.Direction = PathSegment.Direction.FORWARD
var _edge: PathSegment.Edge = PathSegment.Edge.OUTSIDE
var _element_type: PathSegment.ElementType = PathSegment.ElementType.JUMP
var _element_level: int = 0
var _element_catalog: ElementCatalog
var _preset_speed: float = DEFAULT_SPEED_MPS
var _current_path: String = ""
var _dirty: bool = false
@ -174,6 +177,11 @@ var _sync_running: bool = false
func _ready() -> void:
autosave_timer.wait_time = AUTOSAVE_DELAY_SECONDS
_element_catalog = ELEMENT_CATALOG_SCRIPT.load_default()
if not _element_catalog.get_errors().is_empty():
push_warning(
"Element catalog: %s" % ", ".join(_element_catalog.get_errors())
)
_setup_tool_options()
_setup_file_menu()
_setup_playback_controls()
@ -396,11 +404,81 @@ func get_element_level() -> int:
return _element_level
func get_element_catalog() -> ElementCatalog:
return _element_catalog
## Updates the Base-Value hint in the element inspector. Public so tests and
## callers that set the controls programmatically can refresh it explicitly.
func update_element_value_hint() -> void:
if element_value_label == null:
return
if _element_catalog == null:
element_value_label.text = ""
return
var type_index := element_dialog_type_option.selected
var type: PathSegment.ElementType = PathSegment.ElementType.NONE
if type_index >= 0:
type = element_dialog_type_option.get_item_id(type_index)
var level := 0
if element_level_option.selected >= 0:
level = element_level_option.get_item_id(element_level_option.selected)
var code := element_code_edit.text.strip_edges()
var source := "%s · %s" % [_element_catalog.season, _element_catalog.source]
element_value_label.tooltip_text = source
if type == PathSegment.ElementType.NONE or code.is_empty():
element_value_label.text = "Base Value: –"
return
var value := _element_catalog.get_base_value(code, level, type)
if value < 0.0:
element_value_label.text = (
"Base Value: – (Kürzel nicht im Katalog %s)" % _element_catalog.season
)
return
element_value_label.text = (
"Base Value: %s" % ("%.2f" % value).replace(".", ",")
)
func get_selected_element_caption() -> String:
var segment := get_selected_segment()
return segment.get_element_caption() if segment != null else ""
## Splits a canonical level suffix ("CCoSp4", "StSqB") into the level field so
## segments keep the family code and the level separate. Unknown codes and
## mismatched types are left untouched.
func _normalize_element_input(
type: PathSegment.ElementType,
code: String,
level: int
) -> Dictionary:
var cleaned := code.strip_edges().left(PathSegment.ELEMENT_CODE_MAX_LENGTH)
var clamped := clampi(level, 0, PathSegment.ELEMENT_MAX_LEVEL)
if (
_element_catalog == null
or type == PathSegment.ElementType.NONE
or cleaned.length() < 2
):
return {"code": cleaned, "level": clamped}
var suffix := _element_catalog.get_level_suffix(cleaned)
if suffix < 0:
return {"code": cleaned, "level": clamped}
var family := cleaned.left(cleaned.length() - 1)
var definition := _element_catalog.find(family)
if definition == null or definition.element_type != type:
return {"code": cleaned, "level": clamped}
if not definition.has_level(suffix):
return {"code": cleaned, "level": clamped}
return {"code": family, "level": suffix}
## Tags the selected segment with an element (or removes the tag). Returns true
## when the model changed. A negative [param duration] keeps the current stand
## time.
@ -420,6 +498,10 @@ func set_selected_element(
var cleaned := code.strip_edges().left(PathSegment.ELEMENT_CODE_MAX_LENGTH)
var clamped := clampi(level, 0, PathSegment.ELEMENT_MAX_LEVEL)
if type != PathSegment.ElementType.NONE:
var normalized := _normalize_element_input(type, cleaned, clamped)
cleaned = str(normalized["code"])
clamped = int(normalized["level"])
var clamped_duration := -1.0
if type == PathSegment.ElementType.NONE:
cleaned = ""
@ -482,10 +564,12 @@ func add_element_marker(
segment.curve = curve
segment.duration_seconds = 0.0
segment.timing_mode = PathSegment.TimingMode.SPEED
var input_level := _element_level if level < 0 else level
var normalized := _normalize_element_input(type, code, input_level)
segment.set_element(
type,
code,
_element_level if level < 0 else level
str(normalized["code"]),
int(normalized["level"])
)
segment.set_element_duration(
float(ELEMENT_DEFAULT_DURATIONS.get(type, 0.0))
@ -526,6 +610,20 @@ func _setup_element_controls() -> void:
for level: int in range(1, PathSegment.ELEMENT_MAX_LEVEL + 1):
element_level_option.add_item("Level %d" % level, level)
element_code_edit.text_changed.connect(_on_element_code_text_changed)
element_level_option.item_selected.connect(_on_element_value_option_selected)
element_dialog_type_option.item_selected.connect(
_on_element_value_option_selected
)
func _on_element_code_text_changed(_text: String) -> void:
update_element_value_hint()
func _on_element_value_option_selected(_index: int) -> void:
update_element_value_hint()
func _on_element_type_selected(index: int) -> void:
var type: PathSegment.ElementType = element_type_option.get_item_id(index)
@ -565,9 +663,10 @@ func _open_element_dialog() -> void:
else "Sequenzbereiche nutzen die Segmentdauer in der Timing-Leiste"
)
element_dialog.popup_centered(Vector2i(520, 420))
element_dialog.popup_centered(Vector2i(520, 460))
element_code_edit.grab_focus()
element_code_edit.select_all()
update_element_value_hint()
func _on_element_confirmed() -> void:

View file

@ -21,6 +21,9 @@ $GODOT --headless --path rinkplanner --import
# Run model tests
$GODOT --headless --path rinkplanner --script res://tests/run_model_tests.gd
# Run ISU element catalog tests
$GODOT --headless --path rinkplanner --script res://tests/run_rules_tests.gd
# Run canvas transform/geometry tests
$GODOT --headless --path rinkplanner --script res://tests/run_canvas_tests.gd

View file

@ -0,0 +1,359 @@
extends SceneTree
## Headless tests for the ISU element catalog.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_rules_tests.gd
const ElementDefinitionScript := preload("res://src/core/rules/element_definition.gd")
const ElementCatalogScript := preload("res://src/core/rules/element_catalog.gd")
const PathSegmentModel := preload("res://src/core/model/path_segment.gd")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
var _catalog: ElementCatalog
func _init() -> void:
_catalog = ElementCatalogScript.load_default()
_test_catalog_metadata()
_test_jump_values()
_test_spin_values()
_test_sequence_values()
_test_lookup_rules()
_test_suggestions()
_test_segment_integration()
_test_invalid_catalogs()
_finish()
func _test_catalog_metadata() -> void:
_check(_catalog != null, "catalog loads")
_check(
_catalog.get_errors().is_empty(),
"catalog parses without errors (%s)" % ", ".join(_catalog.get_errors())
)
_check(_catalog.is_valid(), "catalog is valid")
_check(_catalog.season == "2025/26", "catalog season is 2025/26")
_check(_catalog.source.contains("2707"), "catalog names ISU communication 2707")
_check(_catalog.valid_from == "2025-07-01", "catalog valid from 2025-07-01")
_check(_catalog.get_definition_count() == 42, "catalog has 42 element families")
_check(
_catalog.get_codes(PathSegment.ElementType.JUMP).size() == 24,
"catalog has 24 jump families"
)
_check(
_catalog.get_codes(PathSegment.ElementType.SPIN).size() == 16,
"catalog has 16 spin families"
)
_check(
_catalog.get_codes(PathSegment.ElementType.SEQUENCE).size() == 2,
"catalog has 2 sequence families"
)
var seen: Dictionary[String, bool] = {}
for definition: ElementDefinition in _catalog.get_definitions():
_check(definition.is_valid(), "'%s' is a valid definition" % definition.code)
_check(not seen.has(definition.code), "'%s' is unique" % definition.code)
seen[definition.code] = true
func _test_jump_values() -> void:
_check_approx(_catalog.get_base_value("1T"), 0.40, "1T base value")
_check_approx(_catalog.get_base_value("2A"), 3.30, "2A base value")
_check_approx(_catalog.get_base_value("3Lz"), 5.90, "3Lz base value")
_check_approx(_catalog.get_base_value("3A"), 8.00, "3A base value")
_check_approx(_catalog.get_base_value("4Lo"), 10.50, "4Lo base value")
_check_approx(_catalog.get_base_value("4A"), 12.50, "4A base value")
_check_approx(
_catalog.get_base_value("3Lz", 4),
5.90,
"jump levels are ignored"
)
_check_approx(
_catalog.get_base_value("3Lz", 0, PathSegment.ElementType.JUMP),
5.90,
"jump lookup with matching type"
)
_check_approx(
_catalog.get_base_value("3Lz", 0, PathSegment.ElementType.SPIN),
-1.0,
"jump lookup rejects a spin type"
)
var triple_lutz: ElementDefinition = _catalog.find("3Lz")
_check(triple_lutz != null, "3Lz family exists")
_check(triple_lutz.display_name == "Triple Lutz", "3Lz has a display name")
_check(not triple_lutz.is_leveled(), "jumps are not levelled")
_check(
triple_lutz.get_codes() == PackedStringArray(["3Lz"]),
"jump family has one canonical code"
)
func _test_spin_values() -> void:
_check_approx(_catalog.get_base_value("USpB"), 1.00, "USpB base value")
_check_approx(_catalog.get_base_value("USp4"), 2.40, "USp4 base value")
_check_approx(_catalog.get_base_value("LSp4"), 2.70, "LSp4 base value")
_check_approx(_catalog.get_base_value("FCSp4"), 3.20, "FCSp4 base value")
_check_approx(_catalog.get_base_value("CCoSpB"), 1.70, "CCoSpB base value")
_check_approx(_catalog.get_base_value("CCoSp4"), 3.50, "CCoSp4 base value")
_check_approx(
_catalog.get_base_value("CCoSp", 4),
3.50,
"spin lookup by family and level"
)
_check_approx(
_catalog.get_base_value("CCoSp4", -1),
3.50,
"spin lookup infers the level suffix"
)
var combination: ElementDefinition = _catalog.find("CCoSp")
_check(combination != null, "CCoSp family exists")
_check(combination.is_leveled(), "spins are levelled")
_check(
combination.get_codes()
== PackedStringArray(["CCoSpB", "CCoSp1", "CCoSp2", "CCoSp3", "CCoSp4"]),
"CCoSp exposes Base through level 4"
)
_check(
ElementDefinitionScript.level_label(0) == "Base",
"level 0 is labelled Base"
)
_check(
ElementDefinitionScript.level_label(3) == "Level 3",
"level 3 is labelled Level 3"
)
func _test_sequence_values() -> void:
_check_approx(_catalog.get_base_value("StSqB"), 1.50, "StSqB base value")
_check_approx(_catalog.get_base_value("StSq3"), 3.30, "StSq3 base value")
_check_approx(_catalog.get_base_value("ChSq1"), 3.00, "ChSq1 base value")
_check_approx(
_catalog.get_base_value("ChSq"),
3.00,
"single-level sequence resolves without a suffix"
)
_check_approx(
_catalog.get_base_value("ChSq4"),
-1.0,
"unknown sequence level is rejected"
)
func _test_lookup_rules() -> void:
_check(_catalog.find("3Lz") != null, "exact lookup works")
_check(_catalog.find(" 3lz ") != null, "lookup trims and ignores case")
_check(_catalog.find("CCoSp4") != null, "lookup accepts a level suffix")
_check(_catalog.find("StSqB") != null, "lookup accepts the Base suffix")
_check(_catalog.find("3X") == null, "unknown code returns null")
_check(_catalog.find("") == null, "empty code returns null")
_check(not _catalog.has_code("3X"), "unknown code is not reported as present")
_check(
_catalog.get_level_suffix("CCoSp4") == 4,
"a spin suffix is parsed as level 4"
)
_check(
_catalog.get_level_suffix("StSqB") == 0,
"a Base suffix is parsed as level 0"
)
_check(
_catalog.get_level_suffix("CCoSp") == -1,
"a family code has no level suffix"
)
_check(
_catalog.get_level_suffix("3Lz") == -1,
"a jump code has no level suffix"
)
_check_approx(
_catalog.get_base_value("CCoSp4", 2),
3.50,
"a canonical suffix wins over the level argument"
)
_check_approx(
_catalog.get_base_value("StSqB", 4),
1.50,
"a Base suffix wins over a graded level argument"
)
_check_approx(
_catalog.get_base_value("ChSq1", 0),
3.00,
"an explicit sequence suffix wins over level 0"
)
_check_approx(
_catalog.get_base_value("3X"),
-1.0,
"unknown code has no base value"
)
_check_approx(
_catalog.get_base_value(""),
-1.0,
"empty code has no base value"
)
func _test_suggestions() -> void:
var combined := _catalog.suggest(PathSegment.ElementType.SPIN, "ccosp", 8)
_check(
combined == PackedStringArray(["CCoSp"]),
"suggestions match a case-insensitive code prefix"
)
_check(
_catalog.suggest(PathSegment.ElementType.JUMP, "axel", 8).size() == 4,
"suggestions match the display name"
)
_check(
_catalog.suggest(PathSegment.ElementType.JUMP, "", 100).size() == 24,
"suggestions respect the element type filter"
)
_check(
_catalog.suggest(PathSegment.ElementType.JUMP, "", 3).size() == 3,
"suggestions respect the limit"
)
_check(
_catalog.suggest(PathSegment.ElementType.SPIN, "", 0).is_empty(),
"a zero limit returns no suggestions"
)
_check(
_catalog.suggest(PathSegment.ElementType.SPIN, "3Lz", 8).is_empty(),
"suggestions do not cross element types"
)
func _test_segment_integration() -> void:
var spin: PathSegment = PathSegmentModel.new()
spin.segment_id = "spin"
spin.curve = _make_point_curve(Vector2.ZERO)
spin.set_element(PathSegment.ElementType.SPIN, "CCoSp", 4)
_check_approx(
_catalog.get_segment_base_value(spin),
3.50,
"segment integration resolves a spin"
)
var jump: PathSegment = PathSegmentModel.new()
jump.segment_id = "jump"
jump.curve = _make_point_curve(Vector2.ZERO)
jump.set_element(PathSegment.ElementType.JUMP, "3Lz", 2)
_check_approx(
_catalog.get_segment_base_value(jump),
5.90,
"segment integration ignores jump levels"
)
var sequence: PathSegment = PathSegmentModel.new()
sequence.segment_id = "sequence"
sequence.curve = _make_point_curve(Vector2.ZERO)
sequence.set_element(PathSegment.ElementType.SEQUENCE, "StSq", 3)
_check_approx(
_catalog.get_segment_base_value(sequence),
3.30,
"segment integration resolves a sequence"
)
var untagged: PathSegment = PathSegmentModel.new()
untagged.segment_id = "untagged"
untagged.curve = _make_point_curve(Vector2.ZERO)
_check_approx(
_catalog.get_segment_base_value(untagged),
-1.0,
"untagged segments have no base value"
)
var coded: PathSegment = PathSegmentModel.new()
coded.segment_id = "coded"
coded.curve = _make_point_curve(Vector2.ZERO)
coded.set_element(PathSegment.ElementType.JUMP, "3Lz", 0)
coded.element_type = PathSegment.ElementType.SPIN
_check_approx(
_catalog.get_segment_base_value(coded),
-1.0,
"segment integration rejects a mismatched type"
)
func _test_invalid_catalogs() -> void:
var missing := ElementCatalogScript.load_from("user://does-not-exist.json")
_check(not missing.is_valid(), "a missing catalog is invalid")
_check(
_contains_error(missing.get_errors(), "cannot open"),
"a missing catalog reports the path"
)
var path := "user://invalid_catalog.json"
var file := FileAccess.open(path, FileAccess.WRITE)
file.store_string(
'{"schema_version": 1, "season": "test", "source": "test", '
+ '"elements": ['
+ '{"code": "3X", "name": "Unknown", "type": "lift", "base_value": 1.0},'
+ '{"code": "Bad", "name": "Bad", "type": "spin", "base_values": {"Z": 1.0}},'
+ '{"code": "Dup", "name": "First", "type": "jump", "base_value": 1.0},'
+ '{"code": "dup", "name": "Second", "type": "jump", "base_value": 2.0}'
+ "]}"
)
file.close()
var invalid := ElementCatalogScript.load_from(path)
_check(not invalid.is_valid(), "a catalog with bad data is invalid")
_check(
_contains_error(invalid.get_errors(), "unknown element type"),
"an unknown element type is reported"
)
_check(
_contains_error(invalid.get_errors(), "invalid level key"),
"an invalid level key is reported"
)
_check(
_contains_error(invalid.get_errors(), "duplicate element code"),
"a duplicate code is reported"
)
_check(
invalid.find("Dup") != null,
"the first definition of a duplicate stays available"
)
_check_approx(
invalid.get_base_value("Dup"),
1.0,
"the first definition of a duplicate keeps its value"
)
func _make_point_curve(point: Vector2) -> Curve2D:
var curve := Curve2D.new()
curve.add_point(point)
return curve
func _contains_error(errors: PackedStringArray, fragment: String) -> bool:
for error: String in errors:
if error.contains(fragment):
return true
return false
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _check_approx(actual: float, expected: float, message: String) -> void:
_check(
absf(actual - expected) <= 0.001,
"%s (expected %.3f, got %.3f)" % [message, expected, actual]
)
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)

View file

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

View file

@ -720,7 +720,11 @@ func _run() -> void:
"element code and level can be edited"
)
_check(
spin.get_element_caption() == "CCoSp4 L3",
spin.element_code == "CCoSp" and spin.element_level == 4,
"a canonical level suffix is moved into the level field"
)
_check(
spin.get_element_caption() == "CCoSp L4",
"marker caption includes code and level"
)
_check_approx(
@ -741,7 +745,7 @@ func _run() -> void:
_check(controller.redo(), "element edit can be redone")
spin = controller.get_active_section().get_segment_by_id(spin.segment_id)
_check(
spin != null and spin.get_element_caption() == "CCoSp4 L3",
spin != null and spin.get_element_caption() == "CCoSp L4",
"redo restores the element data"
)
@ -750,17 +754,54 @@ func _run() -> void:
controller.element_button.pressed.emit()
_check(controller.element_dialog.visible, "element button opens the dialog")
_check(
controller.element_code_edit.text == "CCoSp4",
"element dialog is prefilled with the code"
controller.element_code_edit.text == "CCoSp",
"element dialog is prefilled with the normalized code"
)
controller.element_code_edit.text = "CCoSp3"
_check(
controller.element_level_option.get_item_id(
controller.element_level_option.selected
) == 4,
"element dialog is prefilled with the normalized level"
)
var catalog := controller.get_element_catalog()
_check(catalog != null and catalog.season == "2025/26", "controller loads the ISU catalog")
_check(
controller.element_value_label.text.contains("3,50"),
"element dialog shows the base value of the current code and level"
)
controller.element_code_edit.text = "CCoSp"
controller.element_level_option.select(
controller.element_level_option.get_item_index(2)
)
controller.update_element_value_hint()
_check(
controller.element_value_label.text.contains("2,50"),
"base value follows a family code and level 2"
)
controller.element_code_edit.text = "CCoSp4"
controller.update_element_value_hint()
_check(
controller.element_value_label.text.contains("3,50"),
"a canonical suffix wins over the level control"
)
controller.element_code_edit.text = "3X"
controller.update_element_value_hint()
_check(
controller.element_value_label.text.contains("nicht im Katalog"),
"unknown codes are marked as not in the catalog"
)
controller.element_code_edit.text = "CCoSp"
controller.element_level_option.select(
controller.element_level_option.get_item_index(2)
)
controller.element_duration_spin.value = 6.5
controller.element_dialog.confirmed.emit()
_check(
controller.get_selected_element_caption() == "CCoSp3 L2",
controller.get_selected_element_caption() == "CCoSp L2",
"element dialog applies code and level"
)
_check_approx(