How To Make A Slot Machine Game In Python
03/02/2021
So, I am currently working on a project called Henry's Palace (after Caesars Palace in Las Vegas) on Python. What was a simple dice game to teach m how to code probability has ballooned into 800 lines of code. recently, I added a huge extension, the slot machine. As I had trouble doing this I will show you my personal code for copy and pasting. You'll have to add spaces yourself.
sym1 = random.choice(symbols)
sym2 = random.choice(symbols)
sym3 = random.choice(symbols)
print("---Symbols---")
print(sym1, sym2, sym3, "\n")
if (sym1 == sym2 or sym1 == sym3 or sym2 == sym3) and not(sym1 == sym2 == sym3):
print("Winner! +5p")
credit += 45
return credit
elif (sym1 == sym2 == sym3) and sym1 != "Bell":
print("Winner! +£50")
credit = credit + 50
return credit
elif (sym1 == sym2 == sym3) and (sym1 == "Bell"):
print("Jackpot! +£15")
credit = credit + 50
return credit
elif (sym1 == sym2 == "Skull" or sym1 == sym3 == "Skull" or sym2 == sym3 == "Skull") and not(sym1 == sym2 == sym3):
print("Two Skulls! -£75")
credit = credit - 100
return credit
elif (sym1 == sym2 == sym3) and sym1 == "Skull":
print("Three Skulls! Lose all credit")
credit = 0
return credit
else:
print("Loser! -£20")
credit = - 20
return credit
symbols = ["Cherry", "Bell", "Lemon", "Orange", "Star", "Skull"]
print("You have", credit, "p", "\n")
#moneydrinker function
def moneydrinker(credit):
while True:
print("")
play = input("Roll costs 10p. Would you like to roll? yes/no: ")
print("")
if play == "yes" or "y" or "Yes" or "Y":
if credit >= 20:
credit=roll(credit)
credit -= 10
print("Credit is", credit, "p")
if credit < 20:
print ("You need more points! Time to go home,right?")
else:
print("You do not enough money to roll!")
if intro==1:
Comments