Context.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Context file.
  4. *
  5. * Provides a class to retrieve a context.
  6. *
  7. * @category Context
  8. */
  9. /**
  10. * Application context.
  11. *
  12. * Stores usefull data to be retrieved anywhere in the app.
  13. *
  14. * @category Context
  15. */
  16. class Context {
  17. private $user;
  18. private $player;
  19. private $db;
  20. private $game_mode;
  21. /**
  22. * Retrieves the selected user.
  23. *
  24. * @return User The selected user, null if no specified.
  25. */
  26. public function get_user(){
  27. return $this->user;
  28. }
  29. /**
  30. * Retrieves the logged in player.
  31. *
  32. * @return Player The current player, null if not logged in.
  33. */
  34. public function get_player(){
  35. return $this->player;
  36. }
  37. /**
  38. * Retrieves the database connection.
  39. *
  40. * @return SQLITE3 The database connection.
  41. */
  42. public function get_db(){
  43. return $this->db;
  44. }
  45. /**
  46. * Retrieves the current game mode.
  47. *
  48. * @return int Game mode.
  49. */
  50. public function get_game_mode(){
  51. return $this->game_mode;
  52. }
  53. /**
  54. * Sets the current user.
  55. *
  56. * @param The current user.s
  57. */
  58. protected function set_user($user){
  59. $this->user = $user;
  60. }
  61. /**
  62. * Sets the currently logged-in player.
  63. *
  64. * @param Player Logged-in player.
  65. */
  66. protected function set_player($player){
  67. $this->player = $player;
  68. }
  69. /**
  70. * Sets the database connection
  71. *
  72. * @param SQLITE3 Database connection.
  73. */
  74. protected function set_db($db){
  75. $this->db = $db;
  76. }
  77. /**
  78. * Sets the game mode.
  79. *
  80. * @param int Game mode.
  81. */
  82. protected function set_game_mode($game_mode){
  83. $this->game_mode = $game_mode;
  84. }
  85. }
  86. ?>