Logo Search packages:      
Sourcecode: schafkopf version File versions  Download package

bool Game::setupGameInfoForced ( Player *  players[]  )  [private]

internal helper function for setupGameInfo(). handles all cases when no player wants to play. It forces players in certain cases to play according to the users settings.

Definition at line 395 of file game.cpp.

References postEvent(), GameInfo::setColor(), GameInfo::setMitspieler(), GameInfo::setMode(), GameInfo::setSpieler(), and GameInfo::setValid().

Referenced by setupGameInfo().

{
    int i;
    GameInfo* info;
    
    if( Settings::instance()->doublerHasToPlay() )
    {
        // if someone has doubled he is forced to player
        // if more players have doubled the last one has to play
        for( i=PLAYERS-1;i>=0;i-- )
            if( players[i]->geklopft() )
            {
                postEvent( InfoMessage, 0, 0, i18n("%1 has doubled last\nand has to play now.").arg( players[i]->name() ), true );
    
                info = players[i]->gameInfo( true );
                info->setSpieler( players[i] );
                m_gameinfo = *info;
                delete info;
                return true;
            }
    }
        
    if( Settings::instance()->noGame() == Settings::NOGAME_NEUGEBEN )
    {
        postEvent( InfoMessage, 0, 0, i18n("No one wants to play.\nCards will be thrown together."), true );
        //m_canvas->information( i18n("No one wants to play.\nCards will be thrown together.") );
        m_timesThrownTogether++;
        m_gameinfo.setValid( false );
        postEvent( GameInfoSetup );
        //emit signalSetupGameInfo();
        return false;
    }
    else if( Settings::instance()->noGame() == Settings::NOGAME_ALTERSPIELT )
    {
        // find player with eichel ober
        for( i=0;i<PLAYERS;i++ )
            if( players[i]->cards()->contains( Card::EICHEL, Card::OBER ) )
            {
                postEvent( InfoMessage, 0, 0, i18n("%1 has got the Eichel Ober\nand has to play.").arg( players[i]->name() ), true );
                
                info = players[i]->gameInfo( true );
                info->setSpieler( players[i] );
                m_gameinfo = *info;
                delete info;
                return true;
            }
    }
    else if( Settings::instance()->noGame() == Settings::NOGAME_RAMSCH )
    {
        postEvent( InfoMessage, 0, 0, i18n("No one wants to play.\nRamsch will be played."), true );
        m_gameinfo.setSpieler( NULL );
        m_gameinfo.setMitspieler( NULL );
        m_gameinfo.setMode( GameInfo::RAMSCH );
        m_gameinfo.setColor( Card::NOCOLOR );
        return true;
    }
    
    return false;
}


Generated by  Doxygen 1.6.0   Back to index