Esempio n. 1
0
    bool trigger(TriggerEvent, Room *room, ServerPlayer *player, QVariant &data) const{
        PhaseChangeStruct change = data.value<PhaseChangeStruct>();
        if (change.to != Player::NotActive) return false;
        int weapon_id = player->tag.value("DrJiedaoWeapon", -1).toInt();
        player->tag["DrJiedaoWeapon"] = -1;
        if (!player->getWeapon()
            || weapon_id != player->getWeapon()->getEffectiveId())
            return false;
        ServerPlayer *target = NULL;
        foreach (ServerPlayer *p, room->getOtherPlayers(player))
            if (p->hasFlag("DrJiedaoTarget")) {
                p->setFlags("-DrJiedaoTarget");
                target = p;
                break;
            }
        if (target == NULL) {
            room->throwCard(player->getWeapon(), NULL);
        } else {
            QList<CardsMoveStruct> exchangeMove;
            CardsMoveStruct move1(player->getWeapon()->getEffectiveId(), target, Player::PlaceEquip,
                                  CardMoveReason(CardMoveReason::S_REASON_GOTCARD, player->objectName()));
            exchangeMove.push_back(move1);
            if (target->getWeapon() != NULL) {
                CardsMoveStruct move2(target->getWeapon()->getEffectiveId(), NULL, Player::DiscardPile,
                                      CardMoveReason(CardMoveReason::S_REASON_CHANGE_EQUIP, target->objectName()));
                exchangeMove.push_back(move2);
            }
            room->moveCardsAtomic(exchangeMove, true);
        }

        return false;
    }
Esempio n. 2
0
void EquipCard::use(Room *room, ServerPlayer *source, const QList<ServerPlayer *> &targets) const{
    const EquipCard *equipped = NULL;
    ServerPlayer *target = targets.value(0, source);
    
    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(equipped)
        room->throwCard(equipped, source);
    int tmpId = -1;
    if(getId() > -1)
        tmpId = getId();
    else if(!getSubcards().empty())
       tmpId = this->getSubcards().first();
    if(this->objectName() == "gale-shell" || room->getCardOwner(tmpId)->objectName() == target->objectName()){
        LogMessage log;
        log.from = target;
        log.type = "$Install";
        log.card_str = QString::number(tmpId);
        room->sendLog(log);
        room->moveCardTo(this, target, Player::Equip, true);
    }
}
Esempio n. 3
0
void EquipCard::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const{
    const EquipCard *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);
        }

}
Esempio n. 4
0
void EquipCard::use(Room *room, ServerPlayer *source, const QList<ServerPlayer *> &targets) const{
    const EquipCard *equipped = NULL;
    ServerPlayer *target = targets.value(0, source);
    
    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(equipped)
        room->throwCard(equipped, source);

    LogMessage log;
    log.from = target;
    log.type = "$Install";
    log.card_str = QString::number(getEffectiveId());
    room->sendLog(log);

    room->moveCardTo(this, target, Player::Equip, true);
}