Browse Source

Accent dans le message et variables à réinitialiser dans la boucle

master
Bastien 8 years ago
committed by Squiz
parent
commit
70f635be63
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      main.c

+ 11
- 6
main.c View File

@ -293,11 +293,11 @@ int main(int argc, char **argv) {
previous_movement.start_pos=-1; previous_movement.end_pos=-1;
first_move = 1;
do { /* on demande la suite de coup */
movement.start_pos=-1; movement.end_pos=-1;
start_pos_first_move = -1;
game_state_ia_copy = game_state_copy;
/* si on a une stratégie */
if( player_state[i].ia_lib_p ) {
movement.start_pos=-1; movement.end_pos=-1;
start_pos_first_move = -1;
game_state_ia_copy = game_state_copy;
ia_call_function(player_state[i], ia_next_move, &next_move, &game_state_ia_copy, first_move, &movement);
if(!quit) {
printf("(GUI) Moving pawn %d → hole %d\n", movement.start_pos, movement.end_pos);
@ -322,10 +322,10 @@ int main(int argc, char **argv) {
fprintf(stderr, "mouvement (%d,%d) invalide\n",movement.start_pos, movement.end_pos);
#endif
if( (buffer = (char*) malloc( 28 *sizeof(char) ) ) == NULL)
display_animsg(&gui_res, &game_state, player_state[i].branch, player_state[i].name, "Coup non valide", 1000);
display_animsg(&gui_res, &game_state_copy, player_state[i].branch, player_state[i].name, "Coup non valide", 1000);
else {
snprintf(buffer, 28, "Coup non valide (%d erreur%s)", player_state[i].error+1, (player_state[i].error+1>1)?"s":"");
display_animsg(&gui_res, &game_state, player_state[i].branch, player_state[i].name, buffer, 1500);
display_animsg(&gui_res, &game_state_copy, player_state[i].branch, player_state[i].name, buffer, 1500);
free(buffer);
}
if(++(player_state[i].error)==3) {
@ -347,10 +347,15 @@ int main(int argc, char **argv) {
} else {
/* on a un joueur réel, on demande un coup tant qu'il n'est pas valide */
do {
movement.start_pos=-1; movement.end_pos=-1;
start_pos_first_move = -1;
game_state_ia_copy = game_state_copy;
quit += display_usermove_pawn(&gui_res, &game_state_ia_copy, player_state[i].branch, player_state[i].name, &movement, &next_move);
if(first_move)
start_pos_first_move = movement.start_pos; /* on retient le point de départ pour éviter les coups qui reviendraient là où on est parti */
validation_movement = valid_move(start_pos_first_move, movement, previous_movement, player_state[i], game_state_copy, start_position, !next_move);
if(validation_movement == invalid && !quit)
display_animsg(&gui_res, &game_state, player_state[i].branch, player_state[i].name, "Coup non valide, reessayer", 1000);
display_animsg(&gui_res, &game_state_copy, player_state[i].branch, player_state[i].name, "Coup non valide, réessayer", 1000);
} while(validation_movement == invalid && !quit);
}
if(validation_movement == jump || validation_movement == neighbour_valid) {


Loading…
Cancel
Save