Advertisement
here2share

# five_dice.py

Jul 4th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. # five_dice.py
  2.  
  3. import time
  4. import os
  5. import random
  6.  
  7. number_of_dice = 5
  8. matches = { 3: 'Three', 4: 'Four', 5: 'Five' }
  9.  
  10. def do_roll():
  11.     pts = 0
  12.     print "\nRolling..."
  13.     time.sleep(1)
  14.     os.system("cls")
  15.     dices = number_of_dice-len(rolls)
  16.     if rolls:
  17.         print "Dices Locked In:", rolls
  18.     for r in range(dices):
  19.         rolls.append(random.randint(1,6))
  20.     print rolls
  21.     print "Multiplier = x"+str(multiplier)
  22.     print
  23.     for roll in set(rolls):
  24.         try:
  25.             c = rolls.count(roll)
  26.             s = matches[c]
  27.             bonus = 100
  28.             if roll is 1:
  29.                 bonus = 1000
  30.             pts = roll*c*bonus
  31.             print "You Got", s, "Of A Kind!"
  32.         except:
  33.             0
  34.     rolls.sort()
  35.     if list(rolls) in (range(1,6),range(2,7)):
  36.         pts = 12000
  37.         print pts, "Potential Points Having Rolled A Straight!"
  38.     print "Overall Potential:", pts+points
  39.     print "Current Score:", score
  40.     return pts
  41. 0
  42.  
  43. while 1:
  44.     os.system("cls")
  45.     print "*** Welcome To 5 Dice! ***"
  46.     score = 0
  47.     for chances in range(10,1,-1):
  48.         multiplier = (10-chances)/2+1
  49.         points = 0
  50.         while 1:
  51.             print "\nSafe Roll With", chances, "Rounds Remaining..."
  52.             raw_input("Press ENTER To Roll ")
  53.             rolls = []
  54.             bonus = do_roll()
  55.             if not bonus:
  56.                 print "No Points Found, However...", points, "Points Plus"
  57.             bonus = 2500
  58.             print "A Bonus Of", bonus, "Points, Both x"+str(multiplier)
  59.             print "If You Choose To Lock These Points."
  60.             print chances, "Rounds Remaining..."
  61.             choice = raw_input("Lock These Points? ")
  62.             if choice.lower().startswith("y"):
  63.                 score = score+(points*multiplier)+bonus
  64.                 print "\nCurrent Score:", score
  65.                 break
  66.             else:
  67.                 risk = 0
  68.                 if choice:
  69.                     if choice[0].isdigit():
  70.                         risk = choice
  71.                 if not risk:
  72.                     risk = raw_input("Select Which Dice To Roll Again: ")
  73.                 if ' ' in risk:
  74.                     risk = risk.split(' ')
  75.                 else:
  76.                     risk = list(risk)
  77.                 print risk
  78.                 for r in list(risk):
  79.                     try:
  80.                         rolls.remove(int(r))
  81.                     except:
  82.                         0
  83.                 bonus = do_roll()
  84.                 points += bonus
  85.                 if bonus:
  86.                     print "Great Call... You May Now Lock", points, "To Your Score"
  87.                 else:
  88.                     print "Hah... Zero Points This Round!"
  89.                     break
  90.     print "Game Over!\n"
  91.     print "TOTAL SCORE:", score
  92.     choice = raw_input("Would You Like To Play Again? Y/N: ")
  93.     if choice.lower().startswith("n"):
  94.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement