Exemplo n.º 1
0
void AGameModeBase::PreInitializeComponents()
{
	Super::PreInitializeComponents();

	FActorSpawnParameters SpawnInfo;
	SpawnInfo.Instigator = Instigator;
	SpawnInfo.ObjectFlags |= RF_Transient;	// We never want to save game states or network managers into a map									
											
	// Fallback to default GameState if none was specified.
	if (GameStateClass == nullptr)
	{
		UE_LOG(LogGameMode, Warning, TEXT("No GameStateClass was specified in %s (%s)"), *GetName(), *GetClass()->GetName());
		GameStateClass = AGameStateBase::StaticClass();
	}

	GameState = GetWorld()->SpawnActor<AGameStateBase>(GameStateClass, SpawnInfo);
	GetWorld()->SetGameState(GameState);
	if (GameState)
	{
		GameState->AuthorityGameMode = this;
	}

	// Only need NetworkManager for servers in net games
	GetWorld()->NetworkManager = GetWorldSettings()->GameNetworkManagerClass ? GetWorld()->SpawnActor<AGameNetworkManager>(GetWorldSettings()->GameNetworkManagerClass, SpawnInfo) : nullptr;

	InitGameState();
}
Exemplo n.º 2
0
        //void deroulement_du_jeu()	
        int main(int argc, char *argv[] )
        {
            
            // if( !InitGUI() ){ return 0; }
            
            if( !CheckCommand(argc,argv) ){ return 0; }
            
            if( !InitLogFile() ){ printf("Fail init logFile\n"); }
            
            PrintHeaderMatch();
            
            //Il faut nbMaxCps pour chaques joueurs, donc on multiplie par 2
            nbMaxCps *= 2;
            
            if( !PrintLibInitHeader() ){ printf("Fail print libHeader\n"); }
            if( !LoadLibraries() ){ return(0); }
            PrintTLine();
            
            SGameState* gameState = CreateBoard();
            
            //Srand pour obtenir des nombres aléatoires 
            srand(time(NULL));

            //Initialisation des joueurs    
            j1InitLibrary(j1Name);   
            j2InitLibrary(j2Name);

            if( strlen(pathIA1) && !strlen(pathIA2) ){ PrintPhysicalPlayers(NULL,j2Name); }
            else if( !strlen(pathIA1) && strlen(pathIA2) ){ PrintPhysicalPlayers(j1Name,NULL); }
            else if( !strlen(pathIA1) && !strlen(pathIA2) ){ PrintPhysicalPlayers(j1Name,j2Name); }
            else { PrintPhysicalPlayers(NULL,NULL); }
            
            PrintIAPlayers(pathIA1,pathIA2);
            PrintMaxCps(nbMaxCps/2);
            
            j1StartMatch();
            j2StartMatch();

            int nbMatch = 3;
            int j1Win = 0;
            int j2Win = 0;

            while( nbMatch>0 && j1Win<2 && j2Win<2){

                PrintMatch(4-nbMatch);
                
                //   InitBoard
                
                //On initialise le nombre de coups maximums
                 int cptCps = nbMaxCps;
                 j1NbPenalty = 0;
                 j2NbPenalty = 0;
                 
                 InitGameState(gameState);
                 
                EPiece j1BoardInit[4][10];
                EPiece j2BoardInit[4][10];

                SetPlayerColors();
                
                j1StartGame(j1Color,j1BoardInit);
                j2StartGame(j2Color,j2BoardInit);

                if( j1Color == ECblue ){ PrintColors(j2Name, j1Name); }
                else{ PrintColors(j1Name, j2Name); }
                
                //Initialisation des pions sur le plateau
                if( j1Color == ECblue ){
                    if( !InitBlueBoard(gameState,j1BoardInit) ){PrintBoardInitError(ECblue);return 0;}           
                    if( !InitRedBoard(gameState,j2BoardInit) ){PrintBoardInitError(ECred);return 0;}
                }
                else{
                    if( !InitRedBoard(gameState,j1BoardInit) ){PrintBoardInitError(ECred);return 0;}
                    if( !InitBlueBoard(gameState,j2BoardInit) ){PrintBoardInitError(ECblue);return 0;}
                }

                //Le premier joueur est le rouge
                EColor player = ECred;

                EColor winner = 0;
                
                PrintLine();
                PrintGameState(gameState);
                
                while( !winner && cptCps>0 ){

                    SMove move;
                    
                    //Duplication du plateau
                    SGameState *gameStateCpy = (SGameState*) malloc(sizeof(SGameState));
                    GameStateCpy(gameState,gameStateCpy);
                    
                    //Si c'est le tour du joueur rouge, on inverse son plateau 
                    if( player == ECred ){
                        RevertGame(gameStateCpy);
                    }

                    //On cache les pions du joueur ennemi
                    HideColor(gameStateCpy,abs((player+1)%2)+2);
                    
                    if( player == j1Color ){ move = j1NextMove(gameStateCpy); }
                    else{ move = j2NextMove(gameStateCpy); }
                    
                    if( player == ECred ){
                        move.start.line = 9-move.start.line;
                        move.end.line = 9-move.end.line;
                    }
                    
                    int moveType = CorrectMove(gameState,move,player);

                    PrintMove(player,move);
                    
                    //Mouvement incorrecte
                    if( moveType == 0 ){
                        if( player == j1Color ){
                            j1NbPenalty++;
                            j1Penalty();
                            PrintInvalidMove(player,j1NbPenalty);
                            if( j1NbPenalty == 3 ){
                                PrintPenalty(j1Name,j1Color);
                                winner = abs((j1Color+1)%2)+2;
                                break;
                            }
                        }
                        else{ 
                            j2NbPenalty++;
                            j2Penalty(); 
                            PrintInvalidMove(player,j2NbPenalty);
                            if( j2NbPenalty == 3 ){
                                PrintPenalty(j2Name,j2Color);
                                winner = abs((j2Color+1)%2)+2;
                                break;
                            }
                        }
                    }
                    else{
                        //Attaque
                        if( moveType == 1 ){
                            EPiece army = gameState->board[move.start.line][move.start.col].piece;
                            EPiece enemy = gameState->board[move.end.line][move.end.col].piece;
                            if( player == j1Color ){
                                j1AttackResult(move.start,army,move.end,enemy);
                                j2AttackResult(move.end,enemy,move.start,army);
                            }
                            else{
                                j1AttackResult(move.end,enemy,move.start,army);
                                j2AttackResult(move.start,army,move.end,enemy);
                            }
                            
                            PrintAttackResult(player,move.start,army,move.end,enemy);
                        }
                        
                        ExecuteMove(gameState,move,player);
                    }
                    PrintGameState(gameState);

                    free(gameStateCpy);

                    if( player == ECred ){ player = ECblue; }
                    else{ player = ECred; }

                    winner = Finished(gameState);
                    cptCps--;
                }
                
                if( cptCps == 0){ PrintMaxMoveReached(); }
                else{ 
                    if( j1Color == winner ){ PrintMatchWinner(j1Name, winner, 4-nbMatch);j1Win++; }
                    else{ PrintMatchWinner(j2Name, winner, 4-nbMatch);j2Win++; }
                }
                nbMatch--;
                
                j1EndGame();
                j2EndGame();
                
                printf("j1Win : %d\nj2Win : %d\n",j1Win,j2Win);
            }
            if( j1Win >= 2 ){ PrintGameWinner(j1Name, j1Color); }
            else{ PrintGameWinner(j2Name, j2Color); }
            
            j1EndMatch();
            j2EndMatch();

            free(gameState);
            return(0);
        }
Exemplo n.º 3
0
/* Fonction de gestion de l'affichage du plateau de jeu
 * @param SDL_Surface* window
 *     Surface de la fenetre
 * @param S_GameConfig gameConfig
 *     Structure de configuration du jeu
 * @return int
 *     1 si on doit quitter le programme, 0 sinon
 */
int DisplayBoard(SDL_Surface* window, S_GameConfig gameConfig)
{
    SDL_Surface *board_bg = IMG_Load(DESIGN_PATH "board.png");

    S_GameState gameState;
    InitGameState(&gameState, gameConfig);

    // Initialisation du score
    gameState.scoreP1 = 0;
    gameState.scoreP2 = 0;

    SDL_Rect position;
    position.x = 0; position.y = 0;

    SDL_BlitSurface(board_bg, NULL, window, &position);
    DisplayCheckers(window, gameState);
    DisplayBoardOverlays(window, gameState);
    DisplayScore(window, gameState);

    // On initialise les IA
    if (gameConfig.mode != HUMAN_HUMAN)
    {
        gameConfig.aiFunctions[1].AI_StartMatch((unsigned int)(gameConfig.points));
        gameConfig.aiFunctions[1].AI_StartGame();
    }

    if (gameConfig.mode == AI_AI)
    {
        gameConfig.aiFunctions[0].AI_StartMatch((unsigned int)(gameConfig.points));
        gameConfig.aiFunctions[0].AI_StartGame();
    }

    // finish = On revient au menu
    // quit = On quitte le programme
    int quit = 0, finish = 0;
    SDL_Event event;

    int oldTime = SDL_GetTicks();
    int time;

    while(!finish)
    {
        // Affichage
        if (event.type == SDL_MOUSEBUTTONUP ||
            event.type == SDL_MOUSEBUTTONDOWN ||
            gameState.refresh)
        {
            SDL_BlitSurface(board_bg, NULL, window, &position);
            DisplayCheckers(window, gameState);
            DisplayBoardOverlays(window, gameState);
            DisplayScore(window, gameState);
            gameState.refresh = 0;
        }

        SDL_Flip(window);

        // Gestion des evenements
        E_BoardSelected button = EventsBoard(&event, &gameState);

        if (button == QUIT_BOARD)
        {
            finish = 1;
            quit = 1;

            // On desalloue les IA
            if (gameConfig.mode != HUMAN_HUMAN)
                gameConfig.aiFunctions[1].AI_EndGame();

            if (gameConfig.mode == AI_AI)
                gameConfig.aiFunctions[0].AI_EndGame();
        }
        else if (button == MENU_BOARD)
            finish = 1;

        // Gestion de la vitesse de jeu entre IA
        if (gameConfig.mode == AI_AI && gameState.currentStage == SELECT_ZONE_SRC && gameConfig.option)
        {
            time = SDL_GetTicks();

            if ((time - oldTime) > 1000)
            {
                AI_EventsBoard(&gameState);
                oldTime = time;
            }
        }
        else
            AI_EventsBoard(&gameState);

        SDL_Delay(5);
    }

    // On desalloue les IA
    if (gameConfig.mode != HUMAN_HUMAN)
        gameConfig.aiFunctions[1].AI_EndMatch();

    if (gameConfig.mode == AI_AI)
        gameConfig.aiFunctions[0].AI_EndMatch();

    SDL_FreeSurface(board_bg);

    return quit;
}
Exemplo n.º 4
0
void AGameModeBase::Reset()
{
	Super::Reset();
	InitGameState();
}
Exemplo n.º 5
0
/* Procedure de gestion des actions des IA
 * @param S_GameState* gameState
 *     Etat du jeu
 */
void AI_EventsBoard(S_GameState* gameState)
{
    switch (gameState->currentStage)
    {
        case WAITING_ROLL_DBL:
            if (!IsHuman(gameState, 1))
            {
                // On demande a l'IA si elle veut doubler ou pas
                int answer = 0;
                SGameState AI_gameState;
                CreateAIGameState(&AI_gameState, gameState);

                if (gameState->currentPlayer == EPlayer1)
                    answer = gameState->gameConfig.aiFunctions[0].AI_DoubleStack(&AI_gameState);
                else
                    answer = gameState->gameConfig.aiFunctions[1].AI_DoubleStack(&AI_gameState);

                // L'IA double
                if (answer)
                    gameState->currentStage = DOUBLE_POPUP;
                else
                {
                    RollDice(gameState);

                    if (IsPossibleMove(gameState))
                        gameState->currentStage = SELECT_ZONE_SRC;
                    else
                        gameState->currentStage = PASS_POPUP;
                }
            }
            break;
        case WAITING_ROLL:
            // On gere le bouton que si le joueur est humain
            if (!IsHuman(gameState, 1))
            {
                RollDice(gameState);

                if (IsPossibleMove(gameState))
                    gameState->currentStage = SELECT_ZONE_SRC;
                else
                    gameState->currentStage = PASS_POPUP;
            }
            break;
        case DOUBLE_POPUP:
            if (!IsHuman(gameState, 0))
            {
                // On demande a l'IA si elle accepte ou refuse le double
                int answer = 0;
                SGameState AI_gameState;
                CreateAIGameState(&AI_gameState, gameState);

                if (gameState->currentPlayer == EPlayer1)
                    answer = gameState->gameConfig.aiFunctions[1].AI_TakeDouble(&AI_gameState);
                else
                    answer = gameState->gameConfig.aiFunctions[0].AI_TakeDouble(&AI_gameState);

                // l'IA accepte le double
                if (answer)
                {
                    gameState->stake *= 2;

                    if (gameState->currentPlayer == EPlayer1)
                        gameState->cubeOwner = EPlayer2;
                    else
                        gameState->cubeOwner = EPlayer1;

                    gameState->currentStage = WAITING_ROLL;
                }

                // l'IA refuse le double
                else
                {
                    // Le joueur courant gagne la partie
                    if (gameState->currentPlayer == EPlayer1)
                        gameState->scoreP1 += gameState->stake;
                    else
                        gameState->scoreP2 += gameState->stake;

                    gameState->currentStage = FINISH_GAME_POPUP;
                }
            }
            break;
        case FIRST_ROLL_POPUP:
            // On passe la popup
            if (gameState->gameConfig.mode == AI_AI)
            {
                if (IsPossibleMove(gameState))
                    gameState->currentStage = SELECT_ZONE_SRC;
                else
                    gameState->currentStage = PASS_POPUP;
            }
            break;
        case PASS_POPUP:
            // On passe la popup
            if (!IsHuman(gameState, 1))
            {
                if (gameState->currentPlayer == EPlayer1)
                    gameState->currentPlayer = EPlayer2;
                else
                    gameState->currentPlayer = EPlayer1;

                if (gameState->cubeOwner == gameState->currentPlayer || gameState->stake == 1)
                    gameState->currentStage = WAITING_ROLL_DBL;
                else
                    gameState->currentStage = WAITING_ROLL;
            }
            break;
        case FINISH_GAME_POPUP:
            // On passe la popup
            if (gameState->gameConfig.mode == AI_AI)
            {
                // On desalloue les IA
                gameState->gameConfig.aiFunctions[0].AI_EndGame();
                gameState->gameConfig.aiFunctions[1].AI_EndGame();

                if ((gameState->currentPlayer == EPlayer1 && gameState->scoreP1 >= gameState->gameConfig.points) ||
                    (gameState->currentPlayer == EPlayer2 && gameState->scoreP2 >= gameState->gameConfig.points))
                    gameState->currentStage = FINISH_MATCH_POPUP;
                else
                {
                    // On reinitialise les IA
                    gameState->gameConfig.aiFunctions[0].AI_StartGame();
                    gameState->gameConfig.aiFunctions[1].AI_StartGame();

                    // Remise a zero du plateau
                    InitGameState(gameState, gameState->gameConfig);
                }
            }
            break;
        case SELECT_ZONE_SRC:
            if (!IsHuman(gameState, 1))
            {
                int done = 0;
                int player = (gameState->currentPlayer == EPlayer1) ? 0 : 1;
                int error = 0;

                while (gameState->aiErrors[player] <= 3 && !done)
                {
                    SGameState AI_gameState;
                    CreateAIGameState(&AI_gameState, gameState);

                    SMove moves[4];
                    int i;

                    for (i=0; i<4; i++)
                    {
                        moves[i].src_point = EPos_nopos;
                        moves[i].dest_point = EPos_nopos;
                    }

                    if (gameState->currentPlayer == EPlayer1)
                        gameState->gameConfig.aiFunctions[0].AI_MakeDecision(&AI_gameState, moves, error != 0);
                    else
                        gameState->gameConfig.aiFunctions[1].AI_MakeDecision(&AI_gameState, moves, error != 0);

                    if (IsValidAIMoves(*gameState, moves))
                    {
                        // On effectue les mouvements
                        for (i=0; i<4; i++)
                        {
                            if (IsPossibleMove(gameState))
                            {
                                if (moves[i].src_point != EPos_nopos && moves[i].dest_point != EPos_nopos)
                                {
                                    int src = ConvertAIZone(gameState, moves[i].src_point);
                                    int dest = ConvertAIZone(gameState, moves[i].dest_point);

                                    gameState->currentZone = src;
                                    DoMove(dest, gameState);
                                    done = 1;
                                    gameState->refresh = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        fprintf(stderr, "Mouvement incorrect de l'IA (joueur %i)\n", gameState->currentPlayer + 1);
                        gameState->aiErrors[player]++;
                        error++;
                        gameState->refresh = 1;

                        if (gameState->aiErrors[player] > 3)
                        {
                            // Le joueur courant gagne la partie
                            if (gameState->currentPlayer == EPlayer1)
                                gameState->scoreP2 += gameState->stake;
                            else
                                gameState->scoreP1 += gameState->stake;

                            gameState->currentStage = FINISH_GAME_POPUP;
                        }
                    }
                }
            }
            break;
        default:
            break;
    }
}
Exemplo n.º 6
0
/* Fonction de gestion des evenements du plateau
 * @param SDL_Event* event
 *     Evenements de la fenetre
 * @param S_GameState* gameState
 *     Etat du jeu
 * @return E_BoardSelected
 *     Eventuel bouton clique
 */
E_BoardSelected EventsBoard(SDL_Event* event, S_GameState* gameState)
{
    E_BoardSelected clicked = NONE_BOARD;

    if (gameState->gameConfig.mode == HUMAN_HUMAN)
        SDL_WaitEvent(event); // On attend l'evenement
    else
        SDL_PollEvent(event); // Defilement automatique

    int zone = -1;
    int bx;

    if (event->type == SDL_QUIT)
        clicked = QUIT_BOARD;

    switch (gameState->currentStage)
    {
        case WAITING_FIRST_ROLL:
            switch(event->type)
            {
                case SDL_MOUSEBUTTONDOWN:
                    // Bouton "Lancer"
                    if (ClickRect(event, 293, 230, 100, 30))
                        gameState->selected = BUTTON1;
                    break;
                case SDL_MOUSEBUTTONUP:
                    gameState->selected = NONE_BOARD;

                    // Bouton "Lancer"
                    if (ClickRect(event, 293, 230, 100, 30))
                        RollDice(gameState);
                    break;
            }
            break;
        case WAITING_ROLL_DBL:
            // On gere les boutons que si le joueur est humain
            if (IsHuman(gameState, 1))
            {
                bx = (gameState->currentPlayer == EPlayer1) ? 122 : 464;

                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "Doubler"
                        if (ClickRect(event, bx, 210, 100, 30))
                            gameState->selected = BUTTON1;

                        // Bouton "Lancer"
                        if (ClickRect(event, bx, 250, 100, 30))
                            gameState->selected = BUTTON2;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "Doubler"
                        if (ClickRect(event, bx, 210, 100, 30))
                            gameState->currentStage = DOUBLE_POPUP;

                        // Bouton "Lancer"
                        if (ClickRect(event, bx, 250, 100, 30))
                        {
                            RollDice(gameState);

                            if (IsPossibleMove(gameState))
                                gameState->currentStage = SELECT_ZONE_SRC;
                            else
                                gameState->currentStage = PASS_POPUP;
                        }
                        break;
                }
            }
            break;
        case WAITING_ROLL:
            // On gere le bouton que si le joueur est humain
            if (IsHuman(gameState, 1))
            {
                bx = (gameState->currentPlayer == EPlayer1) ? 122 : 464;

                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "Lancer"
                        if (ClickRect(event, bx, 230, 100, 30))
                            gameState->selected = BUTTON1;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "Lancer"
                        if (ClickRect(event, bx, 230, 100, 30))
                        {
                            RollDice(gameState);

                            if (IsPossibleMove(gameState))
                                gameState->currentStage = SELECT_ZONE_SRC;
                            else
                                gameState->currentStage = PASS_POPUP;
                        }
                        break;
                }
            }
            break;
        case DOUBLE_POPUP:
            // On gere la popup que si l'adversaire est humain
            if (IsHuman(gameState, 0))
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "Accepter"
                        if (ClickRect(event, 234, 305, 100, 30))
                            gameState->selected = BUTTON1;

                        // Bouton "Refuser"
                        if (ClickRect(event, 354, 305, 100, 30))
                            gameState->selected = BUTTON2;
                        break;

                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "Accepter"
                        if (ClickRect(event, 234, 305, 100, 30))
                        {
                            gameState->stake *= 2;

                            if (gameState->currentPlayer == EPlayer1)
                                gameState->cubeOwner = EPlayer2;
                            else
                                gameState->cubeOwner = EPlayer1;

                            gameState->currentStage = WAITING_ROLL;
                        }

                        // Bouton "Refuser"
                        if (ClickRect(event, 354, 305, 100, 30))
                        {
                            // Le joueur courant gagne la partie
                            if (gameState->currentPlayer == EPlayer1)
                                gameState->scoreP1 += gameState->stake;
                            else
                                gameState->scoreP2 += gameState->stake;

                            gameState->currentStage = FINISH_GAME_POPUP;
                        }
                        break;
                }
            }
            break;
        case FIRST_ROLL_POPUP:
            // On gere la popup que si un humain joue
            if (gameState->gameConfig.mode != AI_AI)
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                            gameState->selected = BUTTON1;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                        {
                            if (IsPossibleMove(gameState))
                                gameState->currentStage = SELECT_ZONE_SRC;
                            else
                                gameState->currentStage = PASS_POPUP;
                        }
                        break;
                }
            }
            break;
        case PASS_POPUP:
            // On gere la popup que si le joueur courant est humain
            if (IsHuman(gameState, 1))
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                            gameState->selected = BUTTON1;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                        {
                            if (gameState->currentPlayer == EPlayer1)
                                gameState->currentPlayer = EPlayer2;
                            else
                                gameState->currentPlayer = EPlayer1;

                            if (gameState->cubeOwner == gameState->currentPlayer || gameState->stake == 1)
                                gameState->currentStage = WAITING_ROLL_DBL;
                            else
                                gameState->currentStage = WAITING_ROLL;
                        }
                        break;
                }
            }
            break;
        case FINISH_GAME_POPUP:
            // On gere la popup que si un joueur est humain
            if (gameState->gameConfig.mode != AI_AI)
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                            gameState->selected = BUTTON1;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        gameState->selected = NONE_BOARD;

                        // Bouton "OK"
                        if (ClickRect(event, 293, 305, 100, 30))
                        {
                            // On desalloue les IA
                            if (gameState->gameConfig.mode == HUMAN_AI)
                                gameState->gameConfig.aiFunctions[1].AI_EndGame();

                            // Fin du match
                            if ((gameState->currentPlayer == EPlayer1 && gameState->scoreP1 >= gameState->gameConfig.points) ||
                                (gameState->currentPlayer == EPlayer2 && gameState->scoreP2 >= gameState->gameConfig.points))
                                gameState->currentStage = FINISH_MATCH_POPUP;
                            else
                            {
                                // On reinitialise les IA pour une nouvelle manche
                                if (gameState->gameConfig.mode == HUMAN_AI)
                                    gameState->gameConfig.aiFunctions[1].AI_StartGame();

                                // Remise a zero du plateau
                                InitGameState(gameState, gameState->gameConfig);
                            }
                        }
                        break;
                }
            }
            break;
        case FINISH_MATCH_POPUP:
            switch(event->type)
            {
                case SDL_MOUSEBUTTONDOWN:
                    // Bouton "OK"
                    if (ClickRect(event, 293, 305, 100, 30))
                        gameState->selected = BUTTON1;
                    break;
                case SDL_MOUSEBUTTONUP:
                    gameState->selected = NONE_BOARD;

                    // Bouton "OK"
                    if (ClickRect(event, 293, 305, 100, 30))
                    {
                        // On ecrit dans le fichier des scores
                        FILE* file = fopen("score.txt", "a");

                        fprintf(file, "%s : %d\n", gameState->gameConfig.namePlayer1, gameState->scoreP1);
                        fprintf(file, "%s : %d\n", gameState->gameConfig.namePlayer2, gameState->scoreP2);
                        fprintf(file, "--------------------\n");

                        fclose(file);

                        // On revient au menu
                        clicked = MENU_BOARD;
                    }
                    break;
            }
            break;

        case SELECT_ZONE_SRC:
            // On gere le deplacement que si le joueur courant est humain
            if (IsHuman(gameState, 1))
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONUP:
                        // Selection d'une zone source
                        zone = ClickZone(event);
                        if (IsValidSrc(zone, gameState))
                        {
                            gameState->currentZone = zone;
                            gameState->currentStage = SELECT_ZONE_DST;
                        }
                        break;
                }
            }
            break;
        case SELECT_ZONE_DST:
            // On gere le deplacement que si le joueur courant est humain
            if (IsHuman(gameState, 1))
            {
                switch(event->type)
                {
                    case SDL_MOUSEBUTTONUP:
                        // Selection d'une zone source
                        zone = ClickZone(event);

                        if (IsValidDst(zone, gameState))
                            DoMove(zone, gameState);
                        else if (IsValidSrc(zone, gameState))
                            gameState->currentZone = zone;
                        else
                        {
                            gameState->currentZone = -1;
                            gameState->currentStage = SELECT_ZONE_SRC;
                        }
                        break;
                }
            }
            break;
        default:
            break;
    }

    return clicked;
}