Esempio n. 1
0
 public function run()
 {
     // DB::table('osu_events')->delete();
     App\Models\Event::unguard();
     $beatmapCount = App\Models\Beatmap::count();
     if ($beatmapCount === 0) {
         $this->command->info('Can\'t seed events due to having no beatmap data.');
         return;
     }
     $faker = Faker::create();
     $users = App\Models\User::all();
     $generateEventText = function ($bm, $bms, $u, $rank) {
         switch ($bm->playmode) {
             case 0:
                 $playmode = 'osu!';
                 break;
             case 1:
                 $playmode = 'Taiko';
                 break;
             case 2:
                 $playmode = 'Catch the Beat';
                 break;
             case 3:
                 $playmode = 'osu!mania';
                 break;
         }
         $rank_letters = ['X', 'S', 'A'];
         $rank_letter = array_rand_val($rank_letters);
         $string = "<img src='/images/" . $rank_letter . "_small.png'/> <b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> achieved rank #' . $rank . " on <a href='/b/" . $bm->beatmap_id . "?m=0'>" . $bms->artist . ' - ' . $bms->title . ' [' . $bm->version . ']' . '</a> (' . $playmode . ')';
         return $string;
     };
     foreach ($users as $u) {
         if ($beatmapCount > 0) {
             $all_beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
             for ($c = 0; $c < 4; $c++) {
                 if ($all_beatmaps[$c]) {
                     $bm = $all_beatmaps[$c];
                     $bms = App\Models\BeatmapSet::find($bm->beatmapset_id);
                     if (isset($bms)) {
                         $is_rank_1 = $faker->boolean(20);
                         if ($is_rank_1 === true) {
                             $rank = 1;
                             $epicfactor = 2;
                         } else {
                             $rank = strval(rand(1, 499));
                             $epicfactor = 1;
                         }
                         $txt = $generateEventText($bm, $bms, $u, $rank);
                         $ev = $u->events()->save(App\Models\Event::create(['user_id' => $u->user_id, 'text' => $txt, 'text_clean' => $txt, 'epicfactor' => $epicfactor, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'date' => rand(1451606400, time())]));
                     }
                 }
             }
         }
         // end rank events
         // Create a random supporter/name change event
         $string = '';
         switch (rand(1, 4)) {
             case 1:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has once again chosen to support osu! - thanks for your generosity!';
                 break;
             case 2:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has become an osu! supporter - thanks for your generosity!';
                 break;
             case 3:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $u->username . '</a></b> has received the gift of osu! supporter!';
                 break;
             case 4:
                 $string = "<b><a href='/u/" . $u->user_id . "'>" . $faker->userName . '</a></b> has changed their username to ' . $u->username . '!';
                 break;
         }
         $ev2 = $u->events()->save(App\Models\Event::create(['user_id' => $u->user_id, 'text' => $string, 'text_clean' => $string, 'epicfactor' => 1, 'date' => rand(1451606400, time())]));
     }
     // END EVENTS
     App\Models\Event::reguard();
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // DB::table('osu_scores')->delete();
     // DB::table('osu_scores_high')->delete();
     // DB::table('osu_scores_taiko')->delete();
     // DB::table('osu_scores_taiko_high')->delete();
     // DB::table('osu_scores_fruits')->delete();
     // DB::table('osu_scores_fruits_high')->delete();
     $beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
     $beatmapCount = count($beatmaps);
     if ($beatmapCount === 0) {
         $this->command->info('Can\'t seed Scores due to having no beatmap data.');
         return;
     }
     $faker = Faker::create();
     $users = App\Models\User::all();
     App\Models\Score\Model::unguard();
     $allBeatmapsets = App\Models\Beatmapset::all();
     $possible_ranks = ['A', 'S', 'B', 'SH', 'XH', 'X'];
     foreach ($users as $k => $u) {
         $osuBeatmaps = $beatmaps->where('playmode', 0)->take(20);
         $taikoBeatmaps = $beatmaps->where('playmode', 1)->take(20);
         $fruitsBeatmaps = $beatmaps->where('playmode', 2)->take(20);
         $maniaBeatmaps = $beatmaps->where('playmode', 3)->take(20);
         //add 20 osu! Standard scores
         foreach ($osuBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             // hr, hd/hr, dt, hd/dt
             $sc = App\Models\Score\Osu::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85), 'rank' => array_rand_val($possible_ranks)]);
             $sc2 = App\Models\Score\Best\Osu::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.5 * $bm->difficultyrating, 'rank' => array_rand_val($possible_ranks)]);
         }
         //Taiko scores
         foreach ($taikoBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             $sc3 = App\Models\Score\Taiko::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85), 'rank' => array_rand_val($possible_ranks)]);
             $sc4 = App\Models\Score\Best\Taiko::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating]);
         }
         // end taiko
         //Fruits scores
         foreach ($fruitsBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             $sc5 = App\Models\Score\Fruits::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85)]);
             $sc6 = App\Models\Score\Best\Fruits::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating]);
         }
         // end fruits
         //Mania scores
         foreach ($maniaBeatmaps as $bm) {
             $bms = $allBeatmapsets->find($bm->beatmapset_id);
             $maxcombo = rand(1, $bm->countTotal);
             $possible_mods = [0, 16, 24, 64, 72];
             // hr, hd/hr, dt, hd/dt
             $sc7 = App\Models\Score\Mania::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pass' => $faker->boolean(85)]);
             $sc8 = App\Models\Score\Best\Mania::create(['user_id' => $u->user_id, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'score' => rand(50000, 100000000), 'maxcombo' => $maxcombo, 'rank' => array_rand_val($possible_ranks), 'count300' => round($maxcombo * 0.8), 'count100' => rand(0, round($maxcombo * 0.15)), 'count50' => rand(0, round($maxcombo * 0.05)), 'countgeki' => round($maxcombo * 0.3), 'countmiss' => round($maxcombo * 0.05), 'countkatu' => round($maxcombo * 0.05), 'enabled_mods' => array_rand_val($possible_mods), 'date' => rand(1451606400, time()), 'pp' => $faker->biasedNumberBetween(10, 100) * 2 * $bm->difficultyrating]);
         }
         // end mania
     }
     App\Models\Score\Model::reguard();
 }