Example #1
0
 public function View()
 {
     if (isset($_SESSION['dicehand'])) {
         $hand = $_SESSION['dicehand'];
     } else {
         $hand = new CDiceHand(1);
         $_SESSION['dicehand'] = $hand;
     }
     // Get the arguments from the query string
     $roll = isset($_GET['roll']) ? true : false;
     $init = isset($_GET['init']) ? true : false;
     $save = isset($_GET['save']) ? true : false;
     $destroy = isset($_GET['destroy']) ? true : false;
     /** Roll the dice **/
     if ($roll) {
         $hand->Roll();
     } else {
         if ($init) {
             $hand->initRound();
         } else {
             if ($save) {
                 $hand->saveRound();
             } else {
                 if ($destroy) {
                     if (isset($_GET['destroy'])) {
                         // Unset all of the session variables.
                         $_SESSION = array();
                     }
                     // Finally, destroy the session.
                     session_destroy();
                     echo " Sessionen raderas, <a href='?'>klicka här för att spela igen</a>";
                     exit;
                 }
             }
         }
     }
     $html = '<div>';
     // Display game points for player
     if ($roll or $save) {
         $html .= $hand->infoWinner();
         $html .= $hand->GetRollsAsImageList();
         $html .= "<p>Poäng denna runda: " . $hand->GetRoundtotal() . "</p>";
         $html .= $hand->infoLose();
         $html .= "<p>Dina sparade poäng: " . $hand->GetTotalScore() . "</p></div>";
     } else {
         $html .= $hand->GetRollsAsImageList();
         $html .= "<p>Kasta tärningen för att börja spela!</p></div>";
     }
     return $html;
 }
Example #2
0
File: dice.php Project: frsd1/bth
        $_SESSION['bay']++;
    }
} else {
    $_SESSION['bay'] = 0;
}
if (isset($_GET['reset'])) {
    $_SESSION['bay'] = 0;
}
//echo "<p>Allt innehåll i arrayen \$_SESSION:<br><pre>" . htmlentities(print_r($_SESSION, 1)) . "</pre>";
//echo "<p>Allt innehåll i arrayen \$_SESSION:<br><pre>" ;
echo "-----" . $_SESSION['count'] . "--------";
echo "-----" . $_SESSION['bay'] . "--------";
?>

<p><?php 
echo $hand->GetRollsAsImageList();
?>
</p>

<?php 
if ($roll) {
    ?>
<p>Summan av detta kast blev <?php 
    echo $hand->GetTotal();
    ?>
.
<?php 
}
if ($test) {
    ?>
 Summan av detta kast blev <?php