public function validateGameExistsReal($attribute, $value, $parameters)
 {
     try {
         $game = Game::where('instanceId', $value)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return false;
     }
     return true;
 }
 public function postComment(AddCommentRequest $request)
 {
     $game = Game::where('instanceId', $request->get('game_id'))->first();
     $membershipId = $this->user->account->destiny->membershipId;
     $comment = new Comment();
     $comment->comment = $request->get('message');
     $comment->membershipId = $membershipId;
     $comment->characterId = $game->findAccountViaMembershipId($membershipId, false)->characterId;
     $comment->parent_comment_id = 0;
     $game->comments()->save($comment);
     return response()->json(['flag' => true, 'url' => \URL::action('Destiny\\GameController@getGame', $game->instanceId)]);
 }
Beispiel #3
0
 public static function boot()
 {
     parent::boot();
     Game::deleting(function ($game) {
         foreach ($game->players as $player) {
             $player->delete();
         }
         $game->comments()->delete();
         if ($game->pvp instanceof PVP) {
             $game->pvp->delete();
         }
     });
 }
Beispiel #4
0
 public function postToggleGameVisibility(deleteGameRequest $request)
 {
     try {
         $game = Game::where('instanceId', $request->get('game_id'))->firstOrFail();
         $game->hidden = !$game->hidden;
         $game->save();
         if ($game->hidden) {
             $msg = 'Game was hidden from public.';
         } else {
             $msg = 'Game is now visible to public';
         }
         return \Redirect::action('Destiny\\GameController@getGame', array($request->get('game_id')))->with('flash_message', ['type' => 'green', 'header' => 'Game Visibility Toggled!', 'close' => true, 'body' => $msg]);
     } catch (ModelNotFoundException $e) {
         return \Redirect::action('Destiny\\GameController@getIndex');
     }
 }
Beispiel #5
0
 /**
  * @param string $url
  * @param array $data
  * @param string $type
  */
 private function createGame($url, $data, $type)
 {
     $entries = $data['Response']['data']['entries'];
     $game = new Game();
     $game->setTranslatorUrl($url);
     $game->instanceId = $data['Response']['data']['activityDetails']['instanceId'];
     $game->referenceId = $data['Response']['data']['activityDetails']['referenceId'];
     $game->version = config('app.version', 1);
     if (isset($data['Response']['data']['activityDetails']['mode']) && Gametype::isPVP($data['Response']['data']['activityDetails']['mode'])) {
         // delete old PVP-Games
         PVP::where('instanceId', $game->instanceId)->delete();
         // create new one
         $pvp = new PVP();
         $pvp->instanceId = $game->instanceId;
         $pvp->gametype = $data['Response']['data']['activityDetails']['mode'];
         foreach ($data['Response']['data']['teams'] as $team) {
             if ($team['standing']['basic']['value'] == 0) {
                 $pvp->winnerPts = $team['score']['basic']['value'];
                 $pvp->winnerId = $team['teamId'];
             } elseif ($team['standing']['basic']['value'] == 1) {
                 $pvp->loserPts = $team['score']['basic']['value'];
                 $pvp->loserId = $team['teamId'];
             } else {
                 Log::warning('Unknown Team');
             }
         }
         $pvp->save();
     }
     // delete old game-players
     GamePlayer::where('game_id', $game->instanceId)->delete();
     $game->type = $type;
     $game->occurredAt = $data['Response']['data']['period'];
     $time = [];
     foreach ($entries as $entry) {
         $time[] = $this->gamePlayerSetup($data, $entry, $game, isset($pvp) ? $pvp : null);
     }
     // get highest $duration (MODE)
     if (is_array($time)) {
         $time = array_filter($time);
         $game->timeTookInSeconds = Text::array_mode($time);
     }
     $game->save();
 }