Python Forum
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Poker Dice while loop
#1
I am not sure why my while loop is broken, any help would be greatly appreciated.


#This program will simulate a poker dice game.
import random
import time
def isEven(number):
    if (number % 2 == 0):
    	return True
    else:
        return False
def isOdd(number):
    if (number % 2 == 1):
    	return True
    else:
        return False
pts = 0
a = 0
print("---Poker Dice---\nWelcome User! This is Poker Dice, three dice will be thrown and score points:\nThree of a Kind = +50 pts, Straight = +30 pts, Three Odd Numbers = +15 pts,\nThree Even Numbers = +15 pts, One Pair = +10 pts.")

while a == 0:
    d1 = random.randint(1,6)
    d2 = random.randint(1,6)
    d3 = random.randint(1,6)
    print("The first die rolled", d1)
    print("The second die rolled",d2)
    print("The third die rolled",d3)
    if d1 == d2 and d1 == d3:
        print("All three dice match which means +50 pts!")
        pts += 50
    if d1==(d2+1) and d1==d3+2:
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    elif d1==(d3+1) and d1==d2+2:	    
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    elif d2==(d3+1) and d2==d1+2:	    
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    elif d2==(d1+1) and d2==d3+2:	    
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    elif d3==(d1+1) and d3==d2+2:	    
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    elif d3==(d2+1) and d3==d1+2:	    
        pts += 30
        print("Wow, you just rolled a straight which means +30 pts!")
    if isEven(d1) and isEven(d2) and isEven(d3):
        pts += 15
        print("You just rolled three even numbers! Which means +15 pts!")
    if isOdd(d1) and isOdd(d2) and isOdd(d3):
        pts += 15
        print("You just rolled three odd numbers! Which means +15 pts!")
    if d1 == d2 or d1 == d3 or d2 == d1 or d2 == d3 or d3 == d1 or d3 == d2:
        pts += 10
        print("Two of the dice match, which means +10 pts!")

    print("Overall you scored", pts,"points!")
    fa = input("Would you like to re-roll your dice? Type 'yes' to re-roll or type 'no' to go home safe with your current points.\n").lower()
    if fa == 'yes' or 'y':
        print("Wow, you are brave!")
        pts = 0
    else:
        print("Fine then, we hope to see you again soon! Goodbye.")
        a += 1
        time.sleep(3)
        quit()
        
Reply


Messages In This Thread
Poker Dice while loop - by gullidog - May-28-2017, 07:48 PM
RE: Poker Dice while loop - by ichabod801 - May-28-2017, 08:03 PM
RE: Poker Dice while loop - by gullidog - May-28-2017, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  While loop not ending (Best of 10 dice game) K3nidi 3 1,507 Jul-09-2022, 09:53 AM
Last Post: K3nidi
  Hi! + Poker calculator SpookyKooks 2 2,177 Mar-12-2020, 05:32 AM
Last Post: SpookyKooks
  Similar to Poker bluekade5050 1 32,713 Nov-14-2018, 04:46 PM
Last Post: j.crater
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,519 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 3,248 Sep-30-2018, 12:18 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020