function getOne($id_game, $mobile) { $game = Game::get($id_game); if ($game->num_players > 1) { $entries = Entry::getByTeamGame($id_game); } else { $entries = Entry::getBySoloGame($id_game); } return view($mobile . 'games.one', ['games' => $games, 'entries' => $entries]); }
function getOne($id_game) { $game = Game::get($id_game); if ($game->num_players > 1) { $entries = Entry::getByTeamGame($id_game); } else { $entries = Entry::getBySoloGame($id_game); } return response()->json($entries); }
public function indexGames() { $games = Game::get(); $bgg = new \App\Bgg(); $uploadr = new \App\Uploadr(); foreach ($games as $game) { $url = 'http:' . $bgg->getGameImage($game->bgg_id); $path = $uploadr->uploadFromUrl($url, $game->id, 'game'); $game->photo = $path; $game->save(); } return redirect()->back(); }
function getOne($id_game) { $game = Game::get($id_game); if ($game->num_players > 1) { $entries = Entry::getByTeamGame($id_game); } else { $entries = Entry::getBySoloGame($id_game); } if (empty($entries)) { return view('light.empty', ['game' => $game]); } return view($game->num_players > 1 ? 'light.multi' : 'light.solo', ['game' => $game, 'entries' => $entries]); }
public function edit($id) { return view('playthrough.edit', ['players' => User::get(['id', 'nickname', 'profile_photo']), 'games' => Game::get(['id', 'name', 'photo']), 'playthrough' => Playthrough::find($id), 'p_id' => $id]); }
public function index() { $games = Game::get(); return view('index', compact('games')); }
public function parse() { $games = Game::get(); foreach ($games as $game) { if (preg_match('/Event "(.*?)"/', $game->pgn, $match)) { $game->event = $match[1]; } if (preg_match('/Site "(.*?)"/', $game->pgn, $match)) { $game->site = $match[1]; } if (preg_match('/[^a-zA-Z]Date "(.*?)"/', $game->pgn, $match)) { $game->gameDate = $match[1]; if (preg_match('/([0-9]+)/', $game->gameDate, $match2)) { $game->year = $match2[1]; } } if (preg_match('/Round "(.*?)"/', $game->pgn, $match)) { $game->gameRound = $match[1]; } if (preg_match('/White "(.*?)"/', $game->pgn, $match)) { $game->white = $match[1]; } if (preg_match('/Black "(.*?)"/', $game->pgn, $match)) { $game->black = $match[1]; } if (preg_match('/Result "(.*?)"/', $game->pgn, $match)) { $game->gameResult = $match[1]; } if (preg_match('/ECO "(.*?)"/', $game->pgn, $match)) { $game->eco = $match[1]; } if (preg_match('/WhiteElo "(.*?)"/', $game->pgn, $match)) { $game->whiteElo = " (" . $match[1] . ")"; } else { $game->whiteElo = ""; } if (preg_match('/BlackElo "(.*?)"/', $game->pgn, $match)) { $game->blackElo = " (" . $match[1] . ")"; } else { $game->blackElo = ""; } // Compose a title from players information $game->title = $game->white . $game->whiteElo . " - " . $game->black . $game->blackElo; // Begin with complete pgn of game $game->moves = $game->pgn; // Strip comments $game->moves = preg_replace('/(\\{.*?\\})/', '', $game->moves); // Strip pgn tags $game->moves = preg_replace('/\\[.*\\]/', '', $game->moves); // Convert multiple white space to a single blank char $game->moves = preg_replace("/\\s+/", ' ', $game->moves); // Remove alternative lines and variations $game->moves = self::parseMoves($game->moves); // Strip single & double quotes $game->moves = self::strip_slashes($game->moves); // Find eco code for string opening name and moves $res = DB::select(DB::raw("SELECT * FROM mcc_ecos WHERE eco LIKE '%{$game->eco}%' LIMIT 1")); $game->ecoCode = $res[0]->id; $game->save(); } $games = Game::sortable()->paginate(env('GAME_PAGINATION_MAX')); return view('games.index')->with('games', $games); }
public function adminIndex() { $games = Game::get(); return view('administration/games/index', compact('games')); }
function editTeam($id_game, $id_entry, $old_players, $email, Request $req) { $entry = $req->all(); $entry['id'] = $id_entry; $game = Game::get($id_game); $vld_approv = ['name' => 'required', 'password' => 'required', 'campus' => 'required|in:Cergy,Pau,Mixte', 'real_name.0' => 'required', 'p_name.0' => 'required', 'p_campus.0' => 'required|in:Cergy,Pau,Mixte', 'id' => 'required|numeric']; for ($i = 1; $i < $game->num_players; $i++) { $vld_approv['real_name.' . $i] = 'required_with:p_name.' . $i; $vld_approv['p_name.' . $i] = 'required_with:real_name.' . $i; } $vld = Validator::make($entry, $vld_approv); if ($vld->fails()) { if ($req->is('light/*')) { return redirect()->back()->with('errors', $vld->messages()->all())->with('entry', $entry); } return response()->json($vld->messages()->all(), 400); } $team = $req->only('name', 'password', 'campus'); $team['id'] = $id_entry; $team['real_name'] = ''; if (Entry::update($team) == 0) { if ($req->is('light/*')) { return redirect()->back()->with('errors', ["Mot de passe non valide."])->with('entry', $entry); } return response()->json(["Mot de passe non valide."], 400); } $i = 0; while ($req->input('p_name.' . $i) || !empty($old_players[$i])) { if (empty($req->input('p_name.' . $i))) { Entry::delete($old_players[$i]->rowid, $req->input('password')); } else { if (!empty($old_players[$i])) { Entry::update(['id' => $old_players[$i]->rowid, 'real_name' => $req->input('real_name.' . $i), 'name' => $req->input('p_name.' . $i), 'campus' => $req->input('p_campus.' . $i) || $players[0]['p_campus'], 'password' => $req->input('password')]); } else { Entry::create(['real_name' => $req->input('real_name.' . $i), 'name' => $req->input('p_name.' . $i), 'campus' => $req->input('p_campus.' . $i) || $players[0]['p_campus'], 'id_team' => $id_entry, 'password' => Hash::make($req->input('password')), 'time' => time(), 'email' => $email, 'id_game' => $id_game]); } } $i++; } if ($req->is('light/*')) { return redirect('light/' . $id_game); } return response()->json("success"); }