summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'console.c')
-rw-r--r--console.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/console.c b/console.c
index 6c1cda8..7eed8ce 100644
--- a/console.c
+++ b/console.c
@@ -7,65 +7,66 @@
void draw_board(int board[8][8]) {
printf(" A B C D E F G H\n");
- int tileColor = 1;
+ int tileColor = 0;
for(int r = 0; r < 8; r++) {
tileColor = !tileColor;
- char* line = calloc(2 + (8 * 10), sizeof(char));
+ char* line = calloc(2 + (8 * 16) + 8, sizeof(char));
line[0] = '8' - r;
line[1] = ' ';
for(int c = 0; c < 8; c++) {
tileColor = !tileColor;
- strcat(line, tileColor == 0 ? ANSI_COLOR_RED : ANSI_COLOR_RESET);
+ strcat(line, tileColor == 0 ? COLOR_CHESS_WHITE : COLOR_CHESS_BLACK);
if(board[c][r] <= 6) {
switch(board[c][r]) {
case 0:
- strcat(line, "# ");
+ strcat(line, " ");
break;
case pawn:
- strcat(line, "P ");
+ strcat(line, "P");
break;
case knight:
- strcat(line, "N ");
+ strcat(line, "N");
break;
case bishop:
- strcat(line, "B ");
+ strcat(line, "B");
break;
case rook:
- strcat(line, "R ");
+ strcat(line, "R");
break;
case queen:
- strcat(line, "Q ");
+ strcat(line, "Q");
break;
case king:
- strcat(line, "K ");
+ strcat(line, "K");
break;
}
}
else {
switch(board[c][r] - 6) {
case pawn:
- strcat(line, "p ");
+ strcat(line, "p");
break;
case knight:
- strcat(line, "n ");
+ strcat(line, "n");
break;
case bishop:
- strcat(line, "b ");
+ strcat(line, "b");
break;
case rook:
- strcat(line, "r ");
+ strcat(line, "r");
break;
case queen:
- strcat(line, "q ");
+ strcat(line, "q");
break;
case king:
- strcat(line, "k ");
+ strcat(line, "k");
break;
}
}
+ strcat(line, COLOR_RESET " ");
}
printf(line);
- printf("\n" ANSI_COLOR_RESET);
+ printf("\n" COLOR_RESET);
free(line);
}
}
@@ -96,9 +97,9 @@ void clear_screen() {
}
void warn_user(char* message) {
clear_screen();
- printf("\n");
+ printf("\n" COLOR_WARN);
printf(message);
- printf("\nPress any key to continue...\n");
+ printf(COLOR_RESET "\nPress any key to continue...\n");
while(getchar() != '\n');
getchar();
}