This commit is contained in:
salam committed 2026-09-12 15:05:49 +02:00
1 parent b961a3ad7c
commit da528df0e7
1 file changed
+64 -46
+64 -46
View File
@@ -555,8 +555,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
// Il valore Y dovrebbe essere configurabile in una interfaccia. Il valore iniziale lo fissiamo a Y = 180
// Somma Minuti Giocati da Player (SMG) nel DB
$somma_minuti = $val->total_min;
$tmp['somma_minuti'] = $val->total_min;
// il valore corrispondente al ruolo del Player (esempio un giocatore in Details ha ruolo = RW
// quindi Aspettativa Statistica (AS) per RW = 0.219)
@@ -569,59 +567,79 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
// exp_total_shots
// exp_shots_on_target
$somma_minuti = $val->total_min;
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) {
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype);
$tmp['asp_statistica_' . $bettype] = $asp_statistica;
if ($val->total_min < $this->y_value) {
// Se la SMG è < Y per quel Player prenderemo in considerazione solo l'Aspettativa Statistica (AS).
$tmp['asp_gioco_' . $bettype] = 0;
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else {
// Aspettativa Teorica (AT) Goals = (X * AdG + AS) / (1 + X)
// dove X è un valore che dovrebbe essere parametrizzabile da una interfaccia.
// Il valore iniziale lo fissiamo a X = 3
// (AT)
switch ($bettype) {
case 'goals':
// Aspettativa di Gioco
// (AdG)
$asp_gioco = $val->goals / $somma_minuti * 90;
$tmp['asp_gioco_goals'] = $asp_gioco;
$tmp['asp_teorica_goals'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
case 'cards':
$asp_gioco = $val->cards / $somma_minuti * 90;
$tmp['asp_gioco_cards'] = $asp_gioco;
$tmp['asp_teorica_cards'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
case 'fouls':
$asp_gioco = $val->fouls / $somma_minuti * 90;
$tmp['asp_gioco_fouls'] = $asp_gioco;
$tmp['asp_teorica_fouls'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
case 'offsides':
$asp_gioco = $val->offsides / $somma_minuti * 90;
$tmp['asp_gioco_offsides'] = $asp_gioco;
$tmp['asp_teorica_offsides'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
case 'total_shots':
$asp_gioco = $val->total_shots / $somma_minuti * 90;
$tmp['asp_gioco_total_shots'] = $asp_gioco;
$tmp['asp_teorica_total_shots'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
case 'shots_on_target':
$asp_gioco = $val->shots_on_target / $somma_minuti * 90;
$tmp['asp_gioco_shots_on_target'] = $asp_gioco;
$tmp['asp_teorica_shots_on_target'] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
break;
}
switch ($bettype) {
case 'goals':
if ($val->total_min < $this->y_value || $val->goals == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->goals / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
case 'cards':
if ($val->total_min < $this->y_value || $val->cards == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->cards / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
case 'fouls':
if ($val->total_min < $this->y_value || $val->fouls == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->fouls / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
case 'offsides':
if ($val->total_min < $this->y_value || $val->offsides == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->offsides / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
case 'total_shots':
if ($val->total_min < $this->y_value || $val->total_shots == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->total_shots / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
case 'shots_on_target':
if ($val->total_min < $this->y_value || $val->shots_on_target == 0) {
$tmp['asp_teorica_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_statistica) / (1 + $this->x_value);
} else {
$asp_gioco = $val->shots_on_target / $val->total_min * 90;
$tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
break;
}
}
// Calcolare la Somma di tutte le AT (colonna G della Tabella)
// Considerare la ATR calcolata allo Step 1 (colonna I della Tabella)
// Aspettativa per Player: AP = AT * ATR / TOT AT