bool Slash::IsAvailable(const Player *player, const Card *slash, bool considerSpecificAssignee) { Slash *newslash = new Slash(Card::NoSuit, 0); newslash->deleteLater(); #define THIS_SLASH (slash == NULL ? newslash : slash) if (player->isCardLimited(THIS_SLASH, Card::MethodUse)) return false; if (Sanguosha->getCurrentCardUseReason() == CardUseStruct::CARD_USE_REASON_PLAY) { QList<int> ids; if (slash) { if (slash->isVirtualCard()) { if (slash->subcardsLength() > 0) ids = slash->getSubcards(); } else { ids << slash->getEffectiveId(); } } bool has_weapon = player->hasWeapon("Crossbow") && ids.contains(player->getWeapon()->getEffectiveId()); if ((!has_weapon && player->hasWeapon("Crossbow")) || player->canSlashWithoutCrossbow(THIS_SLASH)) return true; if (considerSpecificAssignee) { QStringList assignee_list = player->property("extra_slash_specific_assignee").toString().split("+"); if (!assignee_list.isEmpty()) { foreach (const Player *p, player->getAliveSiblings()) { if (assignee_list.contains(p->objectName()) && player->canSlash(p, THIS_SLASH)) return true; } } }
const Card *WuxinCard::validate(CardUseStruct &cardUse) const{ QList<int> skysoldier = cardUse.from->getPile("skysoldier"); QList<int> black_skysoldier, disabled_skysoldier; foreach(int id, skysoldier){ if (Sanguosha->getCard(id)->isBlack()){ Slash *theslash = new Slash(Card::SuitToBeDecided, -1); theslash->setSkillName("wuxin"); theslash->addSubcard(id); theslash->deleteLater(); bool can_slash = theslash->isAvailable(cardUse.from) && theslash->targetsFeasible(ServerPlayerList2PlayerList(cardUse.to), cardUse.from); if (can_slash) black_skysoldier << id; else disabled_skysoldier << id; } else disabled_skysoldier << id; } if (black_skysoldier.isEmpty()) return NULL; Room *room = cardUse.from->getRoom(); room->fillAG(skysoldier, cardUse.from, disabled_skysoldier); int slash_id = room->askForAG(cardUse.from, black_skysoldier, false, "wuxin"); room->clearAG(cardUse.from); Slash *slash = new Slash(Card::SuitToBeDecided, -1); slash->addSubcard(slash_id); slash->setSkillName("wuxin"); return slash; }
bool WuxinCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{ foreach(int id, Self->getPile("skysoldier")){ if (Sanguosha->getCard(id)->isBlack()){ Slash *theslash = new Slash(Card::SuitToBeDecided, -1); theslash->setSkillName("wuxin"); theslash->addSubcard(id); theslash->deleteLater(); bool can_slash = theslash->isAvailable(Self) && theslash->targetsFeasible(targets, Self); if (can_slash) return true; } } return false; }
bool Slash::IsAvailable(const Player *player, const Card *slash) { Slash *newslash = new Slash(Card::NoSuit, 0); newslash->deleteLater(); #define THIS_SLASH (slash == NULL ? newslash : slash) if (player->isCardLimited(THIS_SLASH, Card::MethodUse)) return false; if (player->hasWeapon("Crossbow") || player->canSlashWithoutCrossbow(THIS_SLASH)) return true; int used = player->getSlashCount(); int valid = 1 + Sanguosha->correctCardTarget(TargetModSkill::Residue, player, newslash); if (player->hasWeapon("VSCrossbow") && used < valid + 3) return true; return false; #undef THIS_SLASH }
bool JijiangCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{ Slash *slash = new Slash(NoSuit, 0); slash->deleteLater(); return slash->targetFilter(targets, to_select, Self); }