Add dynamic uniform type detection via colors/teams.json#732
Add dynamic uniform type detection via colors/teams.json#732jc214809 wants to merge 3 commits intoMLB-LED-Scoreboard:devfrom
Conversation
Any non-standard key in a team's color object (beyond home/text/accent) is automatically registered as a uniform type. The MLB API detection string is derived from the key name (snake_case -> Title Case) with case-insensitive matching, so city_connect matches "City Connect 2.0 Jersey" and cincy matches "CINCY Jersey" without any hardcoding. Adds Reds CINCY alternate jersey colors to colors/teams.example.json and updates schema to allow arbitrary uniform type sub-objects. Also adds .claude/ to .gitignore.
ty-porter
left a comment
There was a problem hiding this comment.
This is a great feature and future-proofs new team color additions. I think we need to make sure it'll work more holistically with our existing tooling.
I left some suggestions to cover that.
| return MODIFIER + mod | ||
|
|
||
|
|
||
| def _colors_ignored_keys(): |
There was a problem hiding this comment.
This subverts how the validator works and seems fairly flaky -- this validator is complicated so I'm worried that changing how it works based on user input is a potential minefield. There's also an upsert feature which checks if there's a missing key and adds it if it's not there, and removes things that aren't needed any more. For better or worse, it's one of the only ways we have to automatically migrate configs when versions change.
The special ignore_keys setting overrides both of those migration features, so this is a little unsafe.
What if we added a dict of special uniforms:
"cin": {
"home": {
"r": 1,
"g": 2,
"b": 3
},
"text": {
"r": 1,
"g": 2,
"b": 3
},
"accent": {
"r": 1,
"g": 2,
"b": 3
},
"special_uniforms": {
"city_connect": {
"r": 1,
"g": 2,
"b": 3
},
"cincy": {
"r": 1,
"g": 2,
"b": 3
}
}
}What this lets us do is mark special_uniforms unsafe:
"ignored_keys": [
"special_uniforms" + make_modifier(IGNORE_SUBPATHS),
"plugins" + make_modifier(IGNORE_SUBPATHS)
]There was a problem hiding this comment.
Unfortunately this strategy will expand the scope of this PR to touch every single team's colors entry and is also a breaking change, anyone with an existing custom city_connect setup won't get migrated automatically.
I'm personally OK with breaking those custom colors
| "b": 237 | ||
| } | ||
| }, | ||
| "cincy": { |
There was a problem hiding this comment.
This will probably have to get added to the schema as a default value
Any non-standard key in a team's color object (beyond home/text/accent) is
automatically registered as a uniform type. The MLB API detection string is
derived from the key name (snake_case -> Title Case) with case-insensitive
matching, so city_connect matches "City Connect 2.0 Jersey" and cincy matches
"CINCY Jersey" without any hardcoding. Adds Reds CINCY alternate jersey colors
to colors/teams.example.json and updates schema to allow arbitrary uniform
type sub-objects.