本文整理汇总了C++中Hand::getHandType方法的典型用法代码示例。如果您正苦于以下问题:C++ Hand::getHandType方法的具体用法?C++ Hand::getHandType怎么用?C++ Hand::getHandType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hand
的用法示例。
在下文中一共展示了Hand::getHandType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QList<card> Method::PlayBeatHand(Hand hand)
{
// 先固定住最优顺子,从余下牌中打出
QList<card> left = m_cards;
QList<QList<card> > cardlll=Method(m_player,left).PickOptimalSeqSingles();
for(int i=0;i<cardlll.size();i++)
for(int j=0;j<cardlll[i].size();j++ )
left.removeOne(cardlll[i][j]);
//left.Remove(Method(m_player, left).PickOptimalSeqSingles());
if (hand.getHandType() == Hand_Single) // 如果压单牌,尽量从单张牌中挑
{
QList<QList<card> > singleArray = Method(m_player, left).FindCardsByCount(1);
for (int i = 0; i < singleArray.size(); i++)
{
if (Hand(singleArray[i]).Defeat(hand))
{
return singleArray[i];
}
}
}
else if (hand.getHandType() == Hand_Pair) // 如果压双牌,尽量从双牌中挑
{
QList<QList<card> > pairArray = Method(m_player, left).FindCardsByCount(2);
for (int i = 0; i < pairArray.size(); i++)
{
if (Hand(pairArray[i]).Defeat(hand))
{
return pairArray[i];
}
}
}
Player* nextPlayer = m_player->getNextPlayer();
QList<QList<card> > beatCardsArray = Method(m_player, left).FindHand(hand, true);
if (!beatCardsArray.isEmpty())
{
if (m_player->getRole() != nextPlayer->getRole() &&
nextPlayer->getCards().size() <= 2)
{
return beatCardsArray.back();
}
else
{
return beatCardsArray.front();
}
}
else // 余下牌没法打时,只好从顺子中挑牌
{
beatCardsArray = Method(m_player, m_cards).FindHand(hand, true);
if (!beatCardsArray.isEmpty())
{
if (m_player->getRole() != nextPlayer->getRole() &&
nextPlayer->getCards().size() <= 2)
{
return beatCardsArray.back();
}
else
{
return beatCardsArray.front();
}
}
}
// 对家剩牌小于3张,有炸则炸
Player* hitPlayer = m_player->getHitPlayer();
if (m_player->getRole() != hitPlayer->getRole())
{
if (hitPlayer->getCards().size() <= 3)
{
QList<QList<card> > bombs = FindCardsByCount(4);
if (!bombs.isEmpty())
{
return bombs[0];
}
}
}
QList<card> empty;
empty.clear();
return empty;
}