<html>
<head>
<title>Dice-A-Roo!</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
function roll(){
var level = 1;
var living = 1;
output = document.getElementById("output");
game = document.getElementById("game");
var pot = 0;
function checkPot(){
if (pot < 0) {
living = Math.ceil(Math.random() * 2);
if (living == 1) {
pot = 0;
output.innerHTML += "<br \/> It looks like your pot went below 0, but don't worry, you're still alive! Aren't you lucky?";
output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
}//end living
else {
output.innerHTML += "<br \/> <span class='lose'>Oh dear! Your pot went below zero and you lost!!!<\/span>";
game.innerHTML = "<form action=''><button type='button' onclick='javascript:location.reload(true)' class='lose_button'>Play Again?!<\/button><\/form>";
}//end else
}//end if pot is less than 0
}
if (level == 1) {
function rollOne(){
var die = Math.ceil(Math.random() * 6);
if (die == 1){
pot++;
output.innerHTML = "<h2>Small Win<\/h2>Congrats! You gained 1 in your pot!";
output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.</span>";
}
if (die == 2){
pot += 2;
output.innerHTML = "<h2>Medium Win<\/h2>Congrats! You gained 2 in your pot!";
output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.</span>";
}
if (die == 3){
pot -= 2;
output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
checkPot();
}
if (die == 4){
var check = Math.ceil(Math.random() * 4);
if (check == 1) {
pot += 5;
output.innerHTML = "<h2>Super Die!<\/h2>Wow! You gained 5 in your pot!";
output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
}
else {
pot += 1;
output.innerHTML = "<h2>Small Win<\/h2>Congrats! You gained 1 in your pot!";
output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
}
}
if (die == 5){
pot -= 2;
output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
checkPot();
}
if (die == 6){
pot -= 2;
output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
checkPot();
}
}//end rollOne
rollOne();
}//end level 1
if (level == 2) {
function rollTwo(){
var die = Math.ceil(Math.random() * 6);
alert(die);
}//end rollTwo
rollTwo();
}
if (level == 3) {
function rollThree(){
var die = Math.ceil(Math.random() * 6);
alert(die);
}//end rollThree
rollThree();
}
if (level == 4) {
function rollFour(){
var die = Math.ceil(Math.random() * 6);
alert(die);
}//end rollFour
rollFour();
}
if (level == 5) {
function rollFive(){
var die = Math.ceil(Math.random() * 6);
alert(die);
}//end rollThree
rollFive();
}
}
//]>
</script>
</head><!--End of Head-->
<body>
<div>
<h1>Dice-A-Roo!</h1>
<img src="http://images.neopets.com/games/dice/kingroo.gif" />
<form action="" id="game">
<button type="button" onclick="roll()">Roll!</button>
</form>
<div id="output"></div>
</div>
</body><!--End of Body-->
</html>