Example #1
0
File: dice.php Project: frsd1/bth
// Get the arguments from the query string
$roll = isset($_GET['roll']) ? true : false;
$test = isset($_GET['test']) ? true : false;
$init = isset($_GET['init']) ? true : false;
// Create the object or get it from the session
if (isset($_SESSION['dicehand'])) {
    echo "<i>Objektet finns redan i sessionen</i>";
    $hand = $_SESSION['dicehand'];
} else {
    echo "<i>Objektet finns inte i sessionen, skapar nytt objekt och lagrar det i sessionen</i>";
    $hand = new CDiceHand(1);
    $_SESSION['dicehand'] = $hand;
}
// Roll the dices
if ($test) {
    $hand->InitRound();
    $hand->Roll();
}
// Roll the dices
if ($roll) {
    $hand->Roll();
} else {
    if ($init) {
        $hand->InitRound();
    }
}
if (isset($_SESSION['bay'])) {
    $bay = $_SESSION['bay'];
    if ($bay == "start") {
        echo "<p><a href='?roll'>xxxxNyttxxx kast</a>.</p>";
    }