-
-
Save parzibyte/a061c0aef35806c58ae0ce879fabac24 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 imprimir_matriz(matriz, deberia_mostrar_barcos, jugador): | |
print(f"Este es el mar del jugador {jugador}: ") | |
letra = "A" | |
for y in range(FILAS): | |
imprimir_separador_horizontal() | |
print(f"| {letra} ", end="") | |
for x in range(COLUMNAS): | |
celda = matriz[y][x] | |
valor_real = celda | |
if not deberia_mostrar_barcos and valor_real != MAR and valor_real != DISPARO_FALLADO and valor_real != DISPARO_ACERTADO: | |
valor_real = " " | |
print(f"| {valor_real} ", end="") | |
letra = incrementar_letra(letra) | |
print("|",) # Salto de línea | |
imprimir_separador_horizontal() | |
imprimir_fila_de_numeros() | |
imprimir_separador_horizontal() | |
def incrementar_letra(letra): | |
return chr(ord(letra)+1) | |
def imprimir_separador_horizontal(): | |
# Imprimir un renglón dependiendo de las columnas | |
for _ in range(COLUMNAS+1): | |
print("+---", end="") | |
print("+") | |
def imprimir_fila_de_numeros(): | |
print("| ", end="") | |
for x in range(COLUMNAS): | |
print(f"| {x+1} ", end="") | |
print("|") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment