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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user