void EquipCard::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const { if (targets.isEmpty()) { CardMoveReason reason(CardMoveReason::S_REASON_USE, source->objectName(), QString(), this->getSkillName(), QString()); room->moveCardTo(this, NULL, Player::DiscardPile, reason, true); } int equipped_id = Card::S_UNKNOWN_CARD_ID; ServerPlayer *target = targets.first(); if (target->getEquip(location())) equipped_id = target->getEquip(location())->getEffectiveId(); QList<CardsMoveStruct> exchangeMove; CardsMoveStruct move1(getEffectiveId(), target, Player::PlaceEquip, CardMoveReason(CardMoveReason::S_REASON_USE, target->objectName())); exchangeMove.push_back(move1); if (equipped_id != Card::S_UNKNOWN_CARD_ID) { CardsMoveStruct move2(equipped_id, NULL, Player::DiscardPile, 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); }
void DelayedTrick::onEffect(const CardEffectStruct &effect) const { Room *room = effect.to->getRoom(); CardMoveReason reason(CardMoveReason::S_REASON_USE, effect.to->objectName(), getSkillName(), QString()); room->moveCardTo(this, NULL, Player::PlaceTable, reason, true); LogMessage log; log.from = effect.to; log.type = "#DelayedTrick"; log.arg = effect.card->objectName(); room->sendLog(log); JudgeStruct judge_struct = judge; judge_struct.who = effect.to; room->judge(judge_struct); if (judge_struct.isBad()) { takeEffect(effect.to); if (room->getCardOwner(getEffectiveId()) == NULL) { CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, QString()); room->throwCard(this, reason, NULL); } } else if (movable) { onNullified(effect.to); } else { if (room->getCardOwner(getEffectiveId()) == NULL) { CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, QString()); room->throwCard(this, reason, NULL); } } }
void DelayedTrick::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const{ if (targets.isEmpty()) { if (movable) { onNullified(source); if (room->getCardOwner(getEffectiveId()) != source) return; } CardMoveReason reason(CardMoveReason::S_REASON_USE, source->objectName(), QString(), this->getSkillName(), QString()); room->moveCardTo(this, room->getCardOwner(getEffectiveId()), NULL, Player::DiscardPile, reason, true); } }
void DelayedTrick::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const { QStringList nullified_list = room->getTag("CardUseNullifiedList").toStringList(); bool all_nullified = nullified_list.contains("_ALL_TARGETS"); if (all_nullified || targets.isEmpty()) { if (movable) { onNullified(source); if (room->getCardOwner(getEffectiveId()) != source) return; } CardMoveReason reason(CardMoveReason::S_REASON_USE, source->objectName(), QString(), this->getSkillName(), QString()); room->moveCardTo(this, room->getCardOwner(getEffectiveId()), NULL, Player::DiscardPile, reason, true); } }
void DelayedTrick::onEffect(const CardEffectStruct &effect) const { Room *room = effect.to->getRoom(); CardMoveReason reason(CardMoveReason::S_REASON_USE, effect.to->objectName(), getSkillName(), QString()); room->moveCardTo(this, NULL, Player::PlaceTable, reason, true); LogMessage log; log.from = effect.to; log.type = "#DelayedTrick"; log.arg = effect.card->objectName(); room->sendLog(log); JudgeStruct judge_struct = judge; judge_struct.who = effect.to; room->judge(judge_struct); if (judge_struct.negative == judge_struct.isBad()) { if (effect.to->isAlive()) takeEffect(effect.to); if (room->getCardOwner(getEffectiveId()) == NULL) { CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, QString()); room->throwCard(this, reason, NULL); } } else if (movable) { onNullified(effect.to); } else if (returnable && effect.to->isAlive()) { if (room->getCardOwner(getEffectiveId()) == NULL) { if (isVirtualCard()) { Card *delayTrick = Sanguosha->cloneCard(objectName()); WrappedCard *vs_card = Sanguosha->getWrappedCard(getEffectiveId()); vs_card->setSkillName(getSkillName()); vs_card->takeOver(delayTrick); room->broadcastUpdateCard(room->getAlivePlayers(), vs_card->getId(), vs_card); } CardsMoveStruct move; move.card_ids << getEffectiveId(); move.to = effect.to; move.to_place = Player::PlaceDelayedTrick; room->moveCardsAtomic(move, true); } } else { if (room->getCardOwner(getEffectiveId()) == NULL) { CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, QString()); room->throwCard(this, reason, NULL); } } }
void EquipCard::use(Room *room, ServerPlayer *, QList<ServerPlayer *> &targets) const{ int equipped_id = Card::S_UNKNOWN_CARD_ID; ServerPlayer *target = targets.first(); if (target->getEquip(location())) equipped_id = target->getEquip(location())->getEffectiveId(); 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_id != Card::S_UNKNOWN_CARD_ID) { CardsMoveStruct move2; move2.card_ids << equipped_id; 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); }
bool IronChain::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{ bool rec = (Sanguosha->currentRoomState()->getCurrentCardUseReason() == CardUseStruct::CARD_USE_REASON_PLAY); QList<int> sub; if (isVirtualCard()) sub = subcards; else sub << getEffectiveId(); foreach (int id, sub) { if (Self->getPile("wooden_ox").contains(id)) { rec = false; break; } } if (rec && Self->isCardLimited(this, Card::MethodUse)) return targets.length() == 0; if (Sanguosha->currentRoomState()->getCurrentCardUseReason() == CardUseStruct::CARD_USE_REASON_RESPONSE_USE) return targets.length() != 0; int total_num = 2 + Sanguosha->correctCardTarget(TargetModSkill::ExtraTarget, Self, this); if (!rec || getSkillName().contains("guhuo") || getSkillName() == "qice") //why dirty hack? return targets.length() > 0 && targets.length() <= total_num; else return targets.length() <= total_num; }
void DelayedTrick::onUse(Room *room, const CardUseStruct &card_use) const { CardUseStruct use = card_use; WrappedCard *wrapped = Sanguosha->getWrappedCard(getEffectiveId()); use.card = wrapped; LogMessage log; log.from = use.from; log.to = use.to; log.type = "#UseCard"; log.card_str = toString(); room->sendLog(log); QVariant data = QVariant::fromValue(use); RoomThread *thread = room->getThread(); thread->trigger(PreCardUsed, room, data); //CardMoveReason reason(CardMoveReason::S_REASON_USE, use.from->objectName(), use.to.first()->objectName(), getSkillName(), QString()); //room->moveCardTo(this, use.from, use.to.first(), Player::PlaceDelayedTrick, reason, true); CardMoveReason reason(CardMoveReason::S_REASON_USE, use.from->objectName(), QString(), card_use.card->getSkillName(), QString()); CardsMoveStruct move(card_use.card->getEffectiveId(), NULL, Player::PlaceTable, reason); room->moveCardsAtomic(move, true); //show hidden after move Event to avoid filter card use.from->showHiddenSkill(getSkillName()); thread->trigger(CardUsed, room, data); thread->trigger(CardFinished, room, data); }
void EquipCard::use(Room *room, ServerPlayer *source, const QList<ServerPlayer *> &) const{ const EquipCard *equipped = NULL; switch(location()){ case WeaponLocation: equipped = source->getWeapon(); break; case ArmorLocation: equipped = source->getArmor(); break; case DefensiveHorseLocation: equipped = source->getDefensiveHorse(); break; case OffensiveHorseLocation: equipped = source->getOffensiveHorse(); break; } if(equipped) room->throwCard(equipped); LogMessage log; log.from = source; log.type = "$Install"; log.card_str = QString::number(getEffectiveId()); room->sendLog(log); room->moveCardTo(this, source, Player::Equip, true); }
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); } }
QString Card::getEffectIdString() const{ return QString::number(getEffectiveId()); }