Introduce architettura multi-sport con catalogo, engine scoring e overlay.

Catalogo sport in YAML, board implicito, engine per volley/basket/timed/racket/timer/generic, regia e app Android allineate.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-09 20:11:21 +02:00
parent 53f9a6a884
commit e727069d43
56 changed files with 1783 additions and 223 deletions

View File

@@ -1,13 +1,30 @@
module Public
module LiveHelper
def live_score_sets_label(score_state)
def live_score_sets_label(score_state, match = nil)
return nil unless score_state
"Set #{score_state.current_set} · Set vinti #{score_state.home_sets}-#{score_state.away_sets}"
board = match&.effective_board_type || score_state.effective_board_type
case board
when "basket", "timed"
live_score_period_label(match, score_state)
when "timer"
"Cronometro"
when "generic"
"Punteggio"
else
"Set #{score_state.current_set} · Set vinti #{score_state.home_sets}-#{score_state.away_sets}"
end
end
def live_score_period_label(match, score_state)
return "" unless score_state
score_state.current_period_label
end
def live_score_partials_label(score_state)
return nil unless score_state
return nil unless score_state.effective_board_type.in?(%w[volley racket])
partials = Array(score_state.set_partials)
return nil if partials.empty?
@@ -58,7 +75,17 @@ module Public
def live_score_points_label(match, score_state)
return "" unless score_state
"#{match.team.name} #{score_state.home_points} - #{score_state.away_points} #{match.opponent_name}"
board = match.effective_board_type
home = case board
when "basket", "timed" then score_state.basket_home_score
else score_state.home_points
end
away = case board
when "basket", "timed" then score_state.basket_away_score
else score_state.away_points
end
"#{match.team.name} #{home} - #{away} #{match.opponent_name}"
end
private

View File

@@ -0,0 +1,32 @@
module Public
module RegiaHelper
def regia_board_partial(match)
board = match.effective_board_type
partial = "public/regia/#{board}"
lookup_context.exists?(partial, [], true) ? partial : "public/regia/volley"
end
def regia_header_subtitle(match, score)
board = match.effective_board_type
case board
when "basket", "timed"
live_score_period_label(match, score)
when "timer"
"Cronometro"
when "generic"
"Punteggio"
else
"Set #{score.current_set}"
end
end
def format_clock_secs(secs, count_up: false)
total = secs.to_i
return count_up ? "0:00" : "" if total <= 0 && !count_up
m = total / 60
s = total % 60
format("%d:%02d", m, s)
end
end
end