summaryrefslogtreecommitdiff
path: root/src/Core/Main.php
blob: e893d4098e544ac03db37855dceff95c84c8e7f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

namespace App\Core;

use App\Game;

/**
 * Not really sure if we need this
 */
class Main
{
    protected $game;

    /**
     * Construct
     *
     * @author Phil Burton <phil@pgburton.com>
     */
    public function __construct($name, $gameCode, $action)
    {
        $this->init($name, $gameCode, $action);
    }

    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();
        }
    }

    protected function identify($name, $gameCode)
    {
        $this->findOrCreateGame($name, $gameCode);

        // $this->addUserToGame($name, $gameCode);
    }

    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)
    {
        return new Game($name, $gameCode);
    }
}