Getting Type error
This commit is contained in:
parent
9aa6b06c24
commit
2c16341658
|
@ -21,20 +21,18 @@ SYMBOL_VALUE = {
|
|||
"D": 2
|
||||
}
|
||||
|
||||
|
||||
|
||||
def check_winings(columns, bet, lines, values):
|
||||
def check_winings(columns: List, my_bet: int, my_lines: int):
|
||||
winnings = 0
|
||||
winning_lines = []
|
||||
for line in range(lines):
|
||||
for line in range(my_lines):
|
||||
symbol = columns[0][line]
|
||||
for column in columns:
|
||||
symbol_to_check = column[line]
|
||||
if symbol != symbol_to_check:
|
||||
break
|
||||
else:
|
||||
winnings += values[symbol] * bet
|
||||
winning_lines.append( +1)
|
||||
winnings += SYMBOL_VALUE[symbol] * my_bet
|
||||
winning_lines.append(line + 1)
|
||||
|
||||
return winnings, winning_lines
|
||||
|
||||
|
@ -102,7 +100,7 @@ def get_bet() -> int:
|
|||
print(" Error: Please enter a number")
|
||||
return bet
|
||||
|
||||
def main():
|
||||
def roll():
|
||||
balance = deposit()
|
||||
lines = get_number_of_lines()
|
||||
bet = -1
|
||||
|
@ -119,9 +117,27 @@ def main():
|
|||
|
||||
slots = get_slot_machine_spin()
|
||||
print_slotmachine(slots)
|
||||
winnings, winning_lines = check_winings(slots, lines, bet, SYMBOL_VALUE)
|
||||
winnings, winning_lines = check_winings(slots, bet, lines)
|
||||
print(f"You won ${winnings}.")
|
||||
print(f"You won on lines:", *winning_lines)
|
||||
if len(winning_lines) > 0:
|
||||
print(f"You won on line" + ("s" if len(winning_lines) > 1 else "") + ":", *winning_lines)
|
||||
balance += winnings
|
||||
else:
|
||||
balance -= bet * lines
|
||||
print(f"Your balance is now: ${balance}")
|
||||
return winnings - total_bet
|
||||
|
||||
def main() -> int:
|
||||
balance = deposit()
|
||||
while True:
|
||||
print(f"Current Balance is ${balance}")
|
||||
answer = input("Press enter to play (q to quit).")
|
||||
if answer == "q":
|
||||
break
|
||||
balance += roll(balance)
|
||||
|
||||
print(f"YOu left with ${balance}")
|
||||
|
||||
main()
|
||||
print()
|
||||
print("Thank you for playing!")
|
Loading…
Reference in New Issue
Block a user