calc copy wip

This commit is contained in:
salam committed 2026-09-10 09:18:58 +02:00
1 parent 84e591ba06
commit 0d6181b393
2 files changed
+39 -23

No files matched your search

+38 -22
View File
@@ -190,8 +190,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->beschriftung[$i] = '';
}
}
// Log::debug('beschriftung', $this->beschriftung);
}
public function updateXvalue()
@@ -254,13 +252,13 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->modalWidth(Width::ExtraLarge)
->modalSubmitAction(false)
->modalCancelAction(false)
->modalContent(fn () => view('filament.modals.position-abbreviation')),
->modalContent(fn() => view('filament.modals.position-abbreviation')),
Action::make('reset')
->hiddenLabel()
->size(Size::Small)
->tooltip('Remove all players from field')
->icon('phosphor-arrows-clockwise')
->action(fn () => $this->clearAll()),
->action(fn() => $this->clearAll()),
// Action::make('calculate')
// ->hiddenLabel()
// ->tooltip('Calculate expected values')
@@ -274,7 +272,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->size(Size::Small)
->icon('phosphor-copy')
->disabled($this->copyDisabled)
->action(fn () => $this->copyResult()),
->action(fn() => $this->copyResult()),
])
/**
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
@@ -287,7 +285,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->columns([
ViewColumn::make('drag_card')
->columnSpanFull()
->label(fn () => $this->getHeadingTable())
->label(fn() => $this->getHeadingTable())
->view('filament.tables.columns.drag-card'),
])
->filters([
@@ -303,7 +301,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
'midfield' => '<span class="text-blue-500">Midfield</span>',
'defence' => '<span class="text-green-500">Defence</span>',
'goalkeeper' => '<span class="text-gray-500">Goalkeeper</span>',
])->modifyFormFieldUsing(fn (Select $component) => $component->allowHtml())
])->modifyFormFieldUsing(fn(Select $component) => $component->allowHtml())
->query(function ($query) {
return $query;
})->indicateUsing(function (array $data): array {
@@ -423,14 +421,32 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
public function copyResult()
{
$copystring = '';
foreach ($this->results as $row) {
dd($row);
unset($row['origin']);
unset($row['pcolor']);
unset($row['ecolor']);
unset($row['info']);
$copystring .= implode("\t", $row)."\n";
// "id" => 787607
// "name" => "Keno"
// "preferred_foot" => "Right"
// "player_position" => "LW"
// "position_area" => "attack"
// "player_color" => "warning"
// "timed_color" => "danger"
// "events_played" => 7
// "everage_minutes" => 11
// "position" => "DC"
// "active" => 1
// "gls" => 0
// "fls" => 0
// "ofs" => 0
// "snt" => 0
// "tsh" => 0
// "crd" => 0
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd'];
$copystring = implode("\t", $header) . "\n";;
foreach ($this->sourceRecords as $row) {
unset($row['id']);
unset($row['player_position']);
unset($row['position_area']);
unset($row['player_color']);
unset($row['timed_color']);
$copystring .= implode("\t", $row) . "\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
}
@@ -525,18 +541,18 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$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;
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype);
$tmp['asp_statistica_' . $bettype] = $asp_statistica;
if ($somma_minuti < $this->y_value) {
// Se la SMG è < Y per quel Player prenderemo in considerazione solo l'Aspettativa Statistica (AS).
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
$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)
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
$tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
}
}
@@ -550,11 +566,11 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) {
$total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype));
$total_bettype = array_sum(array_column($results, 'asp_teorica_' . $bettype));
foreach ($results as $key => $value) {
// Aspettativa per Player: AP = AT * ATR / TOT AT
$results[$key]['asp_total_'.$bettype] = $total_bettype;
$results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype;
$results[$key]['asp_total_' . $bettype] = $total_bettype;
$results[$key]['asp_player_' . $bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_' . $bettype]) / $total_bettype;
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
"laravel/framework": "*",
"laravel/tinker": "*",
"mongodb/laravel-mongodb": "^5.1",
"mongodb/mongodb": "^2.2",
"mongodb/mongodb": "^2.4",
"neitanod/forceutf8": "^2.0",
"outhebox/blade-flags": "*",
"phpoffice/phpspreadsheet": "^5.9",