bool QiceCard::targetFixed() const{ if(ClientInstance->getStatus() == Client::Responsing) return true; CardStar card = Self->tag.value("qice").value<CardStar>(); return card && card->targetFixed(); }
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 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; }
virtual bool trigger(TriggerEvent triggerEvent, Room* room, ServerPlayer *player, QVariant &data) const{ if(player->getPhase() != Player::NotActive) return false; CardStar card = NULL; if(triggerEvent == CardFinished){ CardUseStruct card_use = data.value<CardUseStruct>(); card = card_use.card; if(card == player->tag["MoonSpearSlash"].value<CardStar>()){ card = NULL; } }else if(triggerEvent == CardResponsed){ card = data.value<ResponsedStruct>().m_card; player->tag["MoonSpearSlash"] = data; } if(card == NULL || !card->isBlack()) return false; //@todo: askForUseCard combines asking and using the card. //animating weapon effect should happen in-between. //we should come back after the askFor methods are restructured. room->askForUseCard(player, "slash", "@moon-spear-slash"); return false; }
virtual bool trigger(TriggerEvent event, ServerPlayer *player, QVariant &data) const{ if(player->getPhase() != Player::NotActive) return false; CardStar card = NULL; if(event == CardFinished){ CardUseStruct card_use = data.value<CardUseStruct>(); card = card_use.card; if(card == player->tag["MoonSpearSlash"].value<CardStar>()){ card = NULL; } }else if(event == CardResponsed){ card = data.value<CardStar>(); player->tag["MoonSpearSlash"] = data; } if(card == NULL || !card->isBlack()) return false; Room *room = player->getRoom(); room->askForUseCard(player, "slash", "@moon-spear-slash"); return false; }
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{ JudgeStar judge = data.value<JudgeStar>(); CardStar card = judge->card; if(card->isBlack()){ Room *room = player->getRoom(); QList<ServerPlayer *> players = room->getOtherPlayers(player); foreach(ServerPlayer *p, players){ QVariant who = QVariant::fromValue(p); if(p->hasLordSkill("songwei") && player->askForSkillInvoke("songwei", who)){ room->playSkillEffect(objectName(), 1); p->drawCards(1); } }
virtual bool trigger(TriggerEvent , ServerPlayer *player, QVariant &data) const{ CardStar card = data.value<CardStar>(); if(card->isBlack()){ Room *room = player->getRoom(); if(room->askForSkillInvoke(player, objectName())){ room->playSkillEffect(objectName()); QList<ServerPlayer *> players = room->getOtherPlayers(player); foreach(ServerPlayer *p, players){ if(p->hasSkill(objectName())){ p->drawCards(1); break; } } }
virtual const Card *viewAs(const QList<CardItem *> &cards) const{ if(cards.length() < Self->getHandcardNum()) return NULL; if(ClientInstance->getStatus() == Client::Responsing){ QiceCard *card = new QiceCard; card->setUserString("nullification"); card->addSubcards(cards); return card; } CardStar c = Self->tag.value("qice").value<CardStar>(); if(c){ QiceCard *card = new QiceCard; card->setUserString(c->objectName()); card->addSubcards(cards); return card; }else return NULL; }
void DaojuCard::onUse(Room *room, const CardUseStruct &card_use) const{ CardStar ju = Sanguosha->getCard(card_use.from->getPile("gui").first()); const Card *first = Sanguosha->getCard(getSubcards().first()); const Card *second = Sanguosha->getCard(getSubcards().last()); Card::Suit suit = Card::NoSuit; if(first->isBlack() && second->isBlack()) suit = Card::Spade; else if(first->isRed() && second->isRed()) suit = Card::Heart; Card *new_card = Sanguosha->cloneCard(ju->objectName(), suit, (first->getNumber() + second->getNumber()) / 2); new_card->setSkillName("daoju"); new_card->addSubcard(first); new_card->addSubcard(second); CardUseStruct use; use.card = new_card; use.from = card_use.from; use.to = card_use.to; room->useCard(use); }
virtual bool trigger(TriggerEvent triggerEvent, Room *room, ServerPlayer *player, QVariant &data) const{ if (player->getPhase() != Player::NotActive) return false; CardStar card = NULL; if (triggerEvent == CardUsed) { CardUseStruct card_use = data.value<CardUseStruct>(); card = card_use.card; } else if (triggerEvent == CardResponded) { card = data.value<CardResponseStruct>().m_card; } if (card == NULL || !card->isBlack() || (card->getHandlingMethod() != Card::MethodUse && card->getHandlingMethod() != Card::MethodResponse)) return false; player->setFlags("MoonspearUse"); if (!room->askForUseCard(player, "slash", "@moon-spear-slash", -1, Card::MethodUse, false)) player->setFlags("-MoonspearUse"); return false; }
bool QiceCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{ CardStar card = Self->tag.value("qice").value<CardStar>(); return card && card->targetsFeasible(targets, Self); }
bool QiceCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{ CardStar card = Sanguosha->cloneCard(user_string, getSuit(this->getSubcards()), getNumber(this->getSubcards())); return card && card->targetFilter(targets, to_select, Self) && !Self->isProhibited(to_select, card); }
bool DaojuCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{ CardStar card = Sanguosha->getCard(Self->getPile("gui").first()); return card && card->targetsFeasible(targets, Self); }
bool DaojuCard::targetFixed() const{ CardStar card = Sanguosha->getCard(Self->getPile("gui").first()); return card && card->targetFixed(); }
bool DaojuCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{ CardStar card = Sanguosha->getCard(Self->getPile("gui").first()); return card && card->targetFilter(targets, to_select, Self) && !Self->isProhibited(to_select, card); }