Beispiel #1
0
 public function Home()
 {
     $nbPlayersWithoutPhoto = Player::where('photo', null)->count();
     $nbPlayersWithoutEmail = Player::where('email', null)->count();
     //$nbTeamsWithoutCaptain = Player::where('photo', null)->count();
     return view('admin.home', array('nbPlayersWithoutPhoto' => $nbPlayersWithoutPhoto, 'nbPlayersWithoutEmail' => $nbPlayersWithoutEmail));
 }
Beispiel #2
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         $players = DB::connection('game')->table('player_characters')->get();
         foreach ($players as $player) {
             if (!Player::where('id', $player->id)->exists()) {
                 $player_info = ['id' => $player->id, 'name' => $player->given_name, 'level' => $player->level, 'class' => 0, 'gold' => $player->gold, 'family_name' => $player->family_id ? DB::connection('game')->table('family')->where('id', $player->family_id)->first()->name : '-'];
                 Player::create($player_info);
             }
         }
     })->everyTenMinutes();
     $schedule->call(function () {
         $families = DB::connection('game')->table('family')->get();
         foreach ($families as $family) {
             if (!Family::where('id', $family->id)->exists()) {
                 $gold = 0;
                 foreach (DB::connection('game')->table('player_characters')->where('family_id', $family->id)->get() as $player) {
                     $gold += $player->gold;
                 }
                 $family_info = ['id' => $family->id, 'name' => $family->name, 'level' => $family->lv, 'gold' => $gold, 'members' => DB::connection('game')->table('player_characters')->where('family_id', $family->id)->count(), 'leader' => DB::connection('game')->table('player_characters')->where('id', $family->leader_id)->first()->given_name];
                 Family::create($family_info);
             }
         }
     })->everyTenMinutes();
 }
 /**
  * Search players. If direct match, send to player page. If not, return all results to search results view.
  *
  * @param SearchRequest|Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function playerSearch(SearchRequest $request)
 {
     $player = Player::where('name', $request->input('searchTerm'))->first();
     if ($player) {
         return redirect(route('view-player', array('id' => $player->accountID)));
     }
     $results = Player::where('name', 'LIKE', '%' . $request->input('searchTerm') . '%')->paginate(15);
     return view('search.results', compact('results'));
 }
Beispiel #4
0
 public function getPlayers()
 {
     $players = [];
     foreach ($this->Scores->groupBy('player_id') as $id => $t) {
         $players[] = Player::where('id', '=', $id)->first();
     }
     if (count($players) > 0) {
         return $players;
     }
     return false;
 }
Beispiel #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('[' . date('d/m/Y H:i:s') . '][FFTT:Players] STARTING');
     $licencies = xml_liste_joueur_o('18270175');
     Player::where('active', 1)->update(['active' => 0, 'saison' => date('Y') . '-' . (date('Y') - 1)]);
     foreach ($licencies as $licencie) {
         Artisan::queue('FFTT:Player', ['licence' => $licencie->licence]);
         $this->info('[' . date('d/m/Y H:i:s') . '][FFTT:Players] ' . $licencie->licence . ' ending');
     }
     $this->info('[' . date('d/m/Y H:i:s') . '][FFTT:Players] ENDED');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, Vote $votes)
 {
     $player1ID = Input::get('ddlPlayer1');
     $player2ID = Input::get('ddlPlayer2');
     $players_list = Player::orderby('last_name')->orderby('first_name')->get()->lists('last_first_name', 'player_id');
     $player1 = Player::where('player_id', '=', $player1ID)->first();
     $player2 = Player::where('player_id', '=', $player2ID)->first();
     $h2h = new Match();
     $head2head = $h2h->head2head($player1ID, $player2ID);
     $skills = Skill::orderby('skill_id')->get();
     $voter_id = \Auth::user()->id;
     return view('pages/matchups.show', compact('players_list', 'player1', 'player2', 'head2head', 'skills', 'votes', 'voter_id'));
 }
 /**
  * Joins the game of another person
  */
 public function join()
 {
     $players = Player::where('user_id', Auth::id())->get();
     $gameIds = $players->lists('game_id')->toArray();
     $game = Game::whereNotIn('id', $gameIds)->where(['state' => Game::STATE_OPEN])->first();
     if (is_null($game)) {
         session()->flash('error', sprintf(self::ERROR_NO_GAMES_FOUND, Auth::user()->name));
         return redirect()->route('welcome');
     }
     $player = new Player();
     $player->game_id = $game->id;
     $player->user_id = Auth::id();
     $player->troops = 5;
     $player->save();
     session()->flash('success', sprintf(self::MESSAGE_JOINED_GAME, Auth::user()->name));
     return redirect()->route(self::ROUTE_SHOW_GAME, [$game->id]);
 }
Beispiel #8
0
 public function __construct()
 {
     /*Licznik zmian, który zmienia się po 24h od dodania zmiany*/
     $date = Carbon::now();
     $date->modify('-24 hours');
     $formatted_date = $date->format('Y-m-d H:i:s');
     $countchange = Change::where('created_at', '>', $formatted_date)->count();
     /*Licznik graczy Online na serwerze*/
     $countonline = Player::where('online', '=', 1)->count();
     /*Licznik niedoczytanych wiadomości prywatnych*/
     $notread1 = Message::where('to_user_id', \Auth::id())->where('read', 0)->count();
     if (\Auth::check()) {
         Cache::remember('users', 5, function () {
             return User::where('id', \Auth::id())->update(['last_activity' => Carbon::now()]);
         });
     }
     /*Licznik i skrypt usuwający i nadający banicję za 4 ostrzeżenia na stronie*/
     $countcautions = Caution::where('user_id', \Auth::id())->count();
     if (!\Auth::guest() && $countcautions == 4) {
         $user = User::where('id', \Auth::id())->first();
         $g = array(4);
         $user->update(['banned' => 'Zbanowany za 4 ostrzeżenia na stronie']);
         $user->group()->sync($g);
     }
     $deleteCaution = Caution::where('user_id', \Auth::id())->where('created_at', '<=', Carbon::now()->subDays(14));
     $deleteCaution->delete();
     $section = Section::lists('name', 'id');
     $lives = Live::latest('created_at')->take(5)->get();
     if (!\Auth::guest()) {
         $notifications = \Auth::user()->notification()->latest('created_at')->take(10)->get();
         View::share('notifications', $notifications);
     }
     View::share('countchange', $countchange);
     View::share('countonline', $countonline);
     View::share('notread1', $notread1);
     View::share('section', $section);
     View::share('lives', $lives);
     $this->middleware('banned', ['except' => ['auth']]);
 }
Beispiel #9
0
 protected function getFactionStat($fid, $stat, $total = 0)
 {
     $players = Player::where('faction_id', $fid)->get();
     foreach ($players as $k => $v) {
         if ($v[$stat] > 0) {
             $total += $v[$stat];
         }
     }
     return $total;
 }
 /**
  * @param $name
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postPlayerUndelete($name)
 {
     $player = Player::where('name', $name)->first();
     if ($player == null || !\Auth::user()->isAdmin()) {
         abort(404);
     }
     if (!DeletedPlayer::where('player_name', $name)->first()) {
         return back()->with('error', 'Player no longer in deleted list');
     }
     $delplayer = DeletedPlayer::where('player_name', $name)->first();
     $delplayer->delete();
     return redirect()->back()->with('success', 'Success! Player will be removed from deleted-list within an hour.');
 }
Beispiel #11
0
 public function PlayersNoPhoto()
 {
     $players = Player::where('photo', null)->get();
     return view('admin.batchs.players', array('players' => $players));
 }
 public function online()
 {
     $players = Player::where('online', '=', 1)->get();
     return view('character.online', compact('players'));
 }
Beispiel #13
0
 /**
  * 创建玩家实例
  */
 public function create()
 {
     // 取得玩家终端ID
     $intDeviceId = Input::get('device_id');
     // 终端ID检查
     if (!$intDeviceId || $intDeviceId == "") {
         return 'Create Error';
     }
     // 检查玩家是否已经存在
     $objPlayerCheck = Player::where('device_id', $intDeviceId)->get();
     if (!empty($objPlayerCheck->toArray())) {
         return 'Player Is Exsit';
     }
     // TODO Truncate
     DB::beginTransaction();
     // 创建玩家实例
     $objPlayer = new Player();
     $objPlayer->device_id = $intDeviceId;
     if ($objPlayer->save()) {
         // 若玩家实例创建成功,创建玩家数据
         $objPlayerData = new PlayerData();
         // 玩家数据初始化 TODO
         $objPlayerData->id = $objPlayer->id;
         $objPlayerData->code = "";
         $objPlayerData->profile = "";
         $objPlayerData->money = 500;
         $objPlayerData->stone = 50;
         if ($objPlayerData->save()) {
             // 最初的卡片赋予 TODO 初始卡片选择
             $objPlayer->appendCard(1);
             // 最初的队伍组建
             $objPlayer->firstTeam();
             // 其他初始化项目 如果有的话添加
             DB::commit();
             return Response::json($objPlayerData);
         } else {
             // 若保持失败
             DB::rollback();
             return Response::json(null);
         }
     } else {
         // 若保持失败
         DB::rollback();
         return Response::json(null);
     }
 }
 /**
  * Search players
  *
  * @return json
  **/
 public function search(SearchPlayerRequest $request)
 {
     $players = Player::where('first_name', 'like', '%' . $request->search . '%')->orWhere('last_name', 'like', '%' . $request->search . '%')->orWhere('email', 'like', '%' . $request->search . '%')->distinct()->paginate(20);
     return view('dashboard.players.index', compact('players', 'request'));
 }
Beispiel #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $licence = $this->argument('licence');
     if (is_array($licence)) {
         $licence = $licence[0];
     }
     $lic = xml_licence_b($licence)->licence;
     if ($lic != '') {
         $player = Player::where('licence', $licence)->first();
         if ($player == null) {
             $player = new Player();
         }
         $player->idlicence = $lic->idlicence;
         $player->licence = $lic->licence;
         $player->nom = $lic->nom;
         $player->prenom = $lic->prenom;
         $player->numclub = $lic->numclub;
         $player->sexe = $lic->sexe;
         $player->type = $lic->type;
         $player->certif = $lic->certif;
         $player->validation = $lic->validation;
         $player->echelon = $lic->echelon;
         $player->place = $lic->place;
         $player->point = (int) $lic->point;
         $player->cat = $lic->cat;
         $player->pointm = $lic->pointm == '' ? 500 : (int) $lic->pointm;
         $player->apointm = $lic->apointm == '' ? 500 : (int) $lic->apointm;
         $player->initm = $lic->initm == '' ? 500 : (int) $lic->initm;
         $player->active = 1;
         $player->save();
         $histos = xml_histo_classement($player->licence);
         $i = 1;
         foreach ($histos as $hist) {
             $histo = RankHisto::where('player_id', $player->id)->where('id_h', $i)->first();
             if ($histo == null) {
                 $histo = new RankHisto();
             }
             $histo->id_h = $i;
             $histo->player_id = $player->id;
             $histo->echelon = $hist->echelon;
             $histo->place = $hist->place;
             $histo->point = (int) $hist->point;
             $histo->saison = $hist->saison;
             $histo->phase = (int) $hist->phase;
             $histo->save();
             $i++;
         }
         Versus::where('player_id', $player->id)->where('active', 1)->update(['active' => 0, 'saison' => date('Y') . '-' . (date('Y') - 1)]);
         $parties_mysql = xml_partie_mysql($player->licence);
         foreach ($parties_mysql as $partie) {
             $versus = Versus::where('player_id', $player->id)->where('advlicence', $partie->advlic)->where('date', $partie->date)->first();
             if ($versus == null) {
                 $versus = new Versus();
             }
             $versus->player_id = $player->id;
             $versus->licence = $partie->licence;
             $versus->advlicence = $partie->advlic;
             $versus->vd = $partie->vd;
             $versus->numjourn = $partie->numjourn;
             $versus->codechamp = $partie->codechamp;
             $versus->date = $partie->date;
             $versus->datef = substr($partie->date, 6, 2) . substr($partie->date, 3, 2) . substr($partie->date, 0, 2);
             $versus->advsexe = $partie->advsexe;
             $versus->advnompre = $partie->advnompre;
             $versus->pointres = $partie->pointres;
             $versus->coefchamp = $partie->coefchamp;
             $versus->advclaof = $partie->advclaof;
             $versus->active = 1;
             $versus->save();
         }
         $parties_mysql = xml_partie($player->licence);
         foreach ($parties_mysql as $partie) {
             $versus = Versus::where('player_id', $player->id)->where('advnompre', substr($partie->nom, 0, 24))->where('date', $partie->date)->where('vd', $partie->victoire)->first();
             if ($versus != null) {
                 $versus->epreuve = $partie->epreuve;
                 $versus->classement = $partie->classement;
                 $versus->forfait = $partie->forfait;
                 $versus->active = 1;
                 $versus->save();
             }
         }
         if ($player->photo == null) {
             $glob = glob(public_path('img/photos/licencies/' . str_slug($player->nom) . '-' . str_slug($player->prenom) . '.*'));
             if (count($glob) > 0) {
                 $image = $glob[0];
                 $player->photo = 'licencies/' . str_slug($player->nom) . '-' . str_slug($player->prenom) . '.' . pathinfo($image)['extension'];
                 $player->save();
             } else {
                 $image = public_path('img/photos/none.jpg');
             }
         } else {
             $image = public_path('img/photos/' . $player->photo);
         }
         if (file_exists($image)) {
             if (pathinfo($image)['extension'] == 'png') {
                 $jpg_image = imagecreatefrompng($image);
             } else {
                 $jpg_image = imagecreatefromjpeg($image);
             }
             $red = imagecolorallocate($jpg_image, 180, 0, 0);
             $green = imagecolorallocate($jpg_image, 0, 180, 0);
             $font_path = public_path() . '/fonts/IndieFlower.ttf';
             $points = round($player->pointm - $player->point, 0);
             if ($points >= 0) {
                 $color = $green;
                 $points = '+' . $points;
             } else {
                 $color = $red;
             }
             $imgSize = getimagesize($image)[0];
             $size = 66 * $imgSize / 300;
             $x = 130 * $imgSize / 300;
             $y = 290 * $imgSize / 300;
             imagettftext($jpg_image, $size, 10, $x, $y, $color, $font_path, $points);
             imagejpeg($jpg_image, public_path() . '/img/photos/prog-' . str_slug($player->nom) . '-' . str_slug($player->prenom) . '.jpg');
             imagedestroy($jpg_image);
         }
     } else {
         dd($licence);
     }
 }
Beispiel #16
0
 public function home()
 {
     $players = Player::where('active', 1)->orderBy('pointm', 'desc')->orderBy('nom', 'asc')->orderBy('prenom', 'asc')->get();
     return view('front.players.home', array('players' => $players));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $serverId)
 {
     $player = Player::where('serverID', $serverId)->where('accountID', $id)->firstOrFail();
     return view('players.view', compact('player'));
 }
Beispiel #18
0
 public function getPlayerById($id)
 {
     $player = Player::where('id', (int) $id);
     return response()->json(['player' => $player]);
 }
Beispiel #19
0
 /**
  * Delete player by id.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $player = NULL;
     if (is_numeric($id)) {
         $player = Player::find($id)->first();
     } else {
         $player = Player::where('nick', '=', $id)->first();
     }
     if ($player === NULL) {
         $this->tpl['title'] = 'Not found';
         $this->tpl['error']['message'] = 'User not found';
         $this->tpl['error']['description'] = 'Sorry, but your user is not found.';
         return \Response::view('errors.404', $this->tpl);
     }
     $player->delete();
     return \Redirect::route('players');
 }