-
-
Save parzibyte/a1aa43ba8b40f5f05ac87a0dabeca7f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jugar(): | |
disparos_restantes_j1 = DISPAROS_INICIALES | |
disparos_restantes_j2 = DISPAROS_INICIALES | |
cantidad_barcos = 5 | |
matriz_j1, matriz_j2 = obtener_matriz_inicial(), obtener_matriz_inicial() | |
matriz_j1 = colocar_e_imprimir_barcos( | |
matriz_j1, cantidad_barcos, JUGADOR_1) | |
matriz_j2 = colocar_e_imprimir_barcos( | |
matriz_j2, cantidad_barcos, JUGADOR_2) | |
turno_actual = JUGADOR_1 | |
print("===============") | |
while True: | |
print(f"Turno de {turno_actual}") | |
disparos_restantes = disparos_restantes_j2 | |
if turno_actual == JUGADOR_1: | |
disparos_restantes = disparos_restantes_j1 | |
imprimir_disparos_restantes(disparos_restantes, turno_actual) | |
matriz_oponente = matriz_j1 | |
if turno_actual == JUGADOR_1: | |
matriz_oponente = matriz_j2 | |
imprimir_matriz(matriz_oponente, False, | |
oponente_de_jugador(turno_actual)) | |
x, y = solicitar_coordenadas(turno_actual) | |
acertado = disparar(x, y, matriz_oponente) | |
if turno_actual == JUGADOR_1: | |
disparos_restantes_j1 -= 1 | |
else: | |
disparos_restantes_j2 -= 1 | |
imprimir_matriz(matriz_oponente, False, | |
oponente_de_jugador(turno_actual)) | |
if acertado: | |
print("Disparo acertado") | |
reproducir_sonido_acertado() | |
if todos_los_barcos_hundidos(matriz_oponente): | |
indicar_victoria(turno_actual) | |
imprimir_matrices_con_barcos(matriz_j1, matriz_j2) | |
break | |
else: | |
print("Disparo fallado") | |
reproducir_sonido_error() | |
if disparos_restantes-1 <= 0: | |
indicar_fracaso(turno_actual) | |
imprimir_matrices_con_barcos(matriz_j1, matriz_j2) | |
break | |
turno_actual = oponente_de_jugador(turno_actual) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment