public function linkPlayerTimePlayed() { $playerTotal = $this->wrappedObject->PlayerTotal(); if ($playerTotal == null || empty($playerTotal) || $playerTotal == "") { return "<i class='small'>Unknown</i>"; } return "<b>" . \App\Server\Utils::getHMbyS($playerTotal->total_time_played, "%dh %dm") . "</b>"; }
public function loadoutBody() { return \App\Server\Utils::getEquipmentTitleById($this->wrappedObject->loadout->body); }
/** * Translate from one langage to other via google translate api * @param Request $request */ public function translateText(Request $request) { \Log::info(\Input::all()); if (env('TRANSLATE_KEY') != $request->key) { print "KnightofSorrow.tk: Invalid Usage Key"; exit; } $from_lang = $request->from_lang; if ($from_lang == "detect") { $from_lang = null; } $to_lang = $request->to_lang; $text = $request->text; $player = $request->player; try { $translator = new Translator(env('YANDEX_API_KEY')); $translation = $translator->translate($text, 'en'); $translated_text = $translation; $language = $translation->getSourceLanguage(); } catch (Exception $e) { $language = "Unknown"; $translated_text = $text; } if ($language == false || $language == null || $language == "") { $language = "Unknown"; } else { $language = Utils::languageByCode1($language); } printf("[c=00ff00][b]%s[\\b][c=ffff00] (in %s)[c=00ff00]: %s[\\c]", $player, $language, $translated_text); exit; }
public function time($format = "%dm %ds") { return \App\Server\Utils::getMSbyS($this->wrappedObject->round_time, $format); }
/** * Returns a Collection for all weapons.. * * @return \Illuminate\Support\Collection */ public function AllWeapons() { $weapons_data = $this->alias->weapons->sortBy('name')->groupBy('name'); $weaponTotal = new \Illuminate\Support\Collection(); $weaponTotal->primary = new \Illuminate\Support\Collection(); $weaponTotal->secondary = new \Illuminate\Support\Collection(); $weaponTotal->tactical = new \Illuminate\Support\Collection(); $weaponTotal->others = new \Illuminate\Support\Collection(); foreach ($weapons_data as $key => $weapons) { if (in_array($key, [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12])) { $weaponTotal->primary->{$key} = new \Illuminate\Support\Arr(); $weaponTotal->primary->push($weaponTotal->primary->{$key}); $weaponTotal->primary->{$key}->family = "Primary"; $weaponTotal->primary->{$key}->name = Server\Utils::getEquipmentTitleById($key); $weaponTotal->primary->{$key}->id = $key; $weaponTotal->primary->{$key}->shots_fired = $weapons->sum('shots_fired'); $weaponTotal->primary->{$key}->shots_hit = $weapons->sum('shots_hit'); $weaponTotal->primary->{$key}->kills = $weapons->sum('kills'); $weaponTotal->primary->{$key}->accuracy = $weaponTotal->primary->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->primary->{$key}->shots_hit / $weaponTotal->primary->{$key}->shots_fired * 100, 2); $weaponTotal->primary->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->primary->{$key}->kills / $weapons->sum('seconds_used') * 60, 2); $weaponTotal->primary->{$key}->distance = $weapons->max('distance'); $weaponTotal->primary->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm"); } elseif (in_array($key, [13, 14, 15, 16, 17])) { $weaponTotal->secondary->{$key} = new \Illuminate\Support\Arr(); $weaponTotal->secondary->push($weaponTotal->secondary->{$key}); $weaponTotal->secondary->{$key}->family = "Secondary"; $weaponTotal->secondary->{$key}->name = Server\Utils::getEquipmentTitleById($key); $weaponTotal->secondary->{$key}->id = $key; $weaponTotal->secondary->{$key}->shots_fired = $weapons->sum('shots_fired'); $weaponTotal->secondary->{$key}->shots_hit = $weapons->sum('shots_hit'); $weaponTotal->secondary->{$key}->kills = $weapons->sum('kills'); $weaponTotal->secondary->{$key}->accuracy = $weaponTotal->secondary->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->secondary->{$key}->shots_hit / $weaponTotal->secondary->{$key}->shots_fired * 100, 2); $weaponTotal->secondary->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->secondary->{$key}->kills / $weapons->sum('seconds_used') * 60, 2); $weaponTotal->secondary->{$key}->distance = $weapons->max('distance'); $weaponTotal->secondary->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm"); } elseif (in_array($key, [18, 23, 24, 45, 25, 26])) { $weaponTotal->tactical->{$key} = new \Illuminate\Support\Arr(); $weaponTotal->tactical->push($weaponTotal->tactical->{$key}); $weaponTotal->tactical->{$key}->family = "Tactical"; $weaponTotal->tactical->{$key}->name = Server\Utils::getEquipmentTitleById($key); $weaponTotal->tactical->{$key}->id = $key; $weaponTotal->tactical->{$key}->shots_fired = $weapons->sum('shots_fired'); $weaponTotal->tactical->{$key}->shots_hit = $weapons->sum('shots_hit'); $weaponTotal->tactical->{$key}->kills = $weapons->sum('kills'); $weaponTotal->tactical->{$key}->accuracy = $weaponTotal->tactical->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->tactical->{$key}->shots_hit / $weaponTotal->tactical->{$key}->shots_fired * 100, 2); $weaponTotal->tactical->{$key}->stuns_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->tactical->{$key}->shots_fired / $weapons->sum('seconds_used') * 60, 2); $weaponTotal->tactical->{$key}->distance = $weapons->max('distance'); $weaponTotal->tactical->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm"); } else { $weaponTotal->others->{$key} = new \Illuminate\Support\Arr(); $weaponTotal->others->push($weaponTotal->others->{$key}); $weaponTotal->others->{$key}->family = "Others"; $weaponTotal->others->{$key}->name = Server\Utils::getEquipmentTitleById($key); $weaponTotal->others->{$key}->id = $key; $weaponTotal->others->{$key}->shots_fired = $weapons->sum('shots_fired'); $weaponTotal->others->{$key}->shots_hit = $weapons->sum('shots_hit'); $weaponTotal->others->{$key}->kills = $weapons->sum('kills'); $weaponTotal->others->{$key}->accuracy = $weaponTotal->others->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->others->{$key}->shots_hit / $weaponTotal->others->{$key}->shots_fired * 100, 2); $weaponTotal->others->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->others->{$key}->kills / $weapons->sum('seconds_used') * 60, 2); $weaponTotal->others->{$key}->distance = $weapons->max('distance'); $weaponTotal->others->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm"); } } $weaponTotal->push($weaponTotal->primary->sortByDesc('kills'))->push($weaponTotal->secondary->sortByDesc('kills'))->push($weaponTotal->tactical->sortByDesc('shots_fired'))->push($weaponTotal->others->sortByDesc('kills')); return $weaponTotal; }