Exemplo n.º 1
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);
    }
}
Exemplo n.º 2
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);
        }

}
Exemplo n.º 3
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);
}