コード例 #1
0
ファイル: god.cpp プロジェクト: arrow-feather/QSanguosha
 virtual const Card *viewAs(const Card *originalCard) const{
     Slash *slash = new Slash(originalCard->getSuit(), originalCard->getNumber());
     slash->setSkillName(objectName());
     WrappedCard *card = Sanguosha->getWrappedCard(originalCard->getId());
     card->takeOver(slash);
     return card;
 }
コード例 #2
0
bool TrustAI::useCard(const Card *card) {
    if (card->isKindOf("EquipCard")) {
        const EquipCard *equip = qobject_cast<const EquipCard *>(card->getRealCard());
        switch (equip->location()) {
        case EquipCard::WeaponLocation: {
                WrappedCard *weapon = self->getWeapon();
                if (weapon == NULL)
                    return true;
                const Weapon *new_weapon = qobject_cast<const Weapon *>(equip);
                const Weapon *ole_weapon = qobject_cast<const Weapon *>(weapon->getRealCard());
                return new_weapon->getRange() > ole_weapon->getRange();
            }
        case EquipCard::ArmorLocation: return !self->getArmor();
        case EquipCard::OffensiveHorseLocation: return !self->getOffensiveHorse();
        case EquipCard::DefensiveHorseLocation: return !self->getDefensiveHorse();
        default:
                return true;
        }
    }
    return false;
}
コード例 #3
0
void EquipCard::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const{
    WrappedCard *equipped = NULL;
    ServerPlayer *target = targets.value(0, source);
    if (room->getCardOwner(getId()) != source) return;
    switch(location()){
    case WeaponLocation: equipped = target->getWeapon(); break;
    case ArmorLocation: equipped = target->getArmor(); break;
    case DefensiveHorseLocation: equipped = target->getDefensiveHorse(); break;
    case OffensiveHorseLocation: equipped = target->getOffensiveHorse(); break;
    }

    if (room->getCardPlace(getId()) == Player::PlaceHand)
        {
            QList<CardsMoveStruct> exchangeMove;
            CardsMoveStruct move1;
            move1.card_ids << getId();
            move1.to = target;
            move1.to_place = Player::PlaceEquip;
            move1.reason = CardMoveReason(CardMoveReason::S_REASON_USE, target->objectName());
            exchangeMove.push_back(move1);
            if(equipped)
            {
                CardsMoveStruct move2;
                move2.card_ids << equipped->getId();
                move2.to = NULL;
                move2.to_place = Player::DiscardPile;
                move2.reason = CardMoveReason(CardMoveReason::S_REASON_CHANGE_EQUIP, target->objectName());
                exchangeMove.push_back(move2);
            }
            LogMessage log;
            log.from = target;
            log.type = "$Install";
            log.card_str = QString::number(getEffectiveId());
            room->sendLog(log);

            room->moveCardsAtomic(exchangeMove, true);
        }

}
コード例 #4
0
QWidget *PlayerCardDialog::createEquipArea() {
    QGroupBox *area = new QGroupBox(tr("Equip area"));
    QVBoxLayout *layout = new QVBoxLayout;

    WrappedCard *weapon = player->getWeapon();
    if (weapon) {
        PlayerCardButton *button = new PlayerCardButton(weapon->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(weapon->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(weapon->getEffectiveId())
                            && (method != Card::MethodDiscard || Self->canDiscard(player, weapon->getEffectiveId())));
        mapper.insert(button, weapon->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    WrappedCard *armor = player->getArmor();
    if (armor) {
        PlayerCardButton *button = new PlayerCardButton(armor->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(armor->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(armor->getEffectiveId())
                            && (method != Card::MethodDiscard || Self->canDiscard(player, armor->getEffectiveId())));
        mapper.insert(button, armor->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    WrappedCard *horse = player->getDefensiveHorse();
    if (horse) {
        PlayerCardButton *button = new PlayerCardButton(horse->getFullName() + tr("(+1 horse)"));
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(horse->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(horse->getEffectiveId())
                            && (method != Card::MethodDiscard || Self->canDiscard(player, horse->getEffectiveId())));
        mapper.insert(button, horse->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    horse = player->getOffensiveHorse();
    if (horse) {
        PlayerCardButton *button = new PlayerCardButton(horse->getFullName() + tr("(-1 horse)"));
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(horse->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(horse->getEffectiveId())
                            && (method != Card::MethodDiscard || Self->canDiscard(player, horse->getEffectiveId())));
        mapper.insert(button, horse->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    WrappedCard *treasure = player->getTreasure();
    if (treasure) {
        PlayerCardButton *button = new PlayerCardButton(treasure->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(treasure->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(treasure->getEffectiveId())
            && (method != Card::MethodDiscard || Self->canDiscard(player, treasure->getEffectiveId())));
        mapper.insert(button, treasure->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    if (layout->count() == 0) {
        PlayerCardButton *no_equip = new PlayerCardButton(tr("No equip"));
        no_equip->setEnabled(false);
        no_equip->setObjectName("noequip_button");
        return no_equip;
    } else {
        area->setLayout(layout);
        return area;
    }
}