activeBoxes = BoxNames::load(); $this->season_or_date = 'season'; $this->lineUpMap = $this->loadLineUpMaps(); $this->player_on_field_counter = 0; for ($i = 1; $i <= 35; $i++) { $this->boxes[$i] = []; if (isset($this->activeBoxes[$i])) { $this->beschriftung[$i] = $this->activeBoxes[$i]; } else { $this->beschriftung[$i] = ''; } } $this->lineup = $this->lineUpMap[$this->activeLineUp]; } #[On('clear-all')] public function clearAll() { $this->team_name = ''; $this->match_id = 0; $this->team_id = 0; for ($i = 1; $i <= 35; $i++) { $this->boxes[$i] = []; } $this->players = []; $this->dispatch('update-players', players: $this->players); } #[On('match-update')] public function matchUpdate(?int $match_id) { $this->team_name = ''; $this->match_id = 0; $this->players = []; for ($i = 1; $i <= 35; $i++) { $this->boxes[$i] = []; } if ($match_id) { $this->match_id = $match_id; } $this->dispatch('update-players', players: $this->players); } #[On('team-update')] public function teamUpdate(int $team_id) { $this->team_id = $team_id; $this->syncData($team_id); } #[On('part_1_value-update')] public function setPart1Value(int $part_1_value) { $this->part_1_value = $part_1_value; if ($this->player_on_field_counter >= 10) { $this->calculateAspg(); } } #[On('liga_id-update')] public function ligaUpdate(int $liga_id) { $this->liga_id = $liga_id; } #[On('lineup-update')] public function lineUpUpdate(int|string $activeLineUp) { $this->activeLineUp = $activeLineUp; $this->lineup = $this->lineUpMap[$activeLineUp]; $this->generateLineUp(); $this->calculateAspg(); } #[On('element-dropped-in-box')] public function handleElementDropped(mixed $elementData, mixed $boxNumber): void { $boxNumber = (int) $boxNumber; $player = is_array($elementData) ? $elementData : json_decode($elementData, true); if (! $player || ! isset($player['id'])) { return; } // when drag from field to field remove from prviouse field to prevent doubles foreach ($this->boxes as $k => $record) { if (count($record) && $record['id'] == (int) $player['id']) { $this->clearBox($k); } } // when drag from source remove from proviuse field foreach ($this->players as $k => $record) { if ($record['id'] == (int) $player['id']) { if ($this->boxes[$boxNumber]) { $this->clearBox($boxNumber); } $this->boxes[$boxNumber] = $record; $this->players[$k]['active'] = 1; $this->players[$k]['pos'] = $this->activeBoxes[$boxNumber]; $this->player_on_field_counter++; } } $this->storePlacement(); if ($this->player_on_field_counter >= 10) { $this->calculateAspg(); } else { $this->dispatch('update-players', players: $this->players); } } #[On('season_or_date-update')] public function setSeasonOrData(string $season_or_date) { $this->season_or_date = $season_or_date; if ($this->player_on_field_counter >= 10) { $this->calculateAspg(); } } #[On('season_mode-update')] public function setSeason(string $season_mode) { $this->season_mode = $season_mode; } #[On('season_selected-update')] public function setSeasonSelected(array $season_selected) { $this->season_selected = $season_selected; if ($this->player_on_field_counter >= 10) { $this->calculateAspg(); } } #[On('date_spliter-update')] public function setDateSpliter(string $date_spliter) { $this->date_spliter = $date_spliter; if ($this->player_on_field_counter >= 10) { $this->calculateAspg(); } } public function get_position(int $ss_player_id) { // see if player is in field and if yes get new position foreach ($this->players as $record) { if ($record['id'] == $ss_player_id) { return $record['pos']; } } return false; } }