summaryrefslogtreecommitdiff
path: root/src/Core/Main.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Main.php')
-rw-r--r--src/Core/Main.php52
1 files changed, 34 insertions, 18 deletions
diff --git a/src/Core/Main.php b/src/Core/Main.php
index 7aa643e..e893d40 100644
--- a/src/Core/Main.php
+++ b/src/Core/Main.php
@@ -9,36 +9,52 @@ use App\Game;
*/
class Main
{
+ protected $game;
+
/**
* Construct
*
* @author Phil Burton <phil@pgburton.com>
*/
- public function __construct()
+ public function __construct($name, $gameCode, $action)
{
- $this->init();
+ $this->init($name, $gameCode, $action);
+ }
- $this->run();
+ public function init($name, $gameCode, $action)
+ {
+ // Shit, but it should work for now
+ switch ($action) {
+ case 'identify':
+ $this->identify($name, $gameCode);
+ break;
+ default:
+ echo "Action not found";
+ die();
+ }
}
- /**
- * Initalise
- *
- * @author Phil Burton <phil@pgburton.com>
- * @return bool
- */
- protected function init()
+ protected function identify($name, $gameCode)
{
- return true;
+ $this->findOrCreateGame($name, $gameCode);
+
+ // $this->addUserToGame($name, $gameCode);
}
- /**
- * Run the Game
- *
- * @author Phil Burton <phil@pgburton.com>
- */
- protected function run()
+ public function findOrCreateGame($name, $gameCode)
+ {
+ // For now always create a new game
+ $this->game = $this->createGame($name, $gameCode);
+ $this->showWelcome($gameCode);
+ }
+
+ public function showWelcome()
+ {
+ include "welcome.php";
+ }
+
+ public function createGame($name, $gameCode)
{
- $game = new Game();
+ return new Game($name, $gameCode);
}
}