-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
28 lines (27 loc) · 844 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "chess.h"
#include <stdbool.h>
#include <stdio.h>
int main(){
struct game game;
init_game(&game, 5);
bool game_ended = false;
while (!game_ended) {
bool valid_input = true;
print_game(game, game.move);
char si, sj, ei, ej;
int isi, isj, iei, iej;
scanf(" %c%c%c%c", &si, &sj, &ei, &ej);
isi = si - 97;
isj = sj - 49;
iei = ei - 97;
iej = ej - 49;
if(isi < 0 || isj < 0 || iei < 0 || iej < 0)
valid_input = false;
if(isi > 7 || isj > 7 || iei > 7 || iej > 7)
valid_input = false;
if(valid_input)
make_move(&game, game.move, (struct position){.i=isi, .j=isj}, (struct position){.i=iei, .j=iej});
printf("\n----------------------------------------------\n");
}
return 0;
}