Beispiel #1
0
 public static function getGameState($match_id, $player_id)
 {
     //get match
     $match = Matches::find($match_id);
     //get player's opponent id
     $opponent_id = Matches::getOpponentID($match_id, $player_id);
     //get the player's state
     $player = Player::getPlayerState($match_id, $player_id);
     //get the opponent player's state
     $opponent = Player::getPlayerState($match_id, $opponent_id);
     //get the game's current state
     $match_state = $match->match_state;
     //get the current active player
     $active_player = $match->active_player_id;
     //get mogs for results animation screen
     $round_result_mogs = PlayField::getResultsAnimationMogs($match_id);
     //get last update timestamp
     $last_update = $match->updated_at;
     $last_update = substr($last_update, 0, 19);
     //create new game_state object
     $game_state = new GameState($player, $opponent, $match_state, $active_player, $round_result_mogs, $last_update);
     return $game_state;
 }
 public function getGameOverDetail($match_id)
 {
     $response = [];
     $response['match_detail'] = Matches::find($match_id);
     $response['p1_name'] = User::getUsername($response['match_detail']->p1_id);
     $response['p2_name'] = User::getUsername($response['match_detail']->p2_id);
     return $response;
 }
Beispiel #3
0
 public static function getOpponentID($match_id, $player_id)
 {
     $match = Matches::find($match_id);
     // print_r($match);
     if ($match['p1_id'] == $player_id) {
         $opponent_id = $match['p2_id'];
     } else {
         $opponent_id = $match['p1_id'];
     }
     return $opponent_id;
 }