check if play is legal
This commit is contained in:
parent
8653ef4d83
commit
48afc879b3
1 changed files with 22 additions and 3 deletions
|
@ -87,9 +87,28 @@ int _case_jouable(Jeton *plat[LONGEUR][LARGEUR], int case_i, int case_j,
|
|||
|
||||
int case_jouable(Jeton *plat[LONGEUR][LARGEUR], int case_i, int case_j,
|
||||
int couleur) {
|
||||
// TODO
|
||||
(void)plat, (void)case_i, (void)case_j, (void)couleur;
|
||||
return 1;
|
||||
int flag = 0;
|
||||
|
||||
// Coup illégal
|
||||
if (plat[case_i][case_j]->couleur == NOIR ||
|
||||
plat[case_i][case_j]->couleur == BLANC) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Regarde dans toutes les directions
|
||||
for (int i = -1; i <= 1; ++i) {
|
||||
for (int j = -1; j <= 1; ++j) {
|
||||
if (i != 0 || j != 0) {
|
||||
if (_case_jouable(plat, case_i, case_j, i, j, couleur) &&
|
||||
plat[case_i + i][case_j + j]->couleur ==
|
||||
couleur_ennemi(couleur)) {
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
int plateau_rempli(Jeton *plat[LONGEUR][LARGEUR]) {
|
||||
|
|
Reference in a new issue