virtual bool trigger(TriggerEvent , ServerPlayer *player, QVariant &data) const{ Room *room = player->getRoom(); JudgeStar judge = data.value<JudgeStar>(); QStringList prompt_list; prompt_list << "@guidao-card" << judge->who->objectName() << "" << judge->reason << judge->card->getEffectIdString(); QString prompt = prompt_list.join(":"); player->tag["Judge"] = data; const Card *card = room->askForCard(player, "@guidao", prompt); if(card){ // the only difference for Guicai & Guidao player->obtainCard(judge->card); judge->card = Sanguosha->getCard(card->getEffectiveId()); room->moveCardTo(judge->card, NULL, Player::Special); LogMessage log; log.type = "$ChangedJudge"; log.from = player; log.to << judge->who; log.card_str = card->getEffectIdString(); room->sendLog(log); room->sendJudgeResult(judge); } return false; }
virtual bool trigger(TriggerEvent, ServerPlayer *caocao, QVariant &data) const{ QString pattern = data.toString(); if(pattern != "jink") return false; Room *room = caocao->getRoom(); QList<ServerPlayer *> lieges = room->getLieges("wei", caocao); if(lieges.isEmpty()) return false; if(!room->askForSkillInvoke(caocao, objectName())) return false; room->playSkillEffect(objectName()); QVariant tohelp = QVariant::fromValue((PlayerStar)caocao); foreach(ServerPlayer *liege, lieges){ const Card *jink = room->askForCard(liege, "jink", "@hujia-jink:" + caocao->objectName(), tohelp); if(jink){ room->provide(jink); return true; } } return false; }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashEffectStruct effect = data.value<SlashEffectStruct>(); Room *room = player->getRoom(); if(effect.from->getGeneral()->isMale() != effect.to->getGeneral()->isMale()){ if(effect.from->askForSkillInvoke(objectName())){ bool draw_card = false; if(effect.to->isKongcheng()) draw_card = true; else{ QString prompt = "double-sword-card:" + effect.from->getGeneralName(); const Card *card = room->askForCard(effect.to, ".", prompt, QVariant(), CardDiscarded); if(card){ room->throwCard(card); }else draw_card = true; } if(draw_card) effect.from->drawCards(1); } } return false; }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ Room *room = player->getRoom(); DamageStruct damage = data.value<DamageStruct>(); room->setPlayerMark(player, "BlackArmor", damage.damage); if(!player->isWounded() || player->getCards("h").length() < damage.damage) return false; CardStar card = room->askForCard(player, "@black_armor", "@black_armor"); if(card){ QList<int> card_ids = card->getSubcards(); foreach(int card_id, card_ids){ LogMessage log; log.type = "$DiscardCard"; log.from = player; log.card_str = QString::number(card_id); room->sendLog(log); } LogMessage log; log.type = "#BlackArmorSkill"; log.from = player; room->sendLog(log); RecoverStruct recover; recover.card = card; recover.recover = qMin(damage.damage, player->getLostHp()); recover.who = player; room->recover(player, recover); room->setPlayerMark(player, "BlackArmor", 0); return true; }
void FireAttack::onEffect(const CardEffectStruct &effect) const{ Room *room = effect.from->getRoom(); if(effect.to->isKongcheng()) return; const Card *card = room->askForCardShow(effect.to, effect.from, objectName()); if(card->getEffectiveId() < 0 && !card->getSubcards().empty()) room->showCard(effect.to, Sanguosha->getCard(card->getSubcards().first())->getId()); else room->showCard(effect.to, card->getEffectiveId()); QString suit_str = card->getSuitString(); QString pattern = QString(".%1").arg(suit_str.at(0).toUpper()); QString prompt = QString("@fire-attack:%1::%2").arg(effect.to->getGeneralName()).arg(suit_str); if(room->askForCard(effect.from, pattern, prompt, QVariant(), CardDiscarded)){ DamageStruct damage; damage.card = this; damage.from = effect.from; damage.to = effect.to; damage.nature = DamageStruct::Fire; room->damage(damage); } if(card->isVirtualCard()) delete card; }
virtual bool trigger(TriggerEvent, ServerPlayer *caocao, QVariant &data) const{ QString pattern = data.toString(); if(pattern != "jink") return false; Room *room = caocao->getRoom(); QList<ServerPlayer *> lieges = room->getLieges("wei", caocao); if(lieges.isEmpty()) return false; if(!room->askForSkillInvoke(caocao, objectName())) return false; room->playSkillEffect(objectName()); foreach(ServerPlayer *liege, lieges){ QString result = room->askForChoice(liege, objectName(), "accept+ignore"); if(result == "ignore") continue; const Card *jink = room->askForCard(liege, "jink", "@hujia-jink:" + caocao->objectName()); if(jink){ room->provide(jink); return true; } }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashResultStruct result = data.value<SlashResultStruct>(); if(!result.success){ Room *room = player->getRoom(); CardStar card = room->askForCard(player, "@axe-card", "axe-card"); if(card){ QList<int> card_ids = card->getSubcards(); foreach(int card_id, card_ids){ LogMessage log; log.type = "$DiscardCard"; log.from = player; log.card_str = QString::number(card_id); room->sendLog(log); } LogMessage log; log.type = "#AxeSkill"; log.from = player; log.to << result.to; room->sendLog(log); result.success = true; data = QVariant::fromValue(result); }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashEffectStruct effect = data.value<SlashEffectStruct>(); Room *room = player->getRoom(); CardStar card = room->askForCard(player, "@axe", "@axe:" + effect.to->objectName(),data, CardDiscarded); if(card){ QList<int> card_ids = card->getSubcards(); foreach(int card_id, card_ids){ LogMessage log; log.type = "$DiscardCard"; log.from = player; log.card_str = QString::number(card_id); room->sendLog(log); } LogMessage log; log.type = "#AxeSkill"; log.from = player; log.to << effect.to; log.arg = objectName(); room->sendLog(log); room->slashResult(effect, NULL); }
virtual bool onPhaseChange(ServerPlayer *gongsun) const{ Room *room = gongsun->getRoom(); if(gongsun->getPhase() == Player::Finish && gongsun->askForSkillInvoke(objectName())){ gongsun->drawCards(2); room->broadcastSkillInvoke("zhulou", qrand() % 2 + 1); if(!room->askForCard(gongsun, ".Weapon", "@zhulou-discard", QVariant(), CardDiscarded)) room->loseHp(gongsun); } return false; }
bool onPhaseChange(ServerPlayer *gongsun) const { Room *room = gongsun->getRoom(); if (gongsun->getPhase() == Player::Finish && gongsun->askForSkillInvoke(this)) { gongsun->drawCards(2); room->broadcastSkillInvoke("zhulou"); if (!room->askForCard(gongsun, ".Weapon", "@zhulou-discard")) room->loseHp(gongsun); } return false; }
virtual bool onPhaseChange(ServerPlayer *player) const{ if(player->getPhase() != Player::Finish) return false; Room *room = player->getRoom(); QList<ServerPlayer *> splayers = room->findPlayersBySkillName(objectName()); foreach(ServerPlayer *splayer, splayers){ if(player == splayer || splayer->isKongcheng()) continue; if(room->askForCard(splayer, "BasicCard", "@xiaoguo:" + player->objectName(), QVariant::fromValue((PlayerStar)player), CardDiscarded)){ LogMessage log; log.type = "#InvokeSkill"; log.from = splayer; log.arg = objectName(); room->sendLog(log); if(!room->askForCard(player, "EquipCard,TrickCard", "@xiaoguoresponse:" + splayer->objectName(), QVariant(), CardDiscarded)){ room->playSkillEffect(objectName(), qrand() % 2 + 1); LogMessage log; log.type = "#Xiaoguo"; log.from = splayer; log.to << player; log.arg = objectName(); room->sendLog(log); DamageStruct damage; damage.from = splayer; damage.to = player; room->damage(damage); } else room->playSkillEffect(objectName(), 3); } } return false; }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashEffectStruct effect = data.value<SlashEffectStruct>(); if(effect.to->hasSkill("kongcheng") && effect.to->isKongcheng()) return false; Room *room = player->getRoom(); const Card *card = room->askForCard(player, "slash", "blade-slash"); if(card){ // if player is drank, unset his flag if(player->hasFlag("drank")) room->setPlayerFlag(player, "-drank"); room->cardEffect(card, player, effect.to); } return false; }
const Card *JijiangCard::validate(CardUseStruct &cardUse) const{ cardUse.m_isOwnerUse = false; ServerPlayer *liubei = cardUse.from; QList<ServerPlayer *> targets = cardUse.to; Room *room = liubei->getRoom(); liubei->broadcastSkillInvoke(this); room->notifySkillInvoked(liubei, "jijiang"); LogMessage log; log.from = liubei; log.to = targets; log.type = "#UseCard"; log.card_str = toString(); room->sendLog(log); const Card *slash = NULL; QList<ServerPlayer *> lieges = room->getLieges("shu", liubei); foreach (ServerPlayer *target, targets) target->setFlags("JijiangTarget"); foreach (ServerPlayer *liege, lieges) { try { slash = room->askForCard(liege, "slash", "@jijiang-slash:" + liubei->objectName(), QVariant(), Card::MethodResponse, liubei); } catch (TriggerEvent triggerEvent) { if (triggerEvent == TurnBroken || triggerEvent == StageChange) { foreach (ServerPlayer *target, targets) target->setFlags("-JijiangTarget"); } throw triggerEvent; } if (slash) { foreach (ServerPlayer *target, targets) target->setFlags("-JijiangTarget"); return slash; } } foreach (ServerPlayer *target, targets) target->setFlags("-JijiangTarget"); room->setPlayerFlag(liubei, "Global_JijiangFailed"); return NULL; }
const Card *onRetrial(ServerPlayer *player, JudgeStruct *judge) const { QStringList prompt_list; prompt_list << "@guidao-card" << judge->who->objectName() << objectName() << judge->reason << QString::number(judge->card->getEffectiveId()); QString prompt = prompt_list.join(":"); Room *room = player->getRoom(); const Card *card = room->askForCard(player, ".|black", prompt, QVariant::fromValue(judge), Card::MethodResponse, judge->who, true); if (card != NULL) { int index = qrand() % 2 + 1; if (Player::isNostalGeneral(player, "zhangjiao")) index += 2; room->broadcastSkillInvoke(objectName(), index); } return card; }
virtual bool trigger(TriggerEvent event, ServerPlayer *player, QVariant &data) const{ Room *room = player->getRoom(); ServerPlayer *skillowner = room->findPlayerBySkillName(objectName()); if(!skillowner) return false; if(skillowner->getPhase() != Player::NotActive) return false; if(!skillowner->inMyAttackRange(player)) return false; if(!skillowner->askForSkillInvoke(objectName(), data)) return false; SlashEffectStruct effect = data.value<SlashEffectStruct>(); if(!room->askForCard(skillowner, "Horse", "@diyxuelu-horse:"+effect.to->getGeneralName(), data)){ room->loseHp(skillowner, 1); room->playSkillEffect("diyxuelu", 1); room->moveCardTo(effect.slash, skillowner, Player::Hand, true); } room->playSkillEffect("diyxuelu", 2); return true; }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashResultStruct result = data.value<SlashResultStruct>(); if(!result.success){ if(result.to->hasSkill("kongcheng") && result.to->isKongcheng()) return false; Room *room = player->getRoom(); const Card *card = room->askForCard(player, "slash", "blade-slash"); if(card){ CardEffectStruct effect; effect.card = card; effect.from = player; effect.to = result.to; room->cardEffect(effect); } } return false; }
void FireAttack::onEffect(const CardEffectStruct &effect) const{ Room *room = effect.from->getRoom(); if (effect.to->isKongcheng()) return; const Card *card = room->askForCardShow(effect.to, effect.from, objectName()); room->showCard(effect.to, card->getEffectiveId()); QString suit_str = card->getSuitString(); QString pattern = QString(".%1").arg(suit_str.at(0).toUpper()); QString prompt = QString("@fire-attack:%1::%2").arg(effect.to->objectName()).arg(suit_str); if (effect.from->isAlive()) { const Card *card_to_throw = room->askForCard(effect.from, pattern, prompt); if (card_to_throw) room->damage(DamageStruct(this, effect.from, effect.to, 1, DamageStruct::Fire)); else effect.from->setFlags("FireAttackFailed_" + effect.to->objectName()); // For AI } if (card->isVirtualCard()) delete card; }
virtual bool trigger(TriggerEvent, ServerPlayer *player, QVariant &data) const{ SlashEffectStruct effect = data.value<SlashEffectStruct>(); if(effect.to->hasSkill("kongcheng") && effect.to->isKongcheng()) return false; Room *room = player->getRoom(); const Card *card = room->askForCard(player, "slash", "blade-slash:" + effect.to->objectName(), QVariant(), NonTrigger); if(card){ // if player is drank, unset his flag if(player->hasFlag("drank")) room->setPlayerFlag(player, "-drank"); CardUseStruct use; use.card = card; use.from = player; use.to << effect.to; room->useCard(use, false); } return false; }
void FireAttack::onEffect(const CardEffectStruct &effect) const{ Room *room = effect.from->getRoom(); if(effect.to->isKongcheng()) return; const Card *card = room->askForCardShow(effect.to, effect.from, objectName()); room->showCard(effect.to, card->getEffectiveId()); QString suit_str = card->getSuitString(); QString pattern = QString(".%1").arg(suit_str.at(0).toUpper()); QString prompt = QString("@fire-attack:%1::%2").arg(effect.to->getGeneralName()).arg(suit_str); if(effect.from->isAlive() && room->askForCard(effect.from, pattern, prompt)){ DamageStruct damage; damage.card = this; damage.from = effect.from; damage.to = effect.to; damage.nature = DamageStruct::Fire; room->damage(damage); } if(card->isVirtualCard()) delete card; }