Example #1
0
    virtual void onDamaged(ServerPlayer *xiahou, const DamageStruct &damage) const{
        ServerPlayer *from = damage.from;
        Room *room = xiahou->getRoom();
        QVariant source = QVariant::fromValue(from);

        if(from && from->isAlive() && room->askForSkillInvoke(xiahou, "ganglie", source)){
            room->playSkillEffect(objectName());

            JudgeStruct judge;
            judge.pattern = QRegExp("(.*):(club):(.*)");
            judge.good = false;
            judge.reason = objectName();
            judge.who = xiahou;

            room->judge(judge);
            if(judge.isGood()){
                if(!room->askForDiscard(from, objectName(), 2, true)){
                    DamageStruct damage;
                    damage.from = xiahou;
                    damage.to = from;

                    room->setEmotion(xiahou, "good");
                    room->damage(damage);
                }
            }else
                room->setEmotion(xiahou, "bad");
        }
    }
Example #2
0
    virtual bool trigger(TriggerEvent event, ServerPlayer *player, QVariant &data) const{
        if(player->isNude())
            return false;

        Room *room = player->getRoom();
        ServerPlayer *caopi = NULL;
        QList<ServerPlayer *> players = room->getOtherPlayers(player);
        foreach(ServerPlayer *p, players){
            if(p->hasSkill(objectName())){
                caopi = p;
                break;
            }
        }

        if(caopi && caopi->isAlive() && room->askForSkillInvoke(caopi, objectName())){
            caopi->obtainCard(player->getWeapon());
            caopi->obtainCard(player->getArmor());
            caopi->obtainCard(player->getDefensiveHorse());
            caopi->obtainCard(player->getOffensiveHorse());

            DummyCard *all_cards = player->wholeHandCards();
            if(all_cards){
                room->moveCardTo(all_cards, caopi, Player::Hand, false);
                delete all_cards;
            }
        }

        return false;
    }
Example #3
0
    virtual bool trigger(TriggerEvent , ServerPlayer *player, QVariant &data) const{
        if(player->isNude())
            return false;

        Room *room = player->getRoom();
        ServerPlayer *caopi = room->findPlayerBySkillName(objectName());
        if(caopi && caopi->isAlive() && room->askForSkillInvoke(caopi, objectName(), data)){
            if(player->isCaoCao()){
                room->playSkillEffect(objectName(), 3);
            }else if(player->getGeneral()->isMale())
                room->playSkillEffect(objectName(), 1);
            else
                room->playSkillEffect(objectName(), 2);

            caopi->obtainCard(player->getWeapon());
            caopi->obtainCard(player->getArmor());
            caopi->obtainCard(player->getDefensiveHorse());
            caopi->obtainCard(player->getOffensiveHorse());

            DummyCard *all_cards = player->wholeHandCards();
            if(all_cards){
                room->moveCardTo(all_cards, caopi, Player::Hand, false);
                delete all_cards;
            }
        }

        return false;
    }
Example #4
0
    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(room->askForSkillInvoke(effect.from, 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);
                    if(card){
                        room->throwCard(card);
                    }else
                        draw_card = true;
                }

                if(draw_card)
                    effect.to->drawCards(1);
            }
        }

        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;
    }
    void onDamaged(ServerPlayer *xiahou, const DamageStruct &damage) const
    {
        ServerPlayer *from = damage.from;
        Room *room = xiahou->getRoom();
        QVariant data = QVariant::fromValue(damage);

        if (room->askForSkillInvoke(xiahou, "neoganglie", data)) {
            room->broadcastSkillInvoke("ganglie");

            JudgeStruct judge;
            judge.pattern = ".|heart";
            judge.good = false;
            judge.reason = objectName();
            judge.who = xiahou;

            room->judge(judge);
            if (!from || from->isDead()) return;
            if (judge.isGood()) {
                QStringList choicelist;
                choicelist << "damage";
                if (from->getHandcardNum() > 1)
                    choicelist << "throw";
                QString choice = room->askForChoice(xiahou, objectName(), choicelist.join("+"));
                if (choice == "damage")
                    room->damage(DamageStruct(objectName(), xiahou, from));
                else
                    room->askForDiscard(from, objectName(), 2, 2);
            }
        }
    }
    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 void onDamaged(ServerPlayer *caocao, const DamageStruct &damage) const{
        Room *room = caocao->getRoom();
        const Card *card = damage.card;
        if(!room->obtainable(card, caocao))
            return;

        QVariant data = QVariant::fromValue(card);
        if(room->askForSkillInvoke(caocao, "jianxiong", data)){
            room->playSkillEffect(objectName());
            caocao->obtainCard(card);
        }
    }
Example #9
0
    virtual void onDamaged(ServerPlayer *caocao, const DamageStruct &damage) const{
        Room *room = caocao->getRoom();
        const Card *card = damage.card;
        if(card && room->getCardPlace(card->getEffectiveId()) == Player::PlaceTable){

            QVariant data = QVariant::fromValue(card);
            if(room->askForSkillInvoke(caocao, "jianxiong", data)){
            room->broadcastSkillInvoke(objectName());
                caocao->obtainCard(card);
            }
        }
    }
Example #10
0
 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 onDamaged(ServerPlayer *target, const DamageStruct &damage) const
 {
     Room *room = target->getRoom();
     for (int i = 1; i <= damage.damage; i++) {
         ServerPlayer *current = room->getCurrent();
         if (!current || current->isDead() || current->getPhase() == Player::NotActive)
             break;
         if (room->askForSkillInvoke(target, objectName(), QVariant::fromValue(current))) {
             room->broadcastSkillInvoke(objectName());
             room->addPlayerMark(current, "@hengjiang");
         }
     }
 }
Example #12
0
    void doChongZhen(ServerPlayer *player, const Card *card) const{
        if(card->getSkillName() != "longdan")
            return;

        Room *room = player->getRoom();

        ServerPlayer *target = player->tag["ChongZhenTarget"].value<PlayerStar>();
        if(!target || target->isKongcheng() || !room->askForSkillInvoke(player, objectName()))
            return;

        int card_id = room->askForCardChosen(player, target, "h", objectName());
        room->moveCardTo(Sanguosha->getCard(card_id), player, Player::Hand, false);
    }
Example #13
0
    virtual bool onPhaseChange(ServerPlayer *target) const{
        if(target->getPhase() == Player::Finish){
            Room *room = target->getRoom();
            if(room->askForSkillInvoke(target, objectName())){
                target->drawCards(2 + target->getLostHp());
                target->turnOver();

                room->broadcastSkillInvoke("jushou");
            }
        }

        return false;
    }
Example #14
0
    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);
        }
    }
Example #15
0
    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;
                    }
                }
            }
Example #16
0
 virtual bool onPhaseChange(ServerPlayer *ganfuren) const{
     Room *room = ganfuren->getRoom();
     if (ganfuren->getPhase() != Player::Start || ganfuren->isKongcheng())
         return false;
     if (room->askForSkillInvoke(ganfuren, objectName())) {
         // As the cost, if one of her handcards cannot be throwed, the skill is unable to invoke
         foreach (const Card *card, ganfuren->getHandcards()) {
             if (ganfuren->isJilei(card))
                 return false;
         }
         //==================================
         int handcard_num = ganfuren->getHandcardNum();
         room->broadcastSkillInvoke(objectName());
         ganfuren->throwAllHandCards();
         if (handcard_num >= ganfuren->getHp())
             room->recover(ganfuren, RecoverStruct(ganfuren));
     }
Example #17
0
    virtual bool trigger(TriggerEvent , ServerPlayer *player, QVariant &data) const{
        Room *room = player->getRoom();
        SlashEffectStruct effect = data.value<SlashEffectStruct>();
        if(!room->askForSkillInvoke(player, objectName(), data))
            return false;
        JudgeStruct judge;
        judge.pattern = QRegExp("(.*):(heart):(.*)");
        judge.good = false;
        judge.reason = objectName();
        judge.who = player;

        room->judge(judge);
        if(judge.isGood()){
            QStringList natures;
            natures << "normal_nature" << "fire_nature" << "thunder_nature" << "wind_nature";
            QString choice = room->askForChoice(player, objectName(), natures.join("+"));
            if(choice == "normal_nature")
                effect.nature = DamageStruct::Normal;
            else if(choice == "fire_nature")
                effect.nature = DamageStruct::Fire;
            else if(choice == "thunder_nature")
                effect.nature = DamageStruct::Thunder;
            else if(choice == "wind_nature")
                effect.nature = DamageStruct::Wind;

            LogMessage log;
            log.type = "#BaguaSwordLog";
            log.from = player;
            log.arg = choice;
            room->sendLog(log);

            data = QVariant::fromValue(effect);
            return false;
        }else{
            Jink *jink = new Jink(Card::NoSuit, 0);
            room->slashResult(effect, jink);
            return true;
        }
        return false;
    }
Example #18
0
    virtual void onDamaged(ServerPlayer *xiahou, const DamageStruct &damage) const{
        ServerPlayer *from = damage.from;
        Room *room = xiahou->getRoom();
        QVariant source = QVariant::fromValue(from);

        if(from && from->isAlive() && room->askForSkillInvoke(xiahou, "neoganglie", source)){
            room->broadcastSkillInvoke("ganglie");

            JudgeStruct judge;
            judge.pattern = QRegExp("(.*):(heart):(.*)");
            judge.good = false;
            judge.reason = objectName();
            judge.who = xiahou;

            room->judge(judge);
            if(judge.isGood()){
                QStringList choicelist;
                choicelist << "damage";
                if (from->getHandcardNum() > 1)
                    choicelist << "throw";
                QString choice;
                if (choicelist.length() == 1)
                    choice = choicelist.first();
                else
                    choice = room->askForChoice(xiahou, "neoganglie", choicelist.join("+"));
                if(choice == "damage"){
                    DamageStruct damage;
                    damage.from = xiahou;
                    damage.to = from;

                    room->setEmotion(xiahou, "good");
                    room->damage(damage);
                }
                else
                     room->askForDiscard(from, objectName(), 2, 2);
            }else
                room->setEmotion(xiahou, "bad");
        }
    }
Example #19
0
    virtual bool onPhaseChange(ServerPlayer *menghuo) const{
        if(menghuo->getPhase() == Player::Draw && menghuo->isWounded()){
            Room *room = menghuo->getRoom();
            if(room->askForSkillInvoke(menghuo, objectName())){
                int x = menghuo->getLostHp(), i;

                room->playSkillEffect(objectName(), 1);
                bool has_heart = false;

                for(i=0; i<x; i++){
                    int card_id = room->drawCard();
                    room->moveCardTo(Sanguosha->getCard(card_id), NULL, Player::Special, true);

                    room->getThread()->delay();

                    const Card *card = Sanguosha->getCard(card_id);
                    if(card->getSuit() == Card::Heart){
                        RecoverStruct recover;
                        recover.card = card;
                        recover.who = menghuo;
                        room->recover(menghuo, recover);
                        room->throwCard(card_id);
                        has_heart = true;
                    }else
                        room->obtainCard(menghuo, card_id);
                }

                if(has_heart)
                    room->playSkillEffect(objectName(), 2);
                else
                    room->playSkillEffect(objectName(), 3);

                return true;
            }
        }

        return false;
    }