wip calculator

This commit is contained in:
salam committed 2026-09-05 16:15:18 +02:00
1 parent 3d3748c353
commit 217636b564
14 files changed
+146 -230

No files matched your search

+24 -23
View File
@@ -2,35 +2,29 @@
namespace App\Livewire;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
class BoardDispatcher extends Component
{
public array $lists = [];
public array $destLabels = ['DR', 'MR', 'RW', 'DC', 'DM', 'MC', 'AM', 'SW', 'DC', 'DM', 'MC', 'AM', 'SM', 'ST', 'DC', 'DM', 'MC', 'AM', 'DL', 'ML', 'LM'];
public string $boardVersion = '';
public function mount()
public function mount(array $filters)
{
$this->boardVersion = uniqid();
$this->lists['source-1'] = [
['id' => '1', 'name' => 'Source Item A', 'origin' => 'source-1'],
['id' => '2', 'name' => 'Source Item B', 'origin' => 'source-1'],
];
$this->lists['source-2'] = [
['id' => '3', 'name' => 'Source Item C', 'origin' => 'source-2'],
];
$this->lists['source-3'] = [
['id' => '4', 'name' => 'Source Item D', 'origin' => 'source-3'],
['id' => '5', 'name' => 'Source Item E', 'origin' => 'source-3'],
];
$this->lists['source-4'] = [
['id' => '6', 'name' => 'Source Item F', 'origin' => 'source-4'],
];
$this->lists = PlayerCalculator::load($filters);
for ($i = 1; $i <= 21; $i++) {
$this->lists["dest-{$i}"] = [];
$active = [2, 4, 6, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 30, 32, 34];
for ($i = 1; $i <= 35; $i++) {
if (in_array($i, $active))
$this->lists["dest-{$i}"] = [];
else
$this->lists["blind-{$i}"] = [];
}
}
@@ -74,6 +68,10 @@ class BoardDispatcher extends Component
{
$itemId = (string) $itemId;
// Log::info($this->boardVersion);
// Log::info('itemId, currentListId', [$itemId, $currentListId]);
// Log::info('OLD LIST', $this->lists);
if (! isset($this->lists[$currentListId])) {
$this->boardVersion = uniqid();
@@ -93,12 +91,15 @@ class BoardDispatcher extends Component
if ($foundItem && isset($this->lists[$foundItem['origin']])) {
// Nur zurücklegen, wenn die Quelle wirklich frei ist
if (count($this->lists[$foundItem['origin']]) < 1) {
array_unshift($this->lists[$foundItem['origin']], $foundItem);
} else {
// Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben
array_unshift($this->lists[$currentListId], $foundItem);
}
array_unshift($this->lists[$foundItem['origin']], $foundItem);
// if (count($this->lists[$foundItem['origin']]) < 2) {
// Log::info('origin');
// array_unshift($this->lists[$foundItem['origin']], $foundItem);
// } else {
// // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben
// array_unshift($this->lists[$currentListId], $foundItem);
// Log::info('box');
// }
}
$this->boardVersion = uniqid();
+1 -1
View File
@@ -6,7 +6,7 @@ class LoadGridPositions
{
public static function load()
{
$arr = [];
$arr = ['DR', 'MR', 'RW', 'DC', 'DM', 'MC', 'AM', 'SW', 'DC', 'DM', 'MC', 'AM', 'SM', 'ST', 'DC', 'DM', 'MC', 'AM', 'DL', 'ML', 'LM'];
$arr[] = 0;
$arr[] = 0;
+21 -23
View File
@@ -88,45 +88,43 @@ class PlayerCalculator extends Component
$colorlevel = round($matches->count() / 3);
if (in_array($val['player_position'], $positions_map['MIDFIELD'])) {
$position = 'MIDFIELD';
$position_color = 'info';
$origin = 'source-midfield';
$pcolor = 'info';
} elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) {
$position = 'DEFENCE';
$position_color = 'success';
$origin = 'source-defence';
$pcolor = 'success';
} elseif (in_array($val['player_position'], $positions_map['ATTACK'])) {
$position = 'ATTACK';
$position_color = 'warning';
$origin = 'source-attack';
$pcolor = 'warning';
} elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
$position = 'GOALKEEPER';
$position_color = 'gray';
$origin = 'source-goalkeeper';
$pcolor = 'gray';
} else {
$position = 'NO SPECIFIC POSITION';
$position_color = '';
$origin = 'NO SPECIFIC POSITION';
$pcolor = '';
}
$name = $val['player_name'];
$preferred_foot = $val['preferred_foot'] ?? '-';
$everage_minutes = round($minues_played / $events_played).' min';
$everage_minutes = round($minues_played / $events_played) . ' min';
if ($colorlevel > 1 && $events_played < $colorlevel) {
$color = 'danger';
$ecolor = 'danger';
} elseif ($events_played < $colorlevel * 2) {
$color = 'info';
$ecolor = 'info';
} else {
$color = 'success';
$ecolor = 'success';
}
$result[] = [
'player_id' => $player_id,
'player_name' => $name,
'position' => $position,
'type_color' => $position_color,
'event_color' => $color,
'info' => 'Ev '.$events_played.', '.$preferred_foot.', '.$everage_minutes,
$result[$origin][] = [
'id' => $player_id,
'name' => $name,
'origin' => $origin,
'pcolor' => $pcolor,
'ecolor' => $ecolor,
'info' => 'Ev ' . $events_played . ', ' . $preferred_foot . ', ' . $everage_minutes,
];
}
// dd($result);
return $result;
}
}