Created
June 8, 2020 18:51
-
-
Save parzibyte/954a5dc4b3199a70b033de4c7f2c8944 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
// Recibe la fila, columna y tablero. La fila y columna deben ser tal y como las | |
// proporciona el usuario. Es decir, la columna debe comenzar en 1 (no en cero | |
// como si fuera un índice) y la fila debe ser una letra | |
int abrirCasilla(char filaLetra, int columna, char tablero[FILAS][COLUMNAS]) { | |
// Convertir a mayúscula | |
filaLetra = toupper(filaLetra); | |
// Restamos 1 porque usamos la columna como índice | |
columna--; | |
// Convertimos la letra a índice | |
int fila = filaLetra - 'A'; | |
assert(columna < COLUMNAS && columna >= 0); | |
assert(fila < FILAS && fila >= 0); | |
if (tablero[fila][columna] == MINA) { | |
return ERROR_MINA_ENCONTRADA; | |
} | |
if (tablero[fila][columna] == ESPACIO_DESCUBIERTO) { | |
return ERROR_ESPACIO_YA_DESCUBIERTO; | |
} | |
// Si no hay error, colocamos el espacio descubierto | |
tablero[fila][columna] = ESPACIO_DESCUBIERTO; | |
return ERROR_NINGUNO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment