* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3 * @package SWDB */ /** * Application context. * * Stores usefull data to be retrieved anywhere in the app. * * @category Context */ class Context { /** * @var User Currently logged in user. */ private $user; /** * @var Player Currently selected player. Does not need to be owned by the logged-in user. */ private $player; /** * @var SQLITE3 Database connection. */ private $db; /** * @var int Selected game mode. * @see GAME_MODE_ID. */ private $game_mode; /** * Retrieves the selected user. * * @return User The selected user, null if no specified. */ public function get_user(){ return $this->user; } /** * Retrieves the logged in player. * * @return Player The current player, null if not logged in. */ public function get_player(){ return $this->player; } /** * Retrieves the database connection. * * @return SQLITE3 The database connection. */ public function get_db(){ return $this->db; } /** * Retrieves the current game mode. * * @see GAME_MODE_ID * @return int Game mode. */ public function get_game_mode(){ return $this->game_mode; } /** * Sets the current user. * * @param The current user. */ protected function set_user($user){ $this->user = $user; } /** * Sets the currently logged-in player. * * @param Player Logged-in player. */ protected function set_player($player){ $this->player = $player; } /** * Sets the database connection * * @param SQLITE3 Database connection. */ protected function set_db($db){ $this->db = $db; } /** * Sets the game mode. * * @see GAME_MODE_ID * @param int Game mode. */ protected function set_game_mode($game_mode){ $this->game_mode = $game_mode; } }