Example #1
0
QString TrustAI::askForKingdom() {
    QString role;
    ServerPlayer *lord = room->getLord();
    QStringList kingdoms = Sanguosha->getKingdoms();
    kingdoms.removeOne("god");
    if (!lord) return kingdoms.at(qrand() % kingdoms.length());

    switch(self->getRoleEnum()) {
    case Player::Lord: role = kingdoms.at(qrand() % kingdoms.length()); break;
    case Player::Renegade:
    case Player::Rebel: {
            if ((lord->hasLordSkill("xueyi") && self->getRoleEnum() == Player::Rebel) || lord->hasLordSkill("shichou"))
                role = "wei";
            else
                role = lord->getKingdom();
            break;
    }
    case Player::Loyalist: {
            if (lord->getGeneral()->isLord())
                role = lord->getKingdom();
            else if (lord->getGeneral2() && lord->getGeneral2()->isLord())
                role = lord->getGeneral2()->getKingdom();
            else {
                if (lord->hasSkill("yongsi")) kingdoms.removeOne(lord->getKingdom());
                role = kingdoms.at(qrand() % kingdoms.length());
            }
            break;
        }
    default:
            break;
    }

    return role;
}
Example #2
0
void HuangtianCard::use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const
{
    ServerPlayer *zhangjiao = targets.first();
    if (zhangjiao->hasLordSkill("huangtian")) {
        room->setPlayerFlag(zhangjiao, "HuangtianInvoked");

        if (!zhangjiao->isLord() && zhangjiao->hasSkill("weidi"))
            room->broadcastSkillInvoke("weidi");
        else {
            int index = qrand() % 2 + 1;
            if (Player::isNostalGeneral(zhangjiao, "zhangjiao"))
                index += 2;
            room->broadcastSkillInvoke("huangtian", index);
        }

        room->notifySkillInvoked(zhangjiao, "huangtian");
        CardMoveReason reason(CardMoveReason::S_REASON_GIVE, source->objectName(), zhangjiao->objectName(), "huangtian", QString());
        room->obtainCard(zhangjiao, this, reason);
        QList<ServerPlayer *> zhangjiaos;
        QList<ServerPlayer *> players = room->getOtherPlayers(source);
        foreach (ServerPlayer *p, players) {
            if (p->hasLordSkill("huangtian") && !p->hasFlag("HuangtianInvoked"))
                zhangjiaos << p;
        }
        if (zhangjiaos.isEmpty())
            room->setPlayerFlag(source, "ForbidHuangtian");
    }
Example #3
0
void HuangtianCard::use(Room *room, ServerPlayer *, const QList<ServerPlayer *> &targets) const{
    ServerPlayer *zhangjiao = targets.first();
    if(zhangjiao->hasSkill("huangtian")){
        zhangjiao->obtainCard(this);
        room->setEmotion(zhangjiao, "good");
    }
}
Example #4
0
void Slash::onUse(Room *room, const CardUseStruct &card_use) const{
    ServerPlayer *player = card_use.from;

    if(player->getPhase() == Player::Play
            && player->getMark("SlashCount") >= 1
            && player->hasSkill("paoxiao"))
        room->playSkillEffect("paoxiao");
    else if(player->getPhase() == Player::Play
            && player->hasSkill("huxiao") && player->getMark("huxiao") > 0) {
        bool toSunquan = false;
        foreach(ServerPlayer *p, card_use.to)
            if(p->getGeneralName().contains("sunquan")) {
            toSunquan = true;
            break;
        }
        if(toSunquan)
            room->playSkillEffect("huxiao", 3);
        else
            room->playSkillEffect("huxiao", 2);
    }