Ejemplo n.º 1
0
void TrustAI::activate(CardUseStruct &card_use) {
    QList<const Card *> cards = self->getHandcards();
    foreach (const Card *card, cards) {
        if (card->targetFixed()) {
            if (useCard(card)) {
                card_use.card = card;
                card_use.from = self;
                return;
            }
        }
    }
}
Ejemplo n.º 2
0
void GuiGame::displayHandCards()
{
	static auto availableWidth{_cardsLayoutWidth * 3.f / 4.f};
	auto cardHeight{_selfHandPanel->getSize().y};

	// Clear the panel
	_selfHandPanel->removeAllWidgets();
	_selfHand.clear();

	// do not use an iterator-for loop since i is a used counter variable
	const float distanceBetweenCards{(availableWidth/(static_cast<float>(_selfHandCards.size()) - 1.f)).getValue()};
	for(unsigned i{0U}; i < _selfHandCards.size(); ++i)
	{
		const auto cardData{_context.client->getCardData(_selfHandCards.at(i).id)};
		const auto widthPosition{static_cast<float>(i) * distanceBetweenCards};
		// create a new card
		_selfHand.push_back(std::make_shared<CardWidget>(cardData));
		// Have it sized according to the panel
		_selfHand.back()->setSize(_cardsLayoutWidth / 4.f, cardHeight);
		// Place it one the panel
		_selfHand.back()->setPosition({widthPosition, 0.f});

		////////// Set up callbacks

		// If card is pressed, use the card
		_selfHand.back()->connect("MousePressed", [this, i]()
		{
			useCard(i);
			displayGame();
		});
		// When the mouse enters on the card area
		connectBigCardDisplay(_selfHand.back(), cardData);
		// Add the card to the panel
		_selfHandPanel->add(_selfHand.back());
	}
}
//魔弹处理
void BackgroundEngine::missileProcess(CardEntity* card,int src,int dst)
{
    bool rightOrder;
    BatInfor reply;
    PlayerEntity* nextOpponent;

    //确定传递方向
    nextOpponent = this->getCurrentPlayer()->getNext();
    while(nextOpponent->getColor() == this->currentPlayer->getColor())
        nextOpponent = nextOpponent->getNext();
    if(nextOpponent->getID() == dst)
        rightOrder = true;
    else
        rightOrder = false;

    bool passed[6];
    for(int i = 0;i < this->playerList.size();i++)
    {
        passed[i] = false;
    }
    int missilePoint = 2;

    QList<CardEntity*> cards;


    do
    {
        cards.clear();
        //魔弹传递到下家
        missilePass(rightOrder,dst,src,passed,missilePoint);

        //读取用户回复
        reply = messageBuffer::readBatInfor();

        if(reply.reply == 0)
        {
            //继续传递
            src = dst;
            dst = reply.dstID;
            missilePoint++;
            cards << getCardByID(reply.CardID);
            this->useCard(cards,getPlayerByID(src),getPlayerByID(dst),false);
            continue;
        }
        else if(reply.reply == 1)
        {
            //圣光
            cards << getCardByID(reply.CardID);
            this->useCard(cards,getPlayerByID(dst));
            break;
        }
        else if(reply.reply == 2)
        {
            //无应对
            PlayerEntity* dstPlayer = getPlayerByID(dst);
            bool shieldBlocked = false;
            //检查圣盾
            for(int i = 0;i < dstPlayer->getBasicEffect().size();i++)
            {
                if(dstPlayer->getBasicEffect()[i]->getMagicName() == SHIELDCARD||dstPlayer->getBasicEffect().at(i)->getSpecialityList().contains(tr("天使之墙")))
                {
                    coder.shieldNotic(dst);
                    dstPlayer->removeBasicEffect(dstPlayer->getBasicEffect()[i]);
                    shieldBlocked = true;
                    break;
                }
            }
            if(shieldBlocked)
                break;
            Harm missileHurt;
            missileHurt.harmPoint = missilePoint;
            missileHurt.type = MAGIC;
            //无圣盾,造成伤害
            this->timeLine3(missileHurt,getPlayerByID(src),dstPlayer,"魔弹");
            break;
        }
        else if(reply.reply == 802)
        {
            //继续传递
            src = dst;
            dst = reply.dstID;
            missilePoint++;
            cards << getCardByID(reply.CardID);
            useCard(cards,getPlayerByID(src),getPlayerByID(dst));
            coder.notice("魔导师发动【魔弹融合】");
            continue;
        }

    }while(1);

}