コード例 #1
0
ファイル: ClientApp.cpp プロジェクト: BillXu/NewProject
SpriteFrame* CClientApp::getCardSpriteByCompsiteNum(uint16_t nNum )
{
	CCard tc ;
	tc.RsetCardByCompositeNum(nNum);
	std::string spriteValue  ;
	uint8_t nType = 0 ;
	switch ( tc.GetType() )
	{
	case CCard::eCard_Diamond:
		nType = 4 ;
		break;
	case CCard::eCard_Heart:
		nType = 2 ;
		break;
	case CCard::eCard_Sword:
		nType = 1 ;
		break;
	case CCard::eCard_Club:
		nType = 3 ;
		break;
	default:
		break;
	}

	if ( nType == 0 || tc.GetCardCompositeNum() == 0 )
	{
		return nullptr ;
	}

	if ( tc.GetCardFaceNum(true) <= 9 )
	{
		spriteValue = String::createWithFormat("card-%d0%d.png",nType,tc.GetCardFaceNum(true))->getCString();
	}
	else
	{
		spriteValue = String::createWithFormat("card-%d0%c.png",nType,'a'+ tc.GetCardFaceNum(true)%10)->getCString();
	}

	return SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteValue.c_str());
}
コード例 #2
0
ファイル: TaxasRobotBrain.cpp プロジェクト: BillXu/NewProject
CTaxasAINode::eAIActionType CTaxasRobotBrain::getAction(unsigned int nMostBetTimesBlind, int& addTimesBlind, char nDemondRound )
{
	unsigned char nRound = 0 ;
	switch ( m_tPeerCard.getAllCardCnt() )
	{
	case 2:
		{
			nRound = 0 ;
		}
		break;
	case 5:
		{
			nRound = 1 ;
		}
		break;
	case 6:
		{
			nRound = 2 ;
		}
		break;
	case 7:
		{
			nRound = 3 ;
		}
		break;
	default:
		assert(0 && "receive card error ,pls check you logic" );
		return CTaxasAINode::eAIAct_Pass;
	}

	if ( nDemondRound != -1 )
	{
		if ( nRound >= nDemondRound )
		{
			nRound = nDemondRound ;
		}
		else
		{
			assert(0 && "receieved cards not enough for your demond round " );
		}
	}

	unsigned char nCardType = 0 ;
	unsigned char nKeyCardFaceValue = 0 ;
	unsigned char nContributeCnt = 0 ;
	if ( 0 == nRound )
	{
		nContributeCnt = 2 ;
		CCard left , right ;
		unsigned char vHoldCard[2] = {m_tPeerCard.GetPrivateCard(0),m_tPeerCard.GetPrivateCard(1)} ;
		left.RsetCardByCompositeNum(vHoldCard[0]);
		right.RsetCardByCompositeNum(vHoldCard[1]);
		nKeyCardFaceValue = left.GetCardFaceNum(true) > right.GetCardFaceNum(true) ? left.GetCardFaceNum(true) : right.GetCardFaceNum(true) ;
		if ( left.GetCardFaceNum() == right.GetCardFaceNum() )
		{
			nCardType = CTaxasPokerPeerCard::eCard_YiDui ;
		}
		else if ( left.GetType() == right.GetType() )
		{
			nCardType = CTaxasPokerPeerCard::eCard_TongHua ;
		}
		else if ( abs(left.GetCardFaceNum() - right.GetCardFaceNum()) == 1 )
		{
			nCardType = CTaxasPokerPeerCard::eCard_ShunZi ;
		}
		else
		{
			nCardType = CTaxasPokerPeerCard::eCard_GaoPai ;
		}
	}
	else
	{
		nCardType = m_tPeerCard.GetCardTypeForRobot(nContributeCnt,nKeyCardFaceValue);
	}

    return m_tAiCore.getAction(nRound,nCardType,nContributeCnt,nKeyCardFaceValue,nMostBetTimesBlind,addTimesBlind) ;
}