add 2 parts for claculation pp wip
This commit is contained in:
1 parent
6d2f4c1052
commit
ad45880506
19 files changed
+1403
-1049
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
trait BestLineUp
|
||||
{
|
||||
public function majorFormations(): array
|
||||
{
|
||||
// 343+
|
||||
// 352
|
||||
// 433+
|
||||
// 442+
|
||||
// 4231
|
||||
// 4321+
|
||||
// 4312+
|
||||
// 4411+
|
||||
return [
|
||||
'343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21],
|
||||
'352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21],
|
||||
'433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21],
|
||||
'442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21],
|
||||
'4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21],
|
||||
'4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21],
|
||||
'4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21],
|
||||
'4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21],
|
||||
];
|
||||
}
|
||||
|
||||
public function generateBestLineUp(): void
|
||||
{
|
||||
if (! $this->team_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_lineups = [];
|
||||
|
||||
$players = $this->prepareLineUp();
|
||||
|
||||
$major_formations = self::majorFormations();
|
||||
|
||||
foreach ($major_formations as $formation_name => $formation_positions) {
|
||||
|
||||
$lineup = [];
|
||||
|
||||
$id_used = [];
|
||||
|
||||
foreach ($formation_positions as $place) {
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
$all_lineups[$formation_name] = $lineup;
|
||||
}
|
||||
|
||||
$tmp = [];
|
||||
foreach ($all_lineups as $formation_name => $lineup) {
|
||||
$tmp[$formation_name] = array_sum(array_column($lineup, 'min'));
|
||||
}
|
||||
$formation_name = array_search(max($tmp), $tmp);
|
||||
|
||||
// dd($all_lineups, $tmp, $formation_name);
|
||||
|
||||
$this->dispatch('update-lineup', $formation_name);
|
||||
|
||||
$this->lineUpUpdate($formation_name);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user