public function getShow($gameId)
 {
     $game = Game::findOrFail($gameId);
     $account = Account::where('user_id', '=', Auth::user()->id)->where('game_id', '=', $gameId)->first();
     $servers = $game->servers()->paginate(10);
     return view('game.show', ['game' => $game, 'account' => $account, 'servers' => $servers, 'page_title' => 'Game Detail']);
 }
Exemplo n.º 2
0
 public function postCalculateMatch($slug, $id, Request $request)
 {
     $tournament = KTournament::enabled()->whereSlug($slug)->first();
     $match = KMatch::find($id);
     if (!$tournament || !$match) {
         abort(404);
     }
     //If has enough permissions or not
     if (!$request->user()->canManageTournament($tournament)) {
         return redirect()->home();
     }
     if ($match->has_been_played) {
         return redirect()->route('tournament.bracket.show', [$tournament->slug])->with('error', "Error! Already calculated, Plz contact admin for support");
     }
     $collection = new Collection();
     $i = 1;
     foreach ($request->game_id as $game_id) {
         //If game_id is 0 means game is not played
         if ($game_id == 0) {
             $game = new Game();
             $game->game_index = $i;
             $game->is_played = false;
         } else {
             //Get the game
             $game = Game::findOrFail($game_id);
             $game->game_index = $i;
             $game->is_played = true;
         }
         $i++;
         $collection->push($game);
     }
     //dd($collection);
     return view('tournament.manage.getcalculate2')->with('tournament', $tournament)->with('match', $match)->with('games', $collection);
 }
Exemplo n.º 3
0
 public function update($id, GameRequestUpdate $request)
 {
     /*
             Original, don't change*/
     $game = Game::findOrFail($id);
     $game->update($request->all());
     return redirect('games');
 }
 /**
  * Rate the specified Game.
  *
  * @param  int  $id
  * @return Response
  */
 public function Rate($id)
 {
     if (isset($_POST['rate']) && !empty($_POST['rate'])) {
         $game = Game::findOrFail($id);
         $rating = new Rating();
         $rating->rating = $_POST['rate'];
         $rating->user_id = Auth::user()->user_id;
         $game->ratings()->save($rating);
     }
 }
 public function destroy($gameId)
 {
     try {
         $game = Game::findOrFail($gameId);
         $game->delete();
     } catch (Exception $e) {
         Session::flash('message', 'Fail : ' . $e->getMessage());
         return Redirect::back();
     }
     return Redirect::to(route('admin.game.index'));
 }
 public function update($serverId)
 {
     $rules = $this->rules;
     $rules['name'] .= ',' . $serverId;
     $validator = \Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $server = Server::findOrFail($serverId);
         $game = Game::findOrFail(Input::get('game_id'));
         $server->name = Input::get('name');
         $server->ip = Input::get('ip');
         $server->port = Input::get('port');
         $server->status = Input::get('status');
         $server->game_id = $game->id;
         $server->save();
         return Redirect::to(route('admin.server.show', $server->id));
     }
 }
 public function update($accountId)
 {
     $rule = $this->rules;
     $rule['username'][2] .= ',' . $accountId;
     $validator = Validator::make(Input::all(), $rule);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $game = Game::findOrFail(Input::get('game_id'));
         $user = User::findOrFail(Input::get('user_id'));
         $account = Account::findOrFail($accountId);
         $account->username = Input::get('username');
         $account->password = Input::get('password');
         $account->user_id = $user->id;
         $account->game_id = $game->id;
         $account->save();
         return Redirect::to(route('admin.account.show', $account->id));
     }
 }
 function answer_handle($game_id, $question_index, PlayRequest $request)
 {
     $current_question_index = $question_index - 1;
     if (Input::get('submit')) {
         $input = Request::all();
         $answer = Answer::findOrFail($input['answer']);
         DB::table('answers')->whereId($answer->id)->increment('count');
         $message = "";
         if ($answer->correct) {
             $message = "Your answer is correct!";
             Session::put('correct_count', Session::get('correct_count') + 1);
         } else {
             $message = "Wrong answer!";
         }
         Session::flash('message', $message);
         return redirect()->action('GamesController@play', [$game_id, $question_index]);
     } elseif (Input::get('check')) {
         $input = Request::all();
         $answer = Answer::findOrFail($input['answer']);
         if (!Session::get('checked_answer')) {
             Session::put('checked_answer', true);
             if ($answer->correct) {
                 $message = "That is the correct answer";
             } else {
                 $message = "That is an incorrect answer";
             }
         } else {
             $message = "You have already used the check answer option";
         }
         Session::flash('message', $message);
         return redirect()->action('GamesController@play', [$game_id, $current_question_index]);
     } elseif (Input::get('fifty')) {
         $message = "fifty fifty";
         if (Session::get('fifty_fifty')) {
             $message = "You've already used your fifty fifty option";
             Session::flash('message', $message);
             return redirect()->action('GamesController@play', [$game_id, $current_question_index]);
         } else {
             Session::put('fifty_fifty', true);
         }
         $game = Game::findOrFail($game_id);
         $question = $game->questions[$current_question_index];
         $i = 0;
         foreach ($question->answers as $answer) {
             if (!$answer->correct && $i < 2) {
                 $question->answers = $question->answers->except($answer->id);
                 $i += 1;
             }
         }
         Session::flash('message', $message);
         $progress = $this->progress($game, $question_index);
         $audience = $this->audience($question);
         return view('games.play')->with(['game' => $game, 'question' => $question, 'next_question_index' => $question_index, 'question_index' => $current_question_index, 'progress' => $progress, 'audience' => $audience]);
     }
 }
Exemplo n.º 9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $game = Game::findOrFail($id);
     $game->delete();
     return redirect(url('/games'));
 }
Exemplo n.º 10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function quit($id)
 {
     $game = Game::findOrFail($id);
     $gamesAssociation = GameAssociation::where('game_id', $game->id)->get();
     if ($game) {
         if ($game->owner == Auth::id()) {
             foreach ($gamesAssociation as $gameAssociated) {
                 $gameAssociated->delete();
             }
             $game->delete();
         } else {
             foreach ($gamesAssociation as $gameAssociated) {
                 $user = User::findOrFail($gameAssociated->user_id);
                 if ($user->id == Auth::id()) {
                     $gameAssociated->delete();
                     $game->nplayers--;
                     $game->save();
                 }
             }
         }
     }
     return redirect("/lobby");
 }
Exemplo n.º 11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(GameRequest $request, $id)
 {
     $game = Game::findOrFail($id);
     $game->update($request->all());
     return redirect('game');
 }
 public function getPassword($gameId)
 {
     $game = Game::findOrFail($gameId);
     return view('account.forgotPassword', ['game' => $game, 'page_title' => 'Reset password']);
 }
Exemplo n.º 13
0
 /**
  * Update the league in storage.
  *
  * @param  int  $id id of league which should be updated
  * @return Response route where to redirect after update
  */
 public function update($id)
 {
     $validator = Validator::make(Input::all(), League::rules($id));
     if ($validator->fails()) {
         return redirect('/leagues/createForm')->withInput()->withErrors($validator);
     }
     $league = League::findOrFail($id);
     $league->name = htmlspecialchars(Input::get('name'));
     $league->abbreviation = htmlspecialchars(Input::get('abbreviation'));
     $league->description = htmlspecialchars(Input::get('description'));
     $league->game()->associate(Game::findOrFail(Input::get('game_id')));
     $league->save();
     return redirect('/leagues');
     //
 }
Exemplo n.º 14
0
 public function show($id)
 {
     $game = Game::findOrFail($id);
     return view('games.show', compact('game'));
 }
Exemplo n.º 15
0
 /**
  * Return match details.
  *
  * @param $slug
  * @param $id
  * @param Request $request
  * @return $this
  */
 public function getTournamentMatch($slug, $id, Request $request)
 {
     $tournament = KTournament::whereSlug($slug)->firstOrFail();
     $match = KMatch::findOrFail($id);
     $games = [];
     for ($i = 1; $i <= 6; $i++) {
         if ($match->{"game" . $i . "_id"} != null) {
             $game = Game::findOrFail($match->{"game" . $i . "_id"});
             $game->game_index = $i;
             array_push($games, $game);
         }
     }
     return view('tournament.showmatch')->with('tournament', $tournament)->with('match', $match)->with('games', $games);
 }
Exemplo n.º 16
0
 /**
  * To handle the Player Detail view section.
  *
  * @param null $id
  * @param $name
  * @return \Illuminate\View\View
  */
 public function getPlayerDetails($name)
 {
     $player = PlayerTotal::findOrFailByName($name);
     $weapons = $player->AllWeapons();
     $latestRounds = $player->lastRounds()->toArray();
     $latestRounds = Game::findOrFail($latestRounds)->sortByDesc('created_at');
     $playerPoints = PlayerPoint::where('name', $name)->get();
     $array = ['player' => $player, 'weaponFamilies' => $weapons, 'latestGames' => $latestRounds, 'playerPoints' => $playerPoints];
     return view('statistics.player-details', $array);
 }
Exemplo n.º 17
0
 public function delete($id)
 {
     $item = Game::findOrFail($id);
     $item->delete();
     return redirect('/category/games');
 }