Example #1
0
 public function start()
 {
     // 1. The game contains
     $playerA = new Player('Player A');
     $playerB = new Player('Player B');
     $playerC = new Player('Player C');
     $playerD = new Player('Player D');
     // 4 players.
     $playerInstances = [$playerA, $playerB, $playerC, $playerD];
     $game = new Game($playerInstances);
     $game->start();
 }
 public function start(Player $player1, Player $player2, $loops)
 {
     for ($i = 1; $i <= $loops; $i++) {
         $game = new Game(new Board(), $player1, $player2);
         $winner = $game->start();
         if ($winner instanceof Player) {
             $this->results['wins'][$winner->getName()]++;
         } else {
             $this->results['undecided']++;
         }
     }
     return $this->getWinner();
 }
Example #3
0
<?php

//magincza fukcja autoloadera
//
function __autoload($file)
{
    include __DIR__ . DIRECTORY_SEPARATOR . $file . '.php';
}
if (!$_GET) {
    ?>

 Rejestracja
        <form action="index.php" method="GET">
            <input type="hidden" name="strona" value="rejestracja">
            <input type="submit"  value="rejestracja"/>
        </form>
        Logowanie
        <form action="index.php" method="GET">
            <input type="hidden" name="strona" value="logowanie">
            <input type="submit"  value="logowanie"/>
        </form>
<?php 
}
$game = new Game();
$game->start();
Example #4
0
<?php

define("GAME", true);
require_once "game/game.php";
$game = new Game();
$game->start(function () use($game) {
    $game->stop();
});
Example #5
0
    test_token();
    try {
        $player_ids = $Game->invite();
        // send the messages
        $message = 'You have been invited to join the game "' . htmlentities($Game->name, ENT_QUOTES, 'UTF-8', false) . '".' . "\n\n" . 'If you wish to play in this game, please join it from the home page.';
        $message .= "\n\n==== Message ===========================================\n\n" . htmlentities($_POST['extra_text'], ENT_QUOTES, 'UTF-8', false);
        $Message->send_message('Invitation to "' . htmlentities($Game->name, ENT_QUOTES, 'UTF-8', false) . '"', $message, $player_ids, false, ldate('m/d/Y', strtotime('1 week')));
        Flash::store('Game Invitations Sent Successfully');
    } catch (MyException $e) {
        Flash::store('Game Invite FAILED !');
    }
}
if (isset($_POST['start'])) {
    test_token();
    try {
        $Game->start((int) $_POST['player_id']);
        Flash::store('Game Started Successfully', 'game.php?id=' . $_POST['game_id']);
    } catch (MyException $e) {
        Flash::store('Game Start FAILED !', true);
    }
}
// test if we are already in this game or not
$joined = $Game->is_player($_SESSION['player_id']);
$color_selection = '';
foreach ($Game->get_avail_colors() as $color) {
    $color_selection .= '<option class="' . strtolower(substr($color, 0, 3)) . '">' . ucfirst($color) . '</option>';
}
$password_box = '';
if ('' != $Game->passhash) {
    $password_box = '<li><label for="password">Password</label><input type="password" id="password" name="password" /></li>';
}