print the table

This commit is contained in:
Mylloon 2022-11-16 15:13:53 +01:00
parent 1f3d98cc78
commit 349731ce02
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 58 additions and 0 deletions

View file

@ -6,4 +6,10 @@
/* Remplie le plateau avec la configuration de départ */
void remplissage_debut(Jeu *jeu);
/* Récupère la case */
char recupere_case(Jeton *plat[8][8], int caseI, int caseJ);
/* Affiche le plateau */
void affiche_plateau(Jeton *plateau);
#endif

View file

@ -1,7 +1,10 @@
#include "../includes/plateau.h"
#include "../includes/struct.h"
int main(void) {
Jeu *jeu = nouvelle_partie();
remplissage_debut(jeu);
affiche_plateau(jeu->plateau);
free_jeu(jeu);

View file

@ -23,3 +23,52 @@ void remplissage_debut(Jeu *jeu) {
jeu->plateau[4][3]->couleur = NOIR;
ajoute_jeton_liste(jeu->j1, jeu->plateau[4][3]);
}
char recupere_case(Jeton *plat[8][8], int caseI, int caseJ) {
switch (plat[caseI][caseJ]->couleur) {
case BLANC:
return 'B';
case NOIR:
return 'N';
default:
return ' ';
}
}
void affiche_plateau(Jeton *plat[8][8]) {
printf(" ");
for (int i = 0; i < 8; ++i) {
printf(" %c ", 'A' + i);
}
printf("\n");
for (int i = 0; i < 8 * 2 + 1; ++i) {
for (int j = 0; j < 8; ++j) {
if (j == 0) {
switch (i % 2) {
case 0:
printf(" ");
break;
case 1:
printf("%d ", (i / 2) + 1);
break;
}
}
if (i % 2 == 0)
printf("+---");
else {
printf("| %c ", recupere_case(plat, i / 2, j));
}
if (j == 7) {
if (i % 2 == 0)
printf("+");
else {
printf("| ");
}
printf("\n");
}
}
}
}