From 1eee94d2604fb43b5a4a21c281c72ad356906a88 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 12 Mar 2017 23:57:42 +0000 Subject: Added identify form and Ratchet websockets test stuff --- src/Core/Main.php | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'src/Core/Main.php') 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 */ - 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 - * @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 - */ - 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); } } -- cgit v1.2.3