| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * Context file.
- *
- * Provides a class to retrieve a context.
- *
- * @category Context
- */
- /**
- * Application context.
- *
- * Stores usefull data to be retrieved anywhere in the app.
- *
- * @category Context
- */
- class Context {
- private $user;
- private $player;
- private $db;
- 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.
- *
- * @return int Game mode.
- */
- public function get_game_mode(){
- return $this->game_mode;
- }
- /**
- * Sets the current user.
- *
- * @param The current user.s
- */
- 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.
- *
- * @param int Game mode.
- */
- protected function set_game_mode($game_mode){
- $this->game_mode = $game_mode;
- }
- }
- ?>
|