Share Pastebin
Guest
Public paste!

Sawyer

By: a guest | Mar 21st, 2010 | Syntax: JavaScript | Size: 3.73 KB | Hits: 59 | Expires: Never
Copy text to clipboard
  1. <html>
  2. <head>
  3.         <title>Dice-A-Roo!</title>
  4.         <link href="style.css" rel="stylesheet" type="text/css" />
  5.         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  6.         <script type="text/javascript">
  7.                 //<![CDATA[
  8.                
  9.                 function roll(){
  10.                         var level = 1;
  11.                         var living = 1;
  12.                         output = document.getElementById("output");
  13.                         game = document.getElementById("game");
  14.                         var pot = 0;
  15.                        
  16.                         function checkPot(){
  17.                                 if (pot < 0) {
  18.                                         living = Math.ceil(Math.random() * 2);
  19.                                         if (living == 1) {
  20.                                                 pot = 0;
  21.                                                 output.innerHTML += "<br \/> It looks like your pot went below 0, but don't worry, you're still alive! Aren't you lucky?";
  22.                                                 output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
  23.                                         }//end living
  24.                                         else {
  25.                                                 output.innerHTML += "<br \/> <span class='lose'>Oh dear! Your pot went below zero and you lost!!!<\/span>";
  26.                                                 game.innerHTML = "<form action=''><button type='button' onclick='javascript:location.reload(true)' class='lose_button'>Play Again?!<\/button><\/form>";
  27.                                         }//end else
  28.                                 }//end if pot is less than 0
  29.                         }
  30.                                 if (level == 1) {
  31.                                         function rollOne(){
  32.                                                 var die = Math.ceil(Math.random() * 6);
  33.                                                         if (die == 1){
  34.                                                                 pot++;
  35.                                                                 output.innerHTML = "<h2>Small Win<\/h2>Congrats! You gained 1 in your pot!";
  36.                                                                 output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.</span>";
  37.                                                         }
  38.                                                         if (die == 2){
  39.                                                                 pot += 2;
  40.                                                                 output.innerHTML = "<h2>Medium Win<\/h2>Congrats! You gained 2 in your pot!";
  41.                                                                 output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.</span>";
  42.                                                         }
  43.                                                         if (die == 3){
  44.                                                                 pot -= 2;
  45.                                                                 output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
  46.                                                                 checkPot();
  47.                                                         }
  48.                                                         if (die == 4){
  49.                                                                 var check = Math.ceil(Math.random() * 4);
  50.                                                                 if (check == 1) {
  51.                                                                         pot += 5;
  52.                                                                         output.innerHTML = "<h2>Super Die!<\/h2>Wow! You gained 5 in your pot!";
  53.                                                                         output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
  54.                                                                 }
  55.                                                                 else {
  56.                                                                         pot += 1;
  57.                                                                         output.innerHTML = "<h2>Small Win<\/h2>Congrats! You gained 1 in your pot!";
  58.                                                                         output.innerHTML += "<br \/> <span>You now have " + pot + " points in your pot.<\/span>";
  59.                                                                 }
  60.                                                                
  61.                                                         }
  62.                                                         if (die == 5){
  63.                                                                 pot -= 2;
  64.                                                                 output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
  65.                                                                 checkPot();
  66.                                                         }
  67.                                                         if (die == 6){
  68.                                                                 pot -= 2;
  69.                                                                 output.innerHTML = "<h2>Evil Die!<\/h2>Oh no! You lost 2 from your pot!";
  70.                                                                 checkPot();
  71.                                                         }
  72.                                         }//end rollOne
  73.                                         rollOne();
  74.                                 }//end level 1
  75.                                 if (level == 2) {
  76.                                         function rollTwo(){
  77.                                                 var die = Math.ceil(Math.random() * 6);
  78.                                                 alert(die);
  79.                                         }//end rollTwo
  80.                                         rollTwo();
  81.                                 }
  82.                                 if (level == 3) {
  83.                                         function rollThree(){
  84.                                                 var die = Math.ceil(Math.random() * 6);
  85.                                                 alert(die);
  86.                                         }//end rollThree
  87.                                         rollThree();
  88.                                 }
  89.                                 if (level == 4) {
  90.                                         function rollFour(){
  91.                                                 var die = Math.ceil(Math.random() * 6);
  92.                                                 alert(die);
  93.                                         }//end rollFour
  94.                                         rollFour();
  95.                                 }
  96.                                 if (level == 5) {
  97.                                         function rollFive(){
  98.                                                 var die = Math.ceil(Math.random() * 6);
  99.                                                 alert(die);
  100.                                         }//end rollThree
  101.                                         rollFive();
  102.                                 }
  103.                 }
  104.                 //]>
  105.         </script>
  106. </head><!--End of Head-->
  107.  
  108. <body>
  109.         <div>
  110.                 <h1>Dice-A-Roo!</h1>
  111.                 <img src="http://images.neopets.com/games/dice/kingroo.gif" />
  112.        
  113.                 <form action="" id="game">
  114.                         <button type="button" onclick="roll()">Roll!</button>
  115.                 </form>
  116.        
  117.                 <div id="output"></div>
  118.         </div>
  119.        
  120. </body><!--End of Body-->
  121. </html>