public function getHskRatioAttribute() { return BattlefieldHelper::hsk($this->Headshots, $this->Kills); }
/** * Assigns the player with their DB profile * * @param array $dbPlayers * @param string $type * * @return $this */ private function playerDBLoop($dbPlayers = [], $type = 'players') { foreach ($this->data['teams'] as $teamID => $team) { if (array_key_exists($type, $team)) { foreach ($team[$type] as $index => $player) { if (is_array($player) && array_key_exists('kills', $player) && array_key_exists('deaths', $player)) { $this->data['teams'][$teamID][$type][$index]['kd'] = BattlefieldHelper::kd($player['kills'], $player['deaths']); } foreach ($dbPlayers as $index2 => $player2) { $guid = !is_string($player) ? $player['guid'] : $player; if ($guid == $player2->EAGUID) { if ($type == 'commander') { $index = 0; } if (is_array($player) && array_key_exists('guid', $player)) { $updated = false; // If player rank doesn't match the database update it if ($player2->GlobalRank != $player['rank']) { if ($player['rank'] > 0) { $player2->GlobalRank = $player['rank']; $updated = true; } } // If player name doesn't match the database update it if ($player2->SoldierName != $player['name']) { $player2->SoldierName = $player['name']; $updated = true; } // If player name or rank are changed save changes to database if ($updated) { $player2->save(); } } $this->data['teams'][$teamID][$type][$index]['_player'] = $player2; break; } } } } } return $this; }
/** * Gets the human readable name of the current mode * * @return string */ public function getCurrentGamemodeAttribute() { return BattlefieldHelper::playmodeName($this->Gamemode, $this->modes_file_path); }