# -*- coding: utf-8 -*-
import random
import time
#import os
print('''Bienvenido a la máquina tragamonedas
Comenzarás con $1000. Se te preguntará si quieres jugar.
Responda con sí / no. también puedes usar s / n
No hay distinción entre mayúsculas y minúsculas, escríbala como desee.
Para ganar debes obtener una de las siguientes combinaciones:
BAR --\t BAR --\t BAR --\tGanas\t$2000
CAMPANA--\tCAMPANA--\tCAMPANA/BAR--\tGanas\t$500
CIRUELA--\tCIRUELA--\tCIRUELA/BAR--\tGanas\t$400
NARANJA--\tNARANJA--\tNARANJA/BAR--\tGanas\t$300
LIMÓN --\tLIMÓN --\tLIMÓN --\tGanas\t$200
CEREZA--\tCEREZA --\tCEREZA --\tGanas\t$100
CEREZA--\t --\t --\tGanas\t$50
7 --\t 7 --\t 7 --\tGanas\tEl premio mayor!
''')
time.sleep(1)
SaldoJugador = 500
PremioMayor= 10000
ITEMS = ["CEREZA", "LIMÓN", "NARANJA", "CIRUELA", "CAMPANA", "BAR", "7"]
Rueda1 = None
Rueda2 = None
Rueda3 = None
Saldo = SaldoJugador
Premio = PremioMayor
def jugar():
global SaldoJugador, Rueda1, Rueda2, Rueda3
Pregunta = Preguntar()
while(SaldoJugador != 0 and Pregunta == True):
Rueda1 = JirarRueda()
Rueda2 = JirarRueda()
Rueda3 = JirarRueda()
Marcador()
Pregunta = Preguntar()
def Preguntar():
'''
#Pregunta al jugador si quiere volver a jugar.
esperando que el usuario responda sí, s, no o n
Sin mayúsculas y minúsculas en la respuesta. Sí, sI, S, N, nO. . .
'''
global SaldoJugador
global PremioMayor
while(True):
# os.system('cls' if os.name == 'nt' else 'clear')
if (PremioMayor <=1):
print ("Restablecimiento del equilibrio de la máquina.")
PremioMayor = 10000
print("El Premio mayor es actualmente: $" + str(PremioMayor) + ".")
Resp = raw_input("¿Quisieras jugar? ¿O quieres comprobar tu dinero? ")
Resp = Resp.lower()
if(Resp == "si" or Resp == "s"):
return True
elif(Resp == "no" or Resp == "n"):
print("Terminaste el juego con $" + str(PremioMayor) + " en tu mano. ¡Gran trabajo!")
time.sleep(2)
return False
elif(Resp == "comprobar" or Resp == "COMPROBAR"):
print ("Actualmente tienes $" + str(SaldoJugador) + ".")
else:
print("Uuups! No entendí eso.")
def JirarRueda():
# devuelve un elemento aleatorio de la rueda
NumAl = random.randint(0, 6)
return ITEMS[NumAl]
def Marcador():
#imprime el puntaje actual
global SaldoJugador, Rueda1, Rueda2, Rueda3, PremioMayor
if((Rueda1 == "CEREZA") and (Rueda2 != "CEREZA")):
Gano = 50
PremioMayor = PremioMayor - 50
elif((Rueda1 == "CEREZA") and (Rueda2 == "CEREZA") and (Rueda3 == "CEREZA")):
Gano = 100
PremioMayor = PremioMayor- 100
elif((Rueda1 == "LIMÓN") and (Rueda2 == "LIMÓN") and (Rueda3 == "LIMÓN")):
Gano = 200
PremioMayor = PremioMayor - 200
elif((Rueda1 == "NARANJA") and (Rueda2 == "NARANJA") and ((Rueda3 == "NARANJA") or (Rueda3 == "BAR"))):
Gano = 300
PremioMayor = PremioMayor - 300
elif((Rueda1 == "CIRUELA") and (Rueda2 == "CIRUELA") and ((Rueda3 == "CIRUELA") or (Rueda3 == "BAR"))):
Gano = 400
PremioMayor = PremioMayor - 400
elif((Rueda1 == "CAMPANA") and (Rueda2 == "CAMPANA") and ((Rueda3 == "CAMPANA") or (Rueda3 == "BAR"))):
Gano = 500
PremioMayor = PremioMayor - 500
elif((Rueda1 == "BAR") and (Rueda2 == "BAR") and (Rueda3 == "BAR")):
Gano = 2000
PremioMayor = PremioMayor - 2000
elif((Rueda1 == "7") and (Rueda2 == "7") and (Rueda3 == "7")):
Gano = PremioMayor
PremioMayor = PremioMayor - Gano
else:
Gano = -1
PremioMayor = PremioMayor + 1
SaldoJugador = SaldoJugador + Gano
if Gano == Premio:
print ("Ganaste el PREMIO MAYOR!!")
if(Gano > 0):
print(Rueda1 + '\t' + Rueda2 + '\t' + Rueda3 + ' -- Ganaste $' + str(Gano))
time.sleep(2)
# os.system('cls' if os.name == 'nt' else 'clear')
else:
print(Rueda1 + '\t' + Rueda2 + '\t' + Rueda3 + ' -- Perdiste')
time.sleep(2)
# os.system('cls' if os.name == 'nt' else 'clear')
jugar()