示例#1
0
winner compareHands(uint8_t * const handA, uint8_t * const handB) {
    uint32_t valA = getHandValue(handA);
    uint32_t valB = getHandValue(handB);
    if(valA == valB)
        return tieBreaker(handA,handB);
    else
        return valA > valB ? PLAYER_ONE : PLAYER_TWO;
}
示例#2
0
void Hand::pushCard(CardInfo& card, float delay /*= 0.f*/)
{
	if (card._number == 0 || card._shape == CardInfo::CardShape::EMPTY)
		return;

	_cardInfos[_handNum] = card;

	auto& cardSpr = _cardSprites[_handNum];
	auto spawn = Spawn::create( MoveTo::create(0.3f, cardSpr->getPosition()), RotateTo::create(0.3f, 0), nullptr);
	auto callFunc = CallFunc::create(CC_CALLBACK_0(Sprite::setVisible, cardSpr, true));
	auto dieFunc = CallFunc::create(CC_CALLBACK_0(Hand::Die, this, .5f));
	if (getHandValue().first <= 21)
		dieFunc = nullptr;
	auto seq = Sequence::create(DelayTime::create(delay),callFunc, spawn,dieFunc, nullptr);
	cardSpr->setPosition(cardSpr->getPosition() + Vec2(0,100));
	cardSpr->setRotation(180);
	
	// 해당 카드 모양에 맞는 스프라이트로 설정
	auto sprFrame = SpriteFrameCache::getInstance()->
		getSpriteFrameByName(FILENAME::SPRITE::CARD_ARRAY[card._shape][card._number]);
	cardSpr->setSpriteFrame(sprFrame);
	cardSpr->setVisible(false);
	cardSpr->runAction(seq);
	++_handNum;
}
示例#3
0
bool Player::canAct()
{
    return getHandValue() < 21;
}