wip
This commit is contained in:
1 parent
49e883e49e
commit
41d91a7124
5 files changed
+231
-127
No files matched your search
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\PlayerProps\BoxNames;
|
||||
use App\Filament\Widgets\PlayerProps\Expectations;
|
||||
use App\Filament\Widgets\PlayerProps\LineUpMap;
|
||||
use App\Livewire\PlayerCalculator;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\SofaScorePlayerPosition;
|
||||
@@ -12,7 +15,6 @@ use App\Models\StatistikoEvent;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class PlayerPropsDrop extends Widget
|
||||
@@ -49,9 +51,9 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->activeBoxes = $this->boxNames();
|
||||
$this->activeBoxes = BoxNames::load();
|
||||
|
||||
$this->lineUpMap = $this->lineUpMap();
|
||||
$this->lineUpMap = LineUpMap::load();
|
||||
|
||||
$this->player_on_field_counter = 0;
|
||||
|
||||
@@ -343,10 +345,13 @@ class PlayerPropsDrop extends Widget
|
||||
$team_id = $this->team_id;
|
||||
$res = StatisticFixtures::where('id', $this->match_id)->first();
|
||||
$asp_team = 0;
|
||||
$team_home_away = 'home';
|
||||
if ((int) $res->home_id == (int) $team_id) {
|
||||
$asp_team = (float) $res->exp_home;
|
||||
$team_home_away = 'home';
|
||||
} elseif ((int) $res->away_id == (int) $team_id) {
|
||||
$asp_team = (float) $res->exp_away;
|
||||
$team_home_away = 'away';
|
||||
}
|
||||
|
||||
$player_totals = SofaScorePlayerPerSeason::with('details')->where('total_min', '>', 0)->where('season', 'total')->where('ss_team_id', $team_id)->get();
|
||||
@@ -358,34 +363,6 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
$asp_team_others = $this->loadOthers($count_player, $team_id);
|
||||
|
||||
// Aspettativa Team di Riferimento
|
||||
// (ATR) = Aspettativa Team * Numero di Giocatori di Team in Rosters (esclusi i portieri) / 10.
|
||||
// Ad esempio per Remo (supponiamo 24 giocatori nel Roster esclusi i portieri): ATR = 1.2 * 24 / 10 = 2.88
|
||||
|
||||
$asp_team_riferimento = (float) $asp_team * $count_player / 10;
|
||||
|
||||
/***
|
||||
"id" => 35067
|
||||
"ss_player_id" => 233856
|
||||
"ss_team_id" => 3212
|
||||
"season" => "total"
|
||||
"total_events" => 12
|
||||
"total_min" => 667
|
||||
"average_min" => 56
|
||||
"events_played_home" => 7
|
||||
"events_played_away" => 0
|
||||
"minutes_played_home" => 398
|
||||
"minutes_played_away" => 274
|
||||
"goals" => 0
|
||||
"fouls" => 5
|
||||
"cards" => 2
|
||||
"offsides" => 0
|
||||
"shots_on_target" => 1
|
||||
"shots_off_target" => 0
|
||||
*/
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($player_totals as $val) {
|
||||
@@ -400,7 +377,6 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
$tmp['id_team'] = $team_id;
|
||||
$tmp['asp_team'] = $asp_team;
|
||||
$tmp['asp_team_riferimento'] = $asp_team_riferimento;
|
||||
$tmp['player_count_without_gk'] = $count_player;
|
||||
|
||||
$position_field = $this->get_position($ss_player_id);
|
||||
@@ -511,14 +487,13 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
// Log::debug('results', $results);
|
||||
// dd($asp_team_others);
|
||||
// "asp_team_riferimento_goals" => 4.4
|
||||
// "asp_team_riferimento_fouls" => 42.2
|
||||
// "asp_team_riferimento_offside" => 2.0
|
||||
// "asp_team_riferimento_card" => 8.8
|
||||
// "asp_team_riferimento_snt" => 15.4
|
||||
// "asp_team_riferimento_tsh" => 42.6
|
||||
$asp_team_all = Expectations::load($team_id);
|
||||
|
||||
// Aspettativa Team di Riferimento
|
||||
// (ATR) = Aspettativa Team * Numero di Giocatori di Team in Rosters (esclusi i portieri) / 10.
|
||||
// Ad esempio per Remo (supponiamo 24 giocatori nel Roster esclusi i portieri): ATR = 1.2 * 24 / 10 = 2.88
|
||||
|
||||
$asp_team_riferimento = (float) $asp_team * $count_player / 10;
|
||||
|
||||
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
|
||||
foreach ($bettypes as $bettype) {
|
||||
@@ -535,29 +510,34 @@ class PlayerPropsDrop extends Widget
|
||||
$results[$key]['asp_riferimento_goals'] = $asp_team_riferimento;
|
||||
break;
|
||||
case 'cards':
|
||||
$asp_referimento = $asp_team_all['crd'][$team_home_away];
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_others['asp_team_riferimento_card'] / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_card'] = $asp_team_others['asp_team_riferimento_card'];
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_referimento / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_card'] = $asp_referimento;
|
||||
break;
|
||||
case 'fouls':
|
||||
$asp_referimento = $asp_team_all['fls'][$team_home_away];
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_others['asp_team_riferimento_fouls'] / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_fouls'] = $asp_team_others['asp_team_riferimento_fouls'];
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_referimento / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_fouls'] = $asp_referimento;
|
||||
break;
|
||||
case 'offsides':
|
||||
$asp_referimento = $asp_team_all['ofs'][$team_home_away];
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_others['asp_team_riferimento_offside'] / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_offside'] = $asp_team_others['asp_team_riferimento_offside'];
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_referimento / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_offside'] = $asp_referimento;
|
||||
break;
|
||||
case 'total_shots':
|
||||
$asp_referimento = $asp_team_all['tsh'][$team_home_away];
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_others['asp_team_riferimento_tsh'] / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_tsh'] = $asp_team_others['asp_team_riferimento_tsh'];
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_referimento / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_tsh'] = $asp_referimento;
|
||||
break;
|
||||
case 'shots_on_target':
|
||||
$asp_referimento = $asp_team_all['snt'][$team_home_away];
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_others['asp_team_riferimento_snt'] / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_snt'] = $asp_team_others['asp_team_riferimento_snt'];
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_referimento / $total_bettype;
|
||||
$results[$key]['asp_team_riferimento_snt'] = $asp_referimento;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,9 +589,10 @@ class PlayerPropsDrop extends Widget
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
})->get();
|
||||
|
||||
$count_events = \count($res);
|
||||
$count_events = 0;
|
||||
|
||||
foreach ($res as $value) {
|
||||
$count_events++;
|
||||
if ($value->home_id == $team_id) {
|
||||
$arr['goals'] += $value->gls_h;
|
||||
$arr['fouls'] += $value->fls_h;
|
||||
@@ -619,7 +600,8 @@ class PlayerPropsDrop extends Widget
|
||||
$arr['card'] += $value->crd_h;
|
||||
$arr['snt'] += $value->snt_h;
|
||||
$arr['tsh'] += $value->tsh_h;
|
||||
} elseif ($value->away_id == $team_id) {
|
||||
}
|
||||
if ($value->away_id == $team_id) {
|
||||
$arr['goals'] += $value->gls_a;
|
||||
$arr['fouls'] += $value->fls_a;
|
||||
$arr['offside'] += $value->ofs_a;
|
||||
@@ -629,70 +611,15 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
$aspettativa = round($arr['fouls'] / $count_events, 1);
|
||||
|
||||
dd($arr['fouls'], $aspettativa, $count_events);
|
||||
|
||||
foreach ($arr as $name => $value) {
|
||||
$arr['asp_team_riferimento_'.$name] = (float) round($value / $count_events * $count_player / 10, 1);
|
||||
$arr['asp_team_riferimento_'.$name] = (float) round($value / $count_events, 1) * $count_player / 10;
|
||||
}
|
||||
dd($arr);
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
private function boxNames(): array
|
||||
{
|
||||
return [2 => 'DR', 4 => 'MR', 6 => 'LW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'RW'];
|
||||
}
|
||||
|
||||
private function lineUpMap(): array
|
||||
{
|
||||
return [
|
||||
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
|
||||
'3331' => [9, 16, 23, 17, 11, 25, 12, 19, 26, 21],
|
||||
'3331-' => [9, 16, 23, 10, 18, 24, 12, 19, 26, 21],
|
||||
'3331+' => [9, 16, 23, 11, 18, 25, 12, 19, 26, 21],
|
||||
'3412-' => [9, 16, 23, 4, 10, 24, 32, 19, 20, 21],
|
||||
'3412+' => [9, 16, 23, 4, 11, 25, 32, 19, 20, 21],
|
||||
'3421-' => [9, 16, 23, 4, 10, 24, 32, 12, 26, 21],
|
||||
'3421+' => [9, 16, 23, 4, 11, 25, 32, 12, 26, 21],
|
||||
'343-' => [9, 16, 23, 4, 10, 24, 32, 6, 34, 21],
|
||||
'343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21],
|
||||
'3511' => [9, 16, 23, 4, 11, 17, 25, 32, 19, 21],
|
||||
'3511-' => [9, 16, 23, 4, 10, 18, 24, 32, 19, 21],
|
||||
'3511+' => [9, 16, 23, 4, 11, 18, 25, 32, 19, 21],
|
||||
'352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21],
|
||||
'352-' => [9, 16, 23, 4, 10, 18, 24, 32, 20, 21],
|
||||
'352+' => [9, 16, 23, 4, 11, 18, 25, 32, 20, 21],
|
||||
'4132' => [2, 9, 23, 30, 17, 12, 19, 26, 20, 21],
|
||||
'4213-' => [2, 9, 23, 30, 10, 24, 19, 6, 34, 21],
|
||||
'4213+' => [2, 9, 23, 30, 11, 25, 19, 6, 34, 21],
|
||||
'4222' => [2, 9, 23, 30, 10, 24, 12, 26, 20, 21],
|
||||
'4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21],
|
||||
'424' => [2, 9, 23, 30, 10, 24, 6, 34, 20, 21],
|
||||
'4312' => [2, 9, 23, 30, 17, 11, 25, 19, 20, 21],
|
||||
'4312-' => [2, 9, 23, 30, 10, 18, 24, 19, 20, 21],
|
||||
'4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21],
|
||||
'4321' => [2, 9, 23, 30, 17, 11, 25, 12, 26, 21],
|
||||
'4321-' => [2, 9, 23, 30, 10, 18, 24, 12, 26, 21],
|
||||
'4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21],
|
||||
'433' => [2, 9, 23, 30, 17, 11, 25, 6, 34, 21],
|
||||
'433-' => [2, 9, 23, 30, 10, 18, 24, 6, 34, 21],
|
||||
'433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21],
|
||||
'4411-' => [2, 9, 23, 30, 4, 10, 24, 32, 19, 21],
|
||||
'4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21],
|
||||
'442' => [2, 9, 23, 30, 4, 17, 18, 32, 20, 21],
|
||||
'442-' => [2, 9, 23, 30, 4, 10, 24, 32, 20, 21],
|
||||
'442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21],
|
||||
'451' => [2, 9, 23, 30, 4, 17, 11, 25, 32, 21],
|
||||
'451-' => [2, 9, 23, 30, 4, 10, 18, 24, 32, 21],
|
||||
'451+' => [2, 9, 23, 30, 4, 11, 18, 25, 32, 21],
|
||||
'523-' => [2, 9, 16, 23, 30, 10, 24, 6, 34, 21],
|
||||
'523+' => [2, 9, 16, 23, 30, 11, 25, 6, 34, 21],
|
||||
'5311' => [2, 9, 16, 23, 30, 17, 11, 25, 19, 21],
|
||||
'5311-' => [2, 9, 16, 23, 30, 10, 18, 24, 19, 21],
|
||||
'5311+' => [2, 9, 16, 23, 30, 11, 18, 25, 19, 21],
|
||||
'532' => [2, 9, 16, 23, 30, 17, 11, 25, 20, 21],
|
||||
'532-' => [2, 9, 16, 23, 30, 10, 18, 24, 20, 21],
|
||||
'532+' => [2, 9, 16, 23, 30, 11, 18, 25, 20, 21],
|
||||
'541-' => [2, 9, 16, 23, 30, 4, 10, 24, 32, 21],
|
||||
'541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user