virtual bool onPhaseChange(ServerPlayer *zhangliang) const{ Room *room = zhangliang->getRoom(); if(zhangliang->getPhase() != Player::Draw) return false; QList<ServerPlayer *> players = room->getOtherPlayers(zhangliang); foreach(ServerPlayer *p, players){ if(p->isKongcheng()) players.removeOne(p); } if(players.isEmpty() || !zhangliang->askForSkillInvoke(objectName())) return false; room->playSkillEffect(objectName()); ServerPlayer *rengonger = room->askForPlayerChosen(zhangliang, players, objectName()); QList<int> handcards = rengonger->handCards(); room->fillAG(handcards, zhangliang); int card_id = room->askForAG(zhangliang, handcards, false, objectName()); room->moveCardTo(Sanguosha->getCard(card_id), zhangliang, Player::Hand, false); room->broadcastInvoke("clearAG"); return true; }
virtual bool onPhaseChange(ServerPlayer *wangyi) const{ if(!wangyi->isWounded()) return false; if(wangyi->getPhase() == Player::Start || wangyi->getPhase() == Player::Finish){ if(!wangyi->askForSkillInvoke(objectName())) return false; Room *room = wangyi->getRoom(); room->broadcastSkillInvoke(objectName(), 1); JudgeStruct judge; judge.pattern = QRegExp("(.*):(club|spade):(.*)"); judge.good = true; judge.reason = objectName(); judge.who = wangyi; room->judge(judge); if(judge.isGood()){ int x = wangyi->getLostHp(); wangyi->drawCards(x); //It should be preview, not draw ServerPlayer *target = room->askForPlayerChosen(wangyi, room->getAllPlayers(), objectName()); if (target == wangyi) room->broadcastSkillInvoke(objectName(), 2); else if (target->getGeneralName().contains("machao")) room->broadcastSkillInvoke(objectName(), 4); else room->broadcastSkillInvoke(objectName(), 3); QList<const Card *> miji_cards = wangyi->getHandcards().mid(wangyi->getHandcardNum() - x); foreach(const Card *card, miji_cards){ CardMoveReason reason(CardMoveReason::S_REASON_GIVE, wangyi->objectName()); reason.m_playerId == target->objectName(); room->obtainCard(target, card, reason, false); } }
virtual bool onPhaseChange(ServerPlayer *wangyi) const{ if(!wangyi->isWounded()) return false; if(wangyi->getPhase() == Player::Start || wangyi->getPhase() == Player::Finish){ if(!wangyi->askForSkillInvoke(objectName())) return false; Room *room = wangyi->getRoom(); JudgeStruct judge; judge.pattern = QRegExp("(.*):(club|spade):(.*)"); judge.good = true; judge.reason = objectName(); judge.who = wangyi; room->judge(judge); if(judge.isGood()){ room->playSkillEffect(objectName()); int x = wangyi->getLostHp(); wangyi->drawCards(x); ServerPlayer *target = room->askForPlayerChosen(wangyi, room->getAllPlayers(), objectName()); QList<const Card *> miji_cards = wangyi->getHandcards().mid(wangyi->getHandcardNum() - x); foreach(const Card *card, miji_cards) room->obtainCard(target, card, false); } }
void QuhuCard::onEffect(const CardEffectStruct &effect) const{ ServerPlayer *xunyu = effect.from; ServerPlayer *tiger = effect.to; Room *room = xunyu->getRoom(); bool success = room->pindian(xunyu, tiger); if(success){ QList<ServerPlayer *> players = room->getOtherPlayers(tiger), wolves; foreach(ServerPlayer *player, players){ if(tiger->inMyAttackRange(player)) wolves << player; } if(wolves.isEmpty()) return; ServerPlayer *wolf = room->askForPlayerChosen(xunyu, wolves); DamageStruct damage; damage.from = tiger; damage.to = wolf; room->damage(damage); }else{
virtual int getDrawNum(ServerPlayer *play2, int n) const{ Room *room = play2->getRoom(); if(room->askForSkillInvoke(play2, objectName())){ room->playSkillEffect(objectName()); ServerPlayer *target = room->askForPlayerChosen(play2, room->getOtherPlayers(play2), objectName()); room->setFixedDistance(play2, target, 0); play2->setFlags(objectName()); play2->tag["XD"] = QVariant::fromValue((PlayerStar)target); return n - 1; }else return n; }
void XuanhuoCard::onEffect(const CardEffectStruct &effect) const{ effect.to->obtainCard(this); Room *room = effect.from->getRoom(); int card_id = room->askForCardChosen(effect.from, effect.to, "he", "xuanhuo"); const Card *card = Sanguosha->getCard(card_id); room->moveCardTo(card, effect.from, Player::Hand, false); QList<ServerPlayer *> targets = room->getOtherPlayers(effect.to); ServerPlayer *target = room->askForPlayerChosen(effect.from, targets, "xuanhuo"); if(target != effect.from) room->moveCardTo(card, target, Player::Hand, false); card_id = room->askForCardChosen(effect.from, effect.to, "he", "xuanhuo"); card = Sanguosha->getCard(card_id); room->moveCardTo(card, effect.from, Player::Hand, false); targets = room->getOtherPlayers(effect.to); target = room->askForPlayerChosen(effect.from, targets, "xuanhuo"); if(target != effect.from) room->moveCardTo(card, target, Player::Hand, false); }
virtual void onDamaged(ServerPlayer *player, const DamageStruct &damage) const{ Room *room = player->getRoom(); if(damage.damage != 1 || !damage.from || damage.from == player) return; if(room->askForSkillInvoke(player, objectName(), QVariant::fromValue(damage))){ ServerPlayer *target = room->askForPlayerChosen(player, room->getOtherPlayers(damage.from), objectName()); Slash *slash = new Slash(Card::NoSuit, 0); slash->setSkillName(objectName()); CardUseStruct use; use.card = slash; use.from = damage.from; use.to << target; room->useCard(use, false); } }
virtual bool trigger(TriggerEvent , ServerPlayer *player, QVariant &data) const{ DamageStruct damage = data.value<DamageStruct>(); Room *room = player->getRoom(); if(damage.card && damage.card->inherits("Slash")){ QString choice = room->askForChoice(player, "muramasa", "sky+yks"); if(choice=="yks") damage.from = NULL; else { QList<ServerPlayer *> players = room->getAllPlayers(); ServerPlayer *target = room->askForPlayerChosen(player, players, "muramasa"); damage.from = target; } if(damage.from==player) return false; room->damage(damage); return true; } }
virtual bool onPhaseChange(ServerPlayer *wangyi) const{ if(!wangyi->isWounded()) return false; if(wangyi->getPhase() == Player::Start || wangyi->getPhase() == Player::Finish){ if(!wangyi->askForSkillInvoke(objectName())) return false; Room *room = wangyi->getRoom(); JudgeStruct judge; judge.pattern = QRegExp("(.*):(club|spade):(.*)"); judge.good = true; judge.reason = objectName(); judge.who = wangyi; room->judge(judge); if(judge.isGood()){ int x = wangyi->getLostHp(); LogMessage log; log.type = "#WatchNCards"; log.from = wangyi; log.arg = QString::number(x); room->sendLog(log); room->playSkillEffect(objectName()); QList<int> miji_cards = room->getNCards(x, false); room->fillAG(miji_cards, wangyi); room->askForAG(wangyi, miji_cards, true, objectName()); room->broadcastInvoke("clearAG"); room->addToDrawPile(miji_cards); ServerPlayer *target = room->askForPlayerChosen(wangyi, room->getAllPlayers(), objectName()); log.type = "#Miji"; log.arg = objectName(); log.to << target; room->sendLog(log); target->drawCards(x, false); } } return false; }
virtual int getDrawNum(ServerPlayer *zhangliao, int n) const{ Room *room = zhangliao->getRoom(); bool can_invoke = false; QList<ServerPlayer *> targets; foreach (ServerPlayer *p, room->getOtherPlayers(zhangliao)) if (p->getHandcardNum() > zhangliao->getHandcardNum()) targets << p; if (!targets.isEmpty()) can_invoke = true; if (can_invoke) { ServerPlayer *target = room->askForPlayerChosen(zhangliao, targets, objectName(), "koftuxi-invoke", true, true); if (target) { target->setFlags("KOFTuxiTarget"); zhangliao->setFlags("koftuxi"); return n - 1; } else { return n; } } else return n; }