commit
This commit is contained in:
parent
4c6e50dfc2
commit
9f413914ea
|
@ -149,7 +149,7 @@ int main(int argc, char *argv[]){
|
|||
|
||||
while (1) { //FIXME: potenzialmente da cambiare questo while (ma forse bastano i segnali)
|
||||
// aspetto il mio turno
|
||||
semOp(semid, msg.player_id, -1);
|
||||
semOp(semid, msg.player_id, -1); // mettere id eccetera in var
|
||||
|
||||
printBoard(boardClient);
|
||||
|
||||
|
@ -164,6 +164,10 @@ int main(int argc, char *argv[]){
|
|||
|
||||
// mando mossa al server
|
||||
sndMove(&move);
|
||||
|
||||
semOp(semid, msg.player_id, -1);
|
||||
printBoard(boardClient);
|
||||
|
||||
printf(PCLIENT "Waiting for oponent\n"); //FIXME: solo se la partita non è finita
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,16 @@ int main(int argc, char *argv[]){
|
|||
|
||||
// PARTITA
|
||||
printf(PSERVER "Starting game\n");
|
||||
printf("%d %d\n", _INPUT_S.collums, _INPUT_S.rows);
|
||||
setCollums(_INPUT_S.collums);
|
||||
setRows(_INPUT_S.rows);
|
||||
|
||||
printf("%d %d\n", _ROWS, _COLLUMS);
|
||||
for (int i=0; i < _ROWS * _COLLUMS; i++) { //FIXME: tmp
|
||||
_BOARD[i] = EMPTY;
|
||||
}
|
||||
|
||||
|
||||
int turns_left = _INPUT_S.rows * _INPUT_S.collums;
|
||||
int turn = 0;
|
||||
tile_t result;
|
||||
|
@ -94,7 +101,6 @@ int main(int argc, char *argv[]){
|
|||
|
||||
do {
|
||||
semOp(_SEMID, turn, 1);
|
||||
turn ^= 1;
|
||||
|
||||
printf(PSERVER "%s's turn\n", name[turn]);
|
||||
|
||||
|
@ -107,7 +113,10 @@ int main(int argc, char *argv[]){
|
|||
|
||||
printf("turns left: %d\n", turns_left - 1);
|
||||
|
||||
semOp(_SEMID, turn, 1);
|
||||
|
||||
|
||||
turn ^= 1;
|
||||
} while (--turns_left && !(result = checkWin(_BOARD, move.move)));
|
||||
|
||||
|
||||
|
|
|
@ -22,11 +22,7 @@ tile_t * shmServerAt(int shmid) {
|
|||
if (board == SHMERR) {
|
||||
errExit("shmat", "shmServerAt");
|
||||
}
|
||||
|
||||
for (int i=0; i < _ROWS * _COLLUMS; i++) {
|
||||
board[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
return board;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,8 +137,8 @@ int checkMove(tile_t *board, int collums) {
|
|||
}
|
||||
|
||||
void insertMove(tile_t *board, int pos, int turn) {
|
||||
printf("playing %d in %d\n", (turn == 0) ? PLAYER2 : PLAYER1 , pos);
|
||||
board[pos] = (turn == 0) ? PLAYER1 : PLAYER2;
|
||||
printf("playing %d in %d\n", (turn == 0) ? PLAYER1 : PLAYER2, pos);
|
||||
board[pos] = (turn == 0) ? PLAYER2 : PLAYER1;
|
||||
}
|
||||
|
||||
int isValid(int pos) {
|
||||
|
|
Loading…
Reference in New Issue