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

bool GameInfo::isAllowed ( CardList cards,
int  mode,
int  color 
) [static]

Is a player with the cards cards allowed to playe the game mode with the color color.

checks wether a game is allowed to play: 1. is it allowed to play this game with this cards (needed for callgames) 2. is it allowed to play this game according to the users preferences

Definition at line 147 of file gameinfo.cpp.

References Settings::allowedGames(), Card::card(), Card::color(), CardList::contains(), t_AllowedGames::dachs, t_AllowedGames::farb_geier, t_AllowedGames::farb_wenz, t_AllowedGames::geier, and t_AllowedGames::wenz.

{
    t_AllowedGames* allowed = NULL;
    
    // it is never allowed to decide to play Ramsch
    if( mode == GameInfo::RAMSCH )
        return false;
        
    if( mode==GameInfo::RUFSPIEL ) 
    {
        if( cards->contains( color, Card::SAU ) || color == Card::HERZ )
            return false;
    
        // ok now we have to test if we have a card in this color with is no trumpf_index
        for( unsigned int i=0;i<cards->count();i++)
        {
            Card* c = cards->at(i);
            if( c->color() == color && c->card() != Card::OBER && c->card() != Card::UNTER )
            {
                return true;
            }
        }
        
        return false;
    } else if( mode==GameInfo::STICHT && color==Card::NOCOLOR )
        return false;
    
    // check for the users preferences now
    allowed = Settings::instance()->allowedGames();
    if( mode == GameInfo::DACHS && !allowed->dachs )
    {
        delete allowed;
        return false;
    }

    if( (mode == GameInfo::WENZ && !allowed->wenz) ||
        (mode == GameInfo::WENZ && color != Card::NOCOLOR && !allowed->farb_wenz) )
    {
        delete allowed;
        return false;
    }
    
    if( (mode == GameInfo::GEIER && !allowed->geier) ||
        (mode == GameInfo::GEIER && color != Card::NOCOLOR && !allowed->farb_geier) )
    {
        delete allowed;
        return false;
    }
   
    delete allowed;
    return true;
}


Generated by  Doxygen 1.6.0   Back to index