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; }
QString Card::toString() const{ if(!isVirtualCard()) return QString::number(id); else return QString("%1:%2[%3:%4]=%5") .arg(objectName()).arg(skill_name) .arg(getSuitString()).arg(getNumberString()).arg(subcardString()); }
int Card::getEffectiveId() const{ if (isVirtualCard()) { if (subcards.isEmpty()) return -1; else return subcards.first(); } else return m_id; }
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); } } }
bool Slash::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{ int slash_targets = 1; if(Self->hasWeapon("halberd") && Self->isLastHandCard(this)){ slash_targets = 3; } bool distance_limit = true; int rangefix = 0; if(isVirtualCard() && getSubcards().length() > 0){ foreach(int card_id, getSubcards()){ if(Self->getWeapon()) if(card_id == Self->getWeapon()->getId()) if(Self->getWeapon()->getRange() > 1) rangefix = qMax((Self->getWeapon()->getRange()), rangefix); if(Self->getOffensiveHorse()) if(card_id == Self->getOffensiveHorse()->getId()) rangefix = qMax(rangefix, 1); } }