Exemplo n.º 1
0
std::pair<CDBTRule::cards_type, int> CDBTRule::getType(const std::vector<int>& cards)
{
	if (isSingle(cards))
		return std::make_pair(type_singal, getWeight(cards[0]));
	else if (isPairs(cards))
		return std::make_pair(type_pairs, getWeightNoRedFive(cards[1]));
	else if (isthree(cards))
		return std::make_pair(type_three, getWeightNoRedFive(cards[2]));
	else if (isBoom(cards))
		return std::make_pair(type_boom, getWeightNoRedFive(cards[cards.size() - 1]));
	else if (isAtom(cards))
		return std::make_pair(type_atom, getWeight(cards[cards.size() - 1]));
	else if (isSister(cards)) {
		//带A
		if (getValue(cards[0]) == 0)
			return std::make_pair(type_sister, getWeightNoRedFive(cards[1]));
		return std::make_pair(type_sister, getWeightNoRedFive(cards[cards.size() - 1]));
	}
	else if (isPlane(cards)) {
		//带A
		if (getValue(cards[0]) == 0)
			return std::make_pair(type_plane, getWeightNoRedFive(cards[2]));
		return std::make_pair(type_plane, getWeightNoRedFive(cards[cards.size() - 1]));
	}
	else if (isThreetwo(cards)){
		//AAABB
		if (getValue(cards[1]) == getValue(cards[2])){
			return std::make_pair(type_three, getWeightNoRedFive(cards[2]));
		}
		//AABBB
		return std::make_pair(type_three, getWeightNoRedFive(cards[4]));
	}
	return std::make_pair(type_unknow, 0);
}
Exemplo n.º 2
0
void GameWidget::newGame()
{
    for(int i=0;i<Max;i++)
    {
        for(int j=0;j<Max;j++)
        {
            map[i][j]->setVisible(false);
            map[i][j]->reBrothers();
            map[i][j]->setInit();
        }
    }
    for(int i=0;i<hCount;i++)
    {
        for(int j=0;j<wCount;j++)
        {
            map[i][j]->setVisible(true);
            connect(map[i][j],SIGNAL(start()),this,SLOT(createGame()));
            connect(map[i][j],SIGNAL(isOpen()),this,SLOT(openBlock()));
            connect(map[i][j],SIGNAL(isBoom()),this,SLOT(gameMiss()));
            connect(map[i][j],SIGNAL(isFlag()),this,SLOT(isFlag()));
            connect(map[i][j],SIGNAL(disFlag()),this,SLOT(disFlag()));

            map[i][j]->unLocked();
        }
    }
    firstRun=1;
    emit mineSum(MineCount);
}
Exemplo n.º 3
0
bool CDBTRule::isThreetwo(const std::vector<int>& cards)
{
	if (cards.size() != 5 || isBoom(cards))
		return false;
	//AAABB
	if (getValue(cards[0]) == getValue(cards[1]) && getValue(cards[0]) == getValue(cards[2])){
		if (isJoker(cards[3]) && cards[3] != cards[4])
			return false;
		if (isJoker(cards[0]) && (cards[0] != cards[1] || cards[0] != cards[2]))
			return false;
		if (getValue(cards[3]) != getValue(cards[4]))
			return false;
		return true;
	}
	//BBAAA
	if (getValue(cards[2]) == getValue(cards[3]) && getValue(cards[2]) == getValue(cards[4])){
		if (isJoker(cards[0]) && cards[0] != cards[1])
			return false;
		if (isJoker(cards[2]) && (cards[2] != cards[3] || cards[2] != cards[4]))
			return false;
		if (getValue(cards[0]) != getValue(cards[1]))
			return false;
		return true;
	}
	return false;
}