Exemple #1
0
void Team::destroyTargets(void)
{
	for(size_t i = 0; i < rosterSize; i++)
	{
		GameObjectPtr object = ObjectManager->getByWatchID(roster[i]);
		if(object)
		{
			GameObjectPtr target = nullptr;
			if(object->isMover())
				target = ((MoverPtr)object)->getPilot()->getCurrentTarget();
			if(target && target->isMover())
			{
				//-----------------------------------------
				//-- Need to pound these guys to death.
				WeaponShotInfo shot;
				shot.init(nullptr, -3, 5, 0, 0);
				for(size_t i = 0; i < 100; i++)
				{
					if(RollDice(30))
						shot.hitLocation = target->calcHitLocation(nullptr, -1, ATTACKSOURCE_DFA, 0);
					else
						shot.hitLocation = target->calcHitLocation(nullptr, -1, ATTACKSOURCE_ARTILLERY, 0);
					if(MPlayer)
					{
						target->handleWeaponHit(&shot, true);
					}
					else
						target->handleWeaponHit(&shot);
				}
			}
		}
	}
}
Exemple #2
0
int CUnit::GetInitiative() const
{
	int Basic = RollDice(1, D20);
	int Mod = GetInitiativeMod();

	Basic += Mod;
	return Basic;
}
Exemple #3
0
static void NextPlayer( HWND hwnd, HDC hdc )
/******************************************/
{
    BOOL    reset_value;
    short   i;

    PCTurn = FALSE;
    HighliteName( hdc, CurrentPlayer );
    CurrentPlayer++;
    if( CurrentPlayer == NumberOfPlayers ) {
        CurrentPlayer = 0;
        CurrentTurn++;
        if( CurrentTurn == 13 ) {
            SendMessage( hwnd, WMW_GAME_OVER, 0, 0 );
            return;
        }
    }
    HighliteName( hdc, CurrentPlayer );
    WriteScoreOptions( hdc );
    CurrentRoll = 0;
    reset_value = FALSE;
    if( DieCheckMeansRoll ) {
        reset_value = TRUE;
    }
    for( i = 0; i < 5; i++ ) {
        Dice[i].is_checked = reset_value;
        CheckDlgButton( hwnd, IDW_DICE1+i, reset_value );
    }
    RollDice( hwnd, hdc );
    GetDiceInfo();
    EnableWindow( GetDlgItem( hwnd, IDW_OK ), FALSE );
    if( Player[CurrentPlayer][IS_COMPUTER] ) {
        PCTurn = TRUE;
        EnableWindow( GetDlgItem( hwnd, IDW_ROLL ), FALSE );
    } else {
        EnableWindow( GetDlgItem( hwnd, IDW_ROLL ), TRUE );
    }
}
Exemple #4
0
long _EXPORT FAR PASCAL WndProc( HWND hwnd, UINT message, WPARAM wparam,
                                  LPARAM lparam )
/*********************************************************************/
{
    static HANDLE   hdlginstance;
    static BOOL     got_watzee_bonus;
    PAINTSTRUCT     ps;
    FARPROC         dlg_proc;
    HDC             hdc;
    POINT           point;
    short           x;
    short           y;
    short           dy;
    short           i;

    switch( message ) {
    case WM_CREATE :
        hdlginstance = ((CREATESTRUCT far *) MK_FP32((void*)lparam))->hInstance;
        x = CharWidth * 22 + CharWidth / 2;
        y = CharHeight * 3;
        dy = CharHeight * 3;
        dy += dy / 7;
       /*  create the check marks for the dice bitmaps, and the ROLL and
           OK buttons  */
        for( i = 0; i < 5; i++, y += dy ) {
            CreateWindow( "BUTTON", "", WS_CHILD|WS_VISIBLE|BS_CHECKBOX,
                          x, y, CharWidth, CharHeight, hwnd,
                          (HMENU)(IDW_DICE1+i),
                          hdlginstance,
                          NULL );
        }
        CreateWindow( "BUTTON", "ROLL", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
                      x, CharHeight * 19, 9 * CharWidth / 2 ,
                      CharHeight * 2, hwnd, (HMENU)IDW_ROLL,
                      hdlginstance, NULL );
        CreateWindow( "BUTTON", "OK", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
                      x, 43 * CharHeight / 2, 9 * CharWidth / 2,
                      CharHeight * 2, hwnd, (HMENU)IDW_OK,
                      hdlginstance, NULL );
        return( 0 );
    case WMW_START_NEW_GAME :
        dlg_proc = MakeProcInstance( (FARPROC)GetNumPlayersDialogProc, hdlginstance );
        DialogBox( hdlginstance, "GetNumPlayers", hwnd, (DLGPROC)dlg_proc );
        FreeProcInstance( dlg_proc );
        dlg_proc = MakeProcInstance( (FARPROC)GetInitialsDialogProc, hdlginstance );
        DialogBox( hdlginstance, "GetPlayersInitials", hwnd, (DLGPROC)dlg_proc );
        FreeProcInstance( dlg_proc );
        EnableWindow( GetDlgItem( hwnd, IDW_OK ), FALSE );
        EnableWindow( GetDlgItem( hwnd, IDW_ROLL ), TRUE );
        PlayingGameYet = TRUE;
        InvalidateRect( hwnd, NULL, FALSE );
        for( i = 0; i < NumberOfPlayers; i++ ) {
            if( Player[i][IS_COMPUTER] ) break;
        }
        if( i < NumberOfPlayers && !GotTimer ) {
            while( !SetTimer( hwnd, ID_TIMER, TIMER_INTERVAL, NULL ) ) {
                if( MessageBox( hwnd, "Too many clocks or timers are active",
                 AppName, MB_ICONEXCLAMATION|MB_RETRYCANCEL ) == IDCANCEL ) {
                    DestroyWindow( hwnd );
                    return( 0 );
                }
            }
            GotTimer = TRUE;
        }
        if( i == 0 ) {
            PCTurn = TRUE;
            EnableWindow( GetDlgItem( hwnd, IDW_ROLL ), FALSE );
        }
        hdc = GetDC( hwnd );
        RollDice( hwnd, hdc );
        GetDiceInfo();
        ReleaseDC( hwnd, hdc );
//      SetFocus( hwnd );
        return( 0 );
    case WM_COMMAND :
        switch( LOWORD( wparam ) ) {
        case IDM_NEWGAME :
            if( GotTimer ) {
                KillTimer( hwnd, ID_TIMER );
            }
            if( MessageBox( hwnd, "Start New Game:  Are you sure?", "WATZEE",
                            MB_YESNO | MB_ICONEXCLAMATION ) == IDYES ) {
                InitializeGameData();
                InvalidateRect( hwnd, NULL, TRUE );
                SendMessage( hwnd, WMW_START_NEW_GAME, 0, 0 );
            } else if( GotTimer ) {
                SetTimer( hwnd, ID_TIMER, TIMER_INTERVAL, NULL );
            }
            break;
        case IDM_OPTIONS :
            if( GotTimer ) {
                KillTimer( hwnd, ID_TIMER );
            }
            dlg_proc = MakeProcInstance( (FARPROC)OptionsDialogProc, hdlginstance );
            DialogBox( hdlginstance, "Options", hwnd, (DLGPROC)dlg_proc );
            FreeProcInstance( dlg_proc );
            if( GotTimer ) {
                SetTimer( hwnd, ID_TIMER, TIMER_INTERVAL, NULL );
            }
            break;
        case IDM_EXIT :
            DestroyWindow( hwnd );
            break;
        case IDM_SCORING :
            if( GotTimer ) {
                KillTimer( hwnd, ID_TIMER );
            }
            dlg_proc = MakeProcInstance( (FARPROC)HelpDialogProc, hdlginstance );
            DialogBox( hdlginstance, "WatzeeHelp", hwnd, (DLGPROC)dlg_proc );
            FreeProcInstance( dlg_proc );
            if( GotTimer ) {
                SetTimer( hwnd, ID_TIMER, TIMER_INTERVAL, NULL );
            }
            break;
        case IDM_ABOUT :
            if( GotTimer ) {
                KillTimer( hwnd, ID_TIMER );
            }
            dlg_proc = MakeProcInstance( (FARPROC)AboutDialogProc, hdlginstance );
            DialogBox( hdlginstance, "AboutWatzee", hwnd, (DLGPROC)dlg_proc );
            FreeProcInstance( dlg_proc );
            if( GotTimer ) {
                SetTimer( hwnd, ID_TIMER, TIMER_INTERVAL, NULL );
            }
            break;
        case IDW_DICE1 :
        case IDW_DICE2 :
        case IDW_DICE3 :
        case IDW_DICE4 :
        case IDW_DICE5 :
            if( !PCTurn && CurrentRoll < 2 ) {
                SendMessage( hwnd, WMW_DIE_CHECK, wparam, 0 );
            }
            break;
        case IDW_ROLL :
            SendMessage( hwnd, WMW_ROLL, 0, 0 );
            break;
        case IDW_OK :
            SendMessage( hwnd, WMW_OK, 0, 0 );
            break;
        }
        return( 0 );
    case WM_LBUTTONUP :
        if( !PCTurn ) {
            MAKE_POINT( point, lparam );
            if( point.x > CharWidth * 24
             && point.y < CharHeight * 20 ) {
                wparam = GetDieCheck( hwnd, point );
                if( wparam && CurrentRoll < 2 ) {
                    SendMessage( hwnd, WMW_DIE_CHECK, wparam, 0 );
                }
            } else {
                wparam = GetScoreCheck( point );
                if( wparam && Player[CurrentPlayer][wparam] == UNDEFINED ) {
                     SendMessage( hwnd, WMW_SCORE_CHECK, wparam, 0 );
                }
            }
        }
        return( 0 );
    case WMW_DIE_CHECK :
        i = LOWORD( wparam ) - IDW_DICE1;
        Dice[i].is_checked = !Dice[i].is_checked;
        CheckDlgButton( hwnd, wparam, (BOOL)Dice[i].is_checked );
//      SetFocus( hwnd );
        return( 0 );
    case WMW_SCORE_CHECK :
        hdc = GetDC( hwnd );
        if( wparam != LastScoreSelection ) {
            DoScore( hdc, wparam );
            EnableWindow( GetDlgItem( hwnd, IDW_OK ), TRUE );
        }
        ReleaseDC( hwnd, hdc );
//      SetFocus( hwnd );
        return( 0 );
    case WMW_ROLL :
        hdc = GetDC( hwnd );
        if( DieCheckMeansRoll ) {
            for( i = 0; i < 5; i++ ) {
                if( Dice[i].is_checked ) break;
            }
        } else {
            for( i = 0; i < 5; i++ ) {
                if( !Dice[i].is_checked ) break;
            }
        }
        if( i < 5 ) {
            if( LastScoreSelection ) {
                Player[CurrentPlayer][LastScoreSelection] = UNDEFINED;
                WriteScore( hdc, CurrentPlayer, LastScoreSelection );
                DoScoreTotals( hdc );
                LastScoreSelection = 0;
            }
            got_watzee_bonus = FALSE;
            CurrentRoll++;
            RollDice( hwnd, hdc );
            GetDiceInfo();
            if( DiceInfo.got_watzee && Player[CurrentPlayer][WATZEE] == 50 ) {
                got_watzee_bonus = TRUE;
            }
            if( CurrentRoll == 2 ) {
                EnableWindow( GetDlgItem( hwnd, IDW_ROLL ), FALSE );
            }
        }
        ReleaseDC( hwnd, hdc );
//      SetFocus( hwnd );
        return( 0 );
    case WMW_OK :
        hdc = GetDC( hwnd );
        LastScoreSelection = 0;
        if( got_watzee_bonus ) {
            DoScore( hdc, WATZEE_BONUS );
            LastScoreSelection = 0;
            got_watzee_bonus = FALSE;
        }
        NextPlayer( hwnd, hdc );
        ReleaseDC( hwnd, hdc );
//      SetFocus( hwnd );
        return( 0 );
    case WMW_GAME_OVER :
        hdc = GetDC( hwnd );
        WriteScoreOptions( hdc );
        ReleaseDC( hwnd, hdc );
        if( GotTimer ) {
            KillTimer( hwnd, ID_TIMER );
            GotTimer = FALSE;
        }
        if( MessageBox( hwnd, "Another Game ?", "WATZEE", MB_YESNO ) == IDYES ) {
            InitializeGameData();
            InvalidateRect( hwnd, NULL, TRUE );
            SendMessage( hwnd, WMW_START_NEW_GAME, 0, 0 );
        } else {
            DestroyWindow( hwnd );
        }
        return( 0 );
    case WM_TIMER :
        if( PCTurn ) {
            PCPlay( hwnd );
        }
        return( 0 );
    case WM_PAINT :
        hdc = BeginPaint( hwnd, &ps );
        DrawDice( hwnd, hdc );
        DrawScoreCard( hdc );
        WriteScoreOptions( hdc );
        if( PlayingGameYet ) {
            WriteInitials( hdc );
            HighliteName( hdc, CurrentPlayer );
            WriteScores( hdc );
        }
        EndPaint( hwnd, &ps );
        return( 0 );
    case WM_DESTROY :
        {
            HBITMAP     hbm;

            if( GotTimer ) {
                KillTimer( hwnd, ID_TIMER );
            }
            for( i = 0; i < 6; i++ ) {
                hbm = (HBITMAP)GetWindowLong( hwnd, i * sizeof( DWORD ) );
                DeleteObject( hbm );
            }
            PostQuitMessage( 0 );
            return( 0 );
        }
    }
    return( DefWindowProc( hwnd, message, wparam, lparam ) );
}
Exemple #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;
    }
}
Exemple #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;
}