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,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Filament\Widgets\PlayerProps\PositionHirarchie;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait PlayerForPosition
|
||||
{
|
||||
public function getPlayerForPosition(array &$lineup, array &$id_used, int $place, Collection $players)
|
||||
{
|
||||
$log = 0;
|
||||
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$hirarchy = PositionHirarchie::load();
|
||||
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
|
||||
if ($log) {
|
||||
Log::debug("A $place - $position", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
} else {
|
||||
if (isset($hirarchy[$position])) {
|
||||
$position2 = $hirarchy[$position][0];
|
||||
$fitered = $players->where('pos', $position2)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
if ($log) {
|
||||
Log::debug("B $place - $position $position2", $fitered);
|
||||
}
|
||||
|
||||
} elseif (isset($hirarchy[$position][1])) {
|
||||
$position3 = $hirarchy[$position][1];
|
||||
$fitered = $players->where('pos', $position3)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
if ($log) {
|
||||
Log::debug("C $place - $position $position2 $position3", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
} elseif (isset($hirarchy[$position][2])) {
|
||||
$position4 = $hirarchy[$position][2];
|
||||
$fitered = $players->where('pos', $position4)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
if ($log) {
|
||||
Log::debug("D $place - $position $position2 $position3 $position4", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user