Exemplo n.º 1
0
 /**
  * Fills games table
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Game::create(['name' => $faker->name(), 'abbreviation' => $faker->realText(10), 'type' => $faker->realText(100), 'description' => $faker->realText(255)]);
     }
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('games')->delete();
     Game::create(['id' => 1, 'score1' => 15, 'score2' => 0, 'minutes' => 10]);
     Game::create(['id' => 2, 'score1' => 15, 'score2' => 14, 'minutes' => 27]);
     Game::create(['id' => 3, 'score1' => 15, 'score2' => 4, 'minutes' => 20]);
     Game::create(['id' => 4, 'score1' => 15, 'score2' => 4, 'minutes' => 22]);
     Game::create(['id' => 5, 'score1' => 15, 'score2' => 10, 'minutes' => 33]);
     Game::create(['id' => 6, 'score1' => 15, 'score2' => 7, 'minutes' => 28]);
     /** Alexandra H. Battle Alamo */
     /** Pro Rnd 1*/
     Game::create(['id' => 7, 'score1' => 11, 'score2' => 7, 'minutes' => 28]);
     Game::create(['id' => 8, 'score1' => 11, 'score2' => 8, 'minutes' => 28]);
     Game::create(['id' => 9, 'score1' => 11, 'score2' => 8, 'minutes' => 28]);
     /** Pro Rnd 2*/
     Game::create(['id' => 10, 'score1' => 11, 'score2' => 9, 'minutes' => 28]);
     Game::create(['id' => 11, 'score1' => 11, 'score2' => 7, 'minutes' => 28]);
     Game::create(['id' => 12, 'score1' => 2, 'score2' => 11, 'minutes' => 28]);
     Game::create(['id' => 13, 'score1' => 15, 'score2' => 13, 'minutes' => 28]);
     /** Open Rnd 1 */
     Game::create(['id' => 14, 'score1' => 15, 'score2' => 1, 'minutes' => 10]);
     Game::create(['id' => 15, 'score1' => 15, 'score2' => 0, 'minutes' => 8]);
     /** Open Rnd 2 */
     Game::create(['id' => 16, 'score1' => 15, 'score2' => 3, 'minutes' => 19]);
     Game::create(['id' => 17, 'score1' => 15, 'score2' => 1, 'minutes' => 14]);
     /** Open Rnd 3 */
     Game::create(['id' => 18, 'score1' => 15, 'score2' => 4, 'minutes' => 22]);
     Game::create(['id' => 19, 'score1' => 15, 'score2' => 2, 'minutes' => 17]);
     /** Open Rnd 4 */
     Game::create(['id' => 20, 'score1' => 15, 'score2' => 13, 'minutes' => 36]);
     Game::create(['id' => 21, 'score1' => 15, 'score2' => 11, 'minutes' => 32]);
 }
Exemplo n.º 3
0
 public function createRoom(Request $request)
 {
     $createGame = Game::prepareCreateGame(Input::all());
     $gameCreated = Game::create($createGame);
     $gameCreated->attachPlayersToGame();
     return Redirect::to('gameLobby');
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(GameRequest $request)
 {
     $input = $request->all();
     // return $input;
     $input['user_id'] = Auth::user()->id;
     Game::create($input);
     return redirect('game');
 }
Exemplo n.º 5
0
 /**
  *儲存資料
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $game = new Game();
     //game 是model 名稱
     $game->title = $input['title'];
     $game->content = $input['content'];
     $game->save();
     Game::create(['title' => $input['title']], ['content' => $input['content']]);
 }
 function store()
 {
     $game_info = Request::only(['name', 'description']);
     $game = Game::create($game_info);
     $input = Request::all();
     //add questions
     foreach ($input['add_questions'] as $question_id) {
         $question = Question::findOrFail($question_id);
         $game->questions()->save($question);
     }
     return redirect('games');
 }
Exemplo n.º 7
0
 public function createGame()
 {
     $game = Game::create(['statusgame' => 'created', 'player1id' => Auth::user()->id, 'board1' => '000000000000000000000000000000000000', 'status1' => 'joined', 'player2id' => 0, 'board2' => '000000000000000000000000000000000000', 'status2' => 'empty']);
     Session::put('gameid', $game->id);
     //$this->me = ['id' => ($game->player1id), 'board' => ($game->board1), 'status' => ($game->status1)];
     //$this->vs = ['id' => ($game->player2id), 'board' => ($game->board2), 'status' => ($game->status2)];
     //$this->me = ['id' => ($game->player2id), 'board' => ($game->board2), 'status' => ($game->status2)];
     //$this->vs = ['id' => ($game->player1id), 'board' => ($game->board1), 'status' => ($game->status1)];
     //Session::put('me', $this->me);
     //Session::put('vs', $this->vs);
     //$score=array_count_values($game->board1);
     //session::put('numpos', $score[1]);
 }
Exemplo n.º 8
0
 public function createRoom(Request $request)
 {
     $createGame = Game::prepareCreateGame(Input::all());
     if (Game::where('gameName', '=', $createGame['gameName'])->first() != null) {
         return Redirect::to('gameLobby')->with('message', 'Game Already Exists!');
     }
     $user = Auth::user()->id;
     $gameCreated = Game::create($createGame);
     $gameCreated->attachPlayersToGame();
     $player = User::findOrFail($user);
     $relation = $player->games->find($gameCreated['game_id']);
     $relation->pivot->isPlayer = 1;
     if ($gameCreated->joinedPlayers == $gameCreated->maxPlayers) {
         $gameCreated->status = "Playing";
     }
     $relation->pivot->save();
     $gameCreated->save();
     return Redirect::to('gameLobby')->with('message', 'Game Created!');
 }
Exemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     # Kosongin isi tabel
     DB::table('anggota')->delete();
     DB::table('detailanggota')->delete();
     DB::table('rental')->delete();
     $rental = Rental::create(array('nama' => 'Hanzo', 'alamat' => 'Jalan Buah Batu'));
     $this->command->info('Data rental telah diisi!');
     #Faker testing
     $anggota1 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id));
     $anggota2 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id));
     $anggota3 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id));
     # Buat anggota
     $arvin = Anggota::create(array('nama' => 'Arvin Chendriyana Supriyadi', 'id_rental' => $rental->id));
     $aulia = Anggota::create(array('nama' => 'Aulia Marchita Ramadhani', 'id_rental' => $rental->id));
     $elmo = Anggota::create(array('nama' => 'Elmo Aryaputra', 'id_rental' => $rental->id));
     # Informasi ketika anggota telah diisi.
     $this->command->info('Anggota telah diisi!');
     # Buat Detail Anggota
     DetailAnggota::create(array('jenisKelamin' => 'Laki-laki', 'alamat' => 'Jalan Sidomukti No. 78', 'telp' => '08112282323', 'id_anggota' => $arvin->id));
     DetailAnggota::create(array('jenisKelamin' => 'Perempuan', 'alamat' => 'Tangerang', 'telp' => '081310713931', 'id_anggota' => $aulia->id));
     DetailAnggota::create(array('jenisKelamin' => 'Laki-laki', 'alamat' => 'Jalan Cigadung', 'telp' => '082117713169', 'id_anggota' => $elmo->id));
     # Informasi ketika detail telah diisi.
     $this->command->info('Detail anggota telah diisi!');
     #Seeder Game
     DB::table('game')->delete();
     DB::table('anggota_game')->delete();
     $fallout_4 = Game::create(array('judul' => 'Fallout 4', 'genre' => 'RPG', 'developer' => 'Bethesda'));
     $witcher_3 = Game::create(array('judul' => 'The Witcher 3: Wild Hunt', 'genre' => 'RPG', 'developer' => 'CD Projekt RED'));
     $kh_3 = Game::create(array('judul' => 'Kingdom Hearts 3', 'genre' => 'RPG', 'developer' => 'Square Enix'));
     $arvin->game()->attach($fallout_4->id);
     $arvin->game()->attach($witcher_3->id);
     $arvin->game()->attach($kh_3->id);
     $aulia->game()->attach($kh_3->id);
     $aulia->game()->attach($fallout_4->id);
     $elmo->game()->attach($witcher_3->id);
     # Tampilkan bila berhasil diisi
     $this->command->info('Anggota beserta game telah diisi!');
 }
Exemplo n.º 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $rules = ['name' => 'required', 'userid' => 'required', 'selectType' => 'required', 'privacity' => 'required'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->route('game.create')->withErrors($validator)->withInput();
     } else {
         if ($request->get('numberlines') * $request->get('numbercolumns') > 80) {
             return redirect()->route('game.create')->withErrors("The total number of lines X the total number of columns must be MORE than 80!")->withInput();
         }
     }
     $maxPlayers = 1;
     if ($request->get('selectType') == "Multiplayer") {
         $maxPlayers = $request->get('nmaxplayers');
     }
     $game = Game::create(['name' => $request->get('name'), 'owner' => $request->get('userid'), 'type' => $request->get('selectType'), 'privacity' => $request->get('privacity'), 'numberlines' => $request->get('numberlines'), 'numbercolumns' => $request->get('numbercolumns'), 'nplayers' => 1, 'maxplayers' => $maxPlayers, 'flag' => 0]);
     GameAssociation::create(['game_id' => $game->id, 'user_id' => $game->owner]);
     $message = ['message_success' => 'Game created successfully'];
     if (!$game->save()) {
         $message = ['message_error' => 'Failed to create game'];
     }
     return redirect("/game/{$game->id}");
 }
Exemplo n.º 11
0
 public function store(Request $request)
 {
     $input = $this->request->all();
     $game = Game::create($input);
     //$game = Game::create([])
     $developerID = $request->input('developer');
     $developer = Developer::find($developerID);
     $relation = $game->developer()->save($developer);
     $this->assertInstanceOf('NeoEloquent\\Eloquent\\Edges\\EdgeOut', $relation);
     //
     //        $saved = $relation->save();
     //        $this->assertTrue($saved);
     //        $this->assertInstanceOf('Carbon\Carbon', $relation->created_at, 'make sure we set the created_at timestamp');
     //        $this->assertInstanceOf('Carbon\Carbon', $relation->updated_at, 'make sure we set the updated_at timestamp');
     //        $this->assertArrayHasKey('user', $developer->getRelations(), 'make sure the user has been set as relation in the model');
     //        $this->assertArrayHasKey('user', $developer->toArray(), 'make sure it is also returned when dealing with the model');
     //        $this->assertEquals($developer->game->toArray(), $game->toArray());
     // Let's retrieve it to make sure that NeoEloquent is not lying about it.
     //        $saved = Location::find($developer->id);
     //        $this->assertEquals($game->toArray(), $saved->game->toArray());
     //return $dev; exit;
     //return redirect('games');
 }
Exemplo n.º 12
0
 public function newGame()
 {
     $rand_number = "0." . mt_rand(100000000, 999999999) . mt_rand(100000000, 999999999);
     $game = Game::create(['rand_number' => $rand_number]);
     $game->hash = md5($game->rand_number);
     $game->rand_number = 0;
     return $game;
 }
Exemplo n.º 13
0
 function createGame($game)
 {
     return Game::create($game);
 }
Exemplo n.º 14
0
 public function insertLeague(Request $request)
 {
     $this->validate($request, ['date' => ['required', 'league_already_created'], 'league' => ['required'], 'users' => ['required']]);
     $input = $request->all();
     $date = explode('/', $input['date']);
     $month = $date[0];
     $year = $date[1];
     $league = new League();
     $league->leaguename_id = $input['league'];
     $league->year = $year;
     $league->month = $month;
     $league->users = json_encode($input['users']);
     $league->save();
     $players = $input['users'];
     $rounds = 9;
     $schedule = [];
     for ($leg = 0; $leg < 2; $leg++) {
         for ($round = 1; $round <= $rounds; $round++) {
             $realRound = $round + $leg * 10;
             $schedule[$realRound] = [];
             for ($game = 1; $game <= count($players) / 2; $game++) {
                 $pos1 = $game - 1;
                 $pos2 = count($players) - ($game - 1) - 1;
                 $schedule[$realRound][$game]['home'] = $players[$pos1];
                 $schedule[$realRound][$game]['away'] = $players[$pos2];
                 Game::create(['league_id' => $league->id, 'round' => $realRound, 'user_1_id' => $players[$pos1], 'user_2_id' => $players[$pos2]]);
             }
             // ROTATE ARRAY
             $playersTemp = $players;
             $top = array_shift($playersTemp);
             $last = array_pop($playersTemp);
             $players = [$last];
             foreach ($playersTemp as $value) {
                 $players[] = $value;
             }
             array_unshift($players, $top);
         }
     }
     return redirect()->route('admin.leagues');
 }
Exemplo n.º 15
0
    /**
     * save one game.
     * @param $data
     * @param $package
     * @return static
     * @internal param $item
     */
    protected function saveGames($data, $package)
    {
        $data['icon'] = $this->saveImageFromLink($data['icon'], 'avatars');
        if ($data['icon']) {
            $category = Category::where('name', $data['category'])->first();
            if (!$category) {
                copy(public_path() . '/images/avatars/' . $data['icon'], public_path() . '/images/categories/' . $data['icon']);
                $category = Category::create(['name' => $data['category'], 'icon' => $data['icon'], 'type' => $data['type']]);
            }
            $data['category_id'] = $category->id;
            try {
                $game = Game::create($data);
                foreach ($data['screens'] as $urlCapture) {
                    $urlCapture = $this->saveImageFromLink($urlCapture, 'captures');
                    if ($urlCapture) {
                        Capture::create(['name' => $urlCapture, 'game_id' => $game->id]);
                    }
                }
                try {
                    Package::create([
                        'game_id' => $game->id,
                        'name' => $package
                    ]);
                } catch (QueryException $e) {
                    DB::table('packages')->where('name', $package)->delete();
                    Package::create([
                        'game_id' => $game->id,
                        'name' => $package
                    ]);
                }
            } catch (QueryException $e) {
                return;
            }

        }
    }