Пример #1
0
    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);
                }
            }
Пример #2
0
QString GeneralSelector::selectFirst(ServerPlayer *player, const QStringList &candidates)
{
    QMap<QString, qreal> values;
    QString role = player->getRole();
    ServerPlayer *lord = player->getRoom()->getLord();
    foreach (QString candidate, candidates) {
        qreal value = 5.0;
        const General *general = Sanguosha->getGeneral(candidate);
        if (role == "loyalist" && lord && (general->getKingdom() == lord->getKingdom() || general->getKingdom() == "god"))
            value *= 1.04;
        if (role == "rebel" && lord && lord->getGeneral() && lord->getGeneral()->hasSkill("xueyi")
            && general->getKingdom() == "qun")
            value *= 0.8;
        if (role != "loyalist" && lord && lord->getGeneral() && lord->getGeneral()->hasSkill("shichou")
            && general->getKingdom() == "shu")
            value *= 0.1;
        if (role == "rebel" && lord && lord->getGeneral() && lord->getGeneral()->hasSkill("guiming")
            && general->getKingdom() == "wu")
            value *= 0.5;
        QString key = QString("_:%1:%2").arg(candidate).arg(role);
        value *= qPow(1.1, first_general_table.value(key, 0.0));
        if (lord) {
            QString key2 = QString("%1:%2:%3").arg(lord->getGeneralName()).arg(candidate).arg(role);
            value *= qPow(1.1, first_general_table.value(key2, 0.0));
        }
        values.insert(candidate, value);
    }
Пример #3
0
 virtual bool trigger(TriggerEvent , Room *room, ServerPlayer *player, QVariant &data) const{
     RecoverStruct recover_struct = data.value<RecoverStruct>();
     int recover = recover_struct.recover;
     for (int i = 0; i < recover; i++) {
         ServerPlayer *target = room->askForPlayerChosen(player, room->getOtherPlayers(player), objectName(), "shushen-invoke", true, true);
         if (target) {
             room->broadcastSkillInvoke(objectName(), target->getGeneralName().contains("liubei") ? 2 : 1);
             target->drawCards(1);
         } else {
             break;
         }
     }
     return false;
 }
 bool trigger(TriggerEvent, Room *room, ServerPlayer *player, QVariant &data) const
 {
     RecoverStruct recover_struct = data.value<RecoverStruct>();
     int recover = recover_struct.recover;
     for (int i = 0; i < recover; i++) {
         ServerPlayer *target = room->askForPlayerChosen(player, room->getOtherPlayers(player), objectName(), "shushen-invoke", true, true);
         if (target) {
             room->broadcastSkillInvoke(objectName(), target->getGeneralName().contains("liubei") ? 2 : 1);
             if (target->isWounded() && room->askForChoice(player, objectName(), "recover+draw", QVariant::fromValue(target)) == "recover")
                 room->recover(target, RecoverStruct(player));
             else
                 target->drawCards(2, objectName());
         } else {
             break;
         }
     }
     return false;
 }
Пример #5
0
QString GeneralSelector::selectFirst(ServerPlayer *player, const QStringList &candidates){
    QString role = player->getRole();
    int seat = player->getSeat();
    int player_count = Sanguosha->getPlayerCount(player->getRoom()->getMode());
    int index = seat;
    if(player_count < 8 && seat == player_count)
        index = 8;
    else if(player_count > 8 && seat > 8)
        index = 8;

    int max = -1;
    QString max_general;

    qreal default_value;
    if(role == "loyalist")
        default_value = 6.5;
    else if(role == "rebel")
        default_value = 7.3;
    else
        default_value = 6.3;

    ServerPlayer *lord = player->getRoom()->getLord();
    QString lord_kingdom, suffix = QString();
    if(lord->getGeneral() && lord->getGeneral()->isLord()){
        lord_kingdom = lord->getKingdom();
        suffix = lord->getGeneralName();
    }

    foreach(QString candidate, candidates){
        QString key = QString("%1:%2:%3:%4").arg(candidate).arg(role).arg(index).arg(suffix);
        qreal value = first_general_table.value(key, default_value);

        if(!lord_kingdom.isNull() && (role == "loyalist" || role == "renegade")){
            const General *general = Sanguosha->getGeneral(candidate);
            if(general->getKingdom() == lord_kingdom)
                value += 0.5;
        }

        if(value > max){
            max = value;
            max_general = candidate;
        }
    }
QString GeneralSelector::selectFirst(ServerPlayer *player, const QStringList &candidates) {
    QString role = player->getRole();
    int seat = player->getSeat();
    Q_ASSERT(player->getRoom() != NULL);
    int player_count = Sanguosha->getPlayerCount(player->getRoom()->getMode());
    int index = seat;
    if (player_count < 8 && seat == player_count)
        index = 8;
    else if (player_count > 8 && seat > 8)
        index = 8;

    QString max_general;

    ServerPlayer *lord = player->getRoom()->getLord();
    QString suffix = QString();
    if (lord->getGeneral() && lord->getGeneral()->isLord())
        suffix = lord->getGeneralName();

    QStringList key_list;
    foreach (QString candidate, candidates) {
        QString key = QString("%1:%2:%3:%4").arg(candidate).arg(role).arg(index).arg(suffix);
        key_list << key;
    }
Пример #7
0
    virtual bool trigger(TriggerEvent, Room *room, ServerPlayer *caopi, QVariant &data) const{
        DeathStruct death = data.value<DeathStruct>();
        ServerPlayer *player = death.who;
        if (player->isNude() || caopi == player)
            return false;
        if (caopi->isAlive() && room->askForSkillInvoke(caopi, objectName(), data)) {
            bool isCaoCao = player->getGeneralName().contains("caocao");
            room->broadcastSkillInvoke(objectName(), (isCaoCao ? 3 : (player->isMale() ? 1 : 2)));

            DummyCard *dummy = new DummyCard;
            QList <const Card *> handcards = player->getHandcards();
            foreach (const Card *card, handcards)
                dummy->addSubcard(card);

            QList <const Card *> equips = player->getEquips();
            foreach (const Card *card, equips)
                dummy->addSubcard(card);

            if (dummy->subcardsLength() > 0) {
                CardMoveReason reason(CardMoveReason::S_REASON_RECYCLE, caopi->objectName());
                room->obtainCard(caopi, dummy, reason, false);
            }
            delete dummy;
        }