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

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

find a player who wants to playerPlayedCard and setup m_gameinfo according to this returns true on succes and false when no one wants to playerPlayedCard and a new game should be started

Definition at line 322 of file game.cpp.

References GameInfo::color(), GameInfo::laufende(), GameInfo::mitspieler(), GameInfo::mode(), postEvent(), GameInfo::setMitspieler(), GameInfo::setSpieler(), setupGameInfoForced(), GameInfo::setValid(), and GameInfo::toString().

{
    // list of games the players want to playercards
    // maximum 4 entries
    QPtrList<GameInfo> games;
    games.setAutoDelete( true );
    unsigned int i = 0;
      
    for( i=0;i<PLAYERS;i++)
    {
        GameInfo* info = players[i]->gameInfo();
      if(terminated)
          return false;
      if( info )
        {
          info->setSpieler( players[i] );
            games.append( info );
            if( players[i]->rtti() != Player::HUMAN )
                postEvent( InfoMessage, 0, 0, i18n("%1 has a game.").arg( players[i]->name() ), true );
          //m_canvas->information( i18n("%1 has a game.").arg( players[i]->name() ) );
        }
        else
        {
            if( players[i]->rtti() != Player::HUMAN )
                postEvent( InfoMessage, 0, 0, i18n("%1 has no game.").arg( players[i]->name() ), true );
          //m_canvas->information( i18n("%1 has no game.").arg( players[i]->name() ) );
        }
    }
    
    if(terminated)
        return false;
    
    if( games.isEmpty() )
    {
        if( !setupGameInfoForced(players) )
            return false;
    } 
    else
    {
        // find the highest game in the list
        GameInfo* best = games.first();
        for( i=0;i<games.count();i++ )        
            if( *games.at( i ) > *best )
                best = games.at( i );
        
        m_gameinfo = *best;
    }
    
    // finde den mitspieler:
    if( m_gameinfo.mode()==GameInfo::RUFSPIEL ) 
    {
        Card sau( Card::SAU, static_cast<Card::EColor>(m_gameinfo.color()) );
        for( i=0;i<PLAYERS || !m_gameinfo.mitspieler();i++ )
        {
            for( unsigned int z=0;z<CARD_CNT/PLAYERS;z++ )
                if( players[i]->cards()->at(z)->isEqual( &sau ) )
                {
                    m_gameinfo.setMitspieler(players[i]);
                    break;
                }
        }
    }
    
    m_laufende = m_gameinfo.laufende();
    postEvent( InfoMessage, 0, 0, m_gameinfo.toString(), true );
    //m_canvas->information( m_gameinfo.toString() );

    m_gameinfo.setValid( true );
    postEvent( GameInfoSetup );
    //emit signalSetupGameInfo();
    return true;
}


Generated by  Doxygen 1.6.0   Back to index