Advertisement
Guest User

duh code is real ek dee

a guest
Oct 2nd, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. object CrapsVersionFinal extends App {
  2. println("This is the Craps game. In order to win you must roll either a 7 or 11 on your first roll.")
  3. println("If you roll a 2 first you lose. Anything else and you roll again.")
  4. println("On any more rolls you undertake, you must roll the same number as the first roll to win.")
  5. println("If you roll a 7 you lose. Anything else and you re-roll. Repeat ad-infinitum.")
  6. println("Press enter to begin.")
  7. var Cheater = readLine();
  8. println();
  9. var RepeatGame = false
  10. var Wins = 0
  11. var Losses = 0
  12. var number = 6
  13. var Cheats = false
  14. def printWandL()    {
  15.   println("Total Wins: "+Wins+"")
  16.   println("Total Losses: "+Losses+"")
  17. }
  18. def DiceRoll():Long = {
  19.   var Roll = Math.round(Math.random()*number)
  20.   if (Cheats == false)  {
  21.       if (Roll == 0)    {
  22.           var IsZero = true
  23.           while (IsZero == true)    {
  24.               Roll = Math.round(Math.random()*number)
  25.               if (Roll != 0)    {
  26.                 IsZero = false
  27.                 return Roll
  28.               }
  29.           }
  30.         }
  31.       else  {
  32.         return Roll
  33.       }
  34.   }
  35.   return 1
  36. }
  37. if (Cheater.equalsIgnoreCase("I want to be a winner"))  {
  38.   var Cheats = true
  39.   Wins = 1337
  40.   Losses = 0
  41.   do    {
  42.       printWandL();
  43.       var Total = 7
  44.       Wins += 1
  45.       println("You rolled a 3 and a 4. Your total is 7, therefore you win!")
  46.       println("Play again? Y/N.")
  47.       var Response = readLine();
  48.       if (Response.equalsIgnoreCase("Yes")  || Response.equalsIgnoreCase("Y")   || Response.equalsIgnoreCase("Yes."))   {
  49.         Cheats = true
  50.         println("Press enter to roll again.")
  51.         readLine();
  52.       }
  53.       else  {
  54.         Cheats = false
  55.         println("Game terminated. You sure are a winner.")
  56.         printWandL();
  57.         var exit = true
  58.         while(exit == true) {        
  59.         }
  60.       }
  61.   }
  62.   while (Cheats == true)
  63. }
  64. else    {
  65. }
  66. do {
  67.     printWandL();
  68.     var resultRollOne = DiceRoll();
  69.     var resultRollTwo = DiceRoll();
  70.     var Total = resultRollOne + resultRollTwo
  71.     var StoredTotal = Total
  72.     if (Total == 7 || Total == 11)  {
  73.         Wins += 1
  74.         println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you win.")
  75.         println("Play again? Y/N.")
  76.         var Response = readLine();
  77.         if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes")) {
  78.           RepeatGame = true
  79.         }
  80.         else    {
  81.           println("Game terminated. Have a nice day.")
  82.           printWandL();
  83.           RepeatGame = false
  84.         }
  85.     }
  86.     else if (Total == 2)    {
  87.       Losses += 1
  88.       println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you lose.")
  89.       println("Play again? Y/N.")
  90.       var Response = readLine();
  91.         if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes")) {
  92.             RepeatGame = true
  93.         }
  94.       else  {
  95.             println("Game terminated. Have a nice day.")
  96.             printWandL();
  97.             RepeatGame = false
  98.       }
  99.     }
  100.     else    {
  101.       var RepeatGameTwo = true
  102.       println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", which results in no win nor penalty.")
  103.       do    {
  104.           println("Press enter to roll again.")
  105.           readLine();
  106.           resultRollOne = DiceRoll();
  107.           resultRollTwo = DiceRoll();
  108.           Total = resultRollOne + resultRollTwo
  109.           if (StoredTotal == Total) {
  110.               Wins += 1
  111.               println("You rolled a "+resultRollOne+" and a "+resultRollTwo+".")
  112.               println("Your second roll was the same as the first ("+Total+"), therefore you win.")
  113.               println("Play again? Y/N.")
  114.               var Response = readLine();
  115.               if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))   {
  116.                   RepeatGame = true
  117.                   RepeatGameTwo = false
  118.         }
  119.               else  {
  120.                   println("Game terminated. Have a nice day.")
  121.                   printWandL();
  122.                   RepeatGame = false
  123.                   RepeatGameTwo = false
  124.               }
  125.           }
  126.           else if (Total == 7)  {
  127.               Losses += 1
  128.               println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you lose.")
  129.               println("Play again? Y/N.")
  130.               var Response = readLine();
  131.               if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))   {
  132.                   RepeatGame = true
  133.                   RepeatGameTwo = false
  134.               }
  135.               else  {
  136.                   println("Game terminated. Have a nice day.")
  137.                   printWandL();
  138.                   RepeatGame = false
  139.                   RepeatGameTwo = false
  140.               }
  141.           }
  142.           else  {
  143.               println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", which results in no win nor penalty.")
  144.       }
  145.       }
  146.       while (RepeatGameTwo == true)
  147. }
  148. }
  149. while (RepeatGame == true)
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement