Documentos de Académico
Documentos de Profesional
Documentos de Cultura
TOTAL_CASILLAS = 10
MATCHES = []
INDEX = 0
CONTINUE = True
# MATCH VARIABLES
CURRENT_CASILLA = 0
TIRADAS_TOTALES = 0
LAST_DADO_RESULT = 0
def incrementIndex():
global INDEX
INDEX += 1
def incrementTirada():
global TIRADAS_TOTALES
TIRADAS_TOTALES += 1
class Match:
# Clase objeto de una partida
def getTiradas(match):
return match.tiradasTotales
def preguntarCasillas():
global TOTAL_CASILLAS
tempCasillas = input("Cuantas casillas (10 a 100): ")
if not tempCasillas.isnumeric():
printError("No has escrito un numero entre 10 y 100.")
preguntarCasillas()
return
TOTAL_CASILLAS = int(tempCasillas)
def finish():
global TIRADAS_TOTALES, INDEX, LAST_DADO_RESULT, CURRENT_CASILLA
print("He ganado con " + str(TIRADAS_TOTALES) + " tiradas de dado.")
match = Match(INDEX, TIRADAS_TOTALES)
MATCHES.append(match)
questNext()
def processThrow(int):
global CURRENT_CASILLA, TOTAL_CASILLAS, LAST_DADO_RESULT
FINAL_CASILLA = CURRENT_CASILLA + int
oca = False
LAST_DADO_RESULT = int
CURRENT_CASILLA = FINAL_CASILLA
sendCurrentCasillaMessage(int, oca)
checkFinish(FINAL_CASILLA, TOTAL_CASILLAS)
def throwDado():
incrementTirada()
randomDado = randint(1, 6)
processThrow(randomDado)
def questNext():
global CONTINUE
cont = input("¿Quieres jugar otra? (s/n): ")
if str(cont) == "n":
CONTINUE = False
elif str(cont) == "s":
CONTINUE = True
else:
questNext()
def startMatch():
global CURRENT_CASILLA, TOTAL_CASILLAS, TIRADAS_TOTALES,
LAST_DADO_RESULT
incrementIndex()
print("EMPIEZA PARTIDA " + str(INDEX))
print("Estoy en la casilla 0")
while not CURRENT_CASILLA >= TOTAL_CASILLAS:
throwDado()
CURRENT_CASILLA = 0
TIRADAS_TOTALES = 0
LAST_DADO_RESULT = 0
def printError(msg):
print("ERROR: " + msg)
preguntarCasillas()
while CONTINUE:
startMatch()
MATCHES.sort(key=getTiradas)
bestMatch = MATCHES[0]
print("*** Mejor partida: la " + str(bestMatch.index) + ", con solo " + str(bestMatch.tiradasTotales)
+ " tiradas de dado ***")