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; }
virtual void onDamaged(ServerPlayer *target, const DamageStruct &damage) const{ Room *room = target->getRoom(); if (!target->askForSkillInvoke(objectName(), QVariant::fromValue(damage))) return; room->broadcastSkillInvoke(objectName()); QList<int> card_ids = room->getNCards(4); room->fillAG(card_ids); QList<int> to_get, to_throw; while (true) { int sum = 0; foreach (int id, to_get) sum += Sanguosha->getCard(id)->getNumber(); foreach (int id, card_ids) { if (sum + Sanguosha->getCard(id)->getNumber() >= 13) { room->takeAG(NULL, id, false); card_ids.removeOne(id); to_throw << id; } } if (card_ids.isEmpty()) break; int card_id = room->askForAG(target, card_ids, card_ids.length() < 4, objectName()); if (card_id == -1) break; card_ids.removeOne(card_id); to_get << card_id; room->takeAG(target, card_id, false); if (card_ids.isEmpty()) break; } DummyCard *dummy = new DummyCard; if (!to_get.isEmpty()) { dummy->addSubcards(to_get); target->obtainCard(dummy); } dummy->clearSubcards(); if (!to_throw.isEmpty() || !card_ids.isEmpty()) { dummy->addSubcards(to_throw + card_ids); CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, target->objectName(), objectName(), QString()); room->throwCard(dummy, reason, NULL); } delete dummy; room->clearAG(); }