add 2 parts for claculation pp wip

This commit is contained in:
salam committed 2026-10-31 19:22:16 +01:00
1 parent 6d2f4c1052
commit ad45880506
19 files changed
+1403 -1049

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Traits\PlayerProps;
trait LineUps
{
public function prepareLineUp()
{
$arr = [
'team_id' => $this->team_id,
'season_or_date' => $this->season_or_date,
'season_mode' => $this->season_mode,
];
$players = $this->loadPlayerAll();
$arr = collect();
foreach ($players as $value) {
if ($value['position'] != '') {
$arr->push([
'id' => $value['ss_player_id'],
'min' => $value['average_min'],
'pos' => $value['position'],
'name' => $value['player_name'],
]);
}
}
return $arr;
}
public function generateLineUp(): void
{
if ($this->activeLineUp && $this->team_id) {
$players = $this->prepareLineUp();
$places = $this->getLineUpMap($this->activeLineUp);
$lineup = [];
$id_used = [];
foreach ($places as $place) {
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
}
for ($i = 1; $i <= 35; $i++) {
$this->boxes[$i] = [];
}
$this->clearResultTable();
$this->player_on_field_counter = 0;
foreach ($this->players as $k => $record) {
$id = $record['id'];
if (isset($lineup[$id])) {
$this->boxes[$lineup[$id]['place']] = $record;
$this->players[$k]['active'] = 1;
$this->players[$k]['pos'] = $lineup[$id]['position'];
$this->player_on_field_counter++;
} else {
$this->players[$k]['active'] = 0;
$this->players[$k]['pos'] = '';
}
}
$this->calculateAspg();
$this->storePlacement();
}
}
public function updateLineup(?string $state)
{
$this->clearResultTable();
if (isset($this->lineupsMap[$state])) {
$this->lineup = $this->lineUpMap[$state];
} else {
$this->lineup = [];
}
}
}