Beispiel #1
0
LingHun::LingHun()
{

    makeConnection();
    setMyRole(this);
    lianJieUsed=false;
    Button *linghunzhaohuan;
    linghunzhaohuan=new Button(3,"灵魂召还");
    buttonArea->addButton(linghunzhaohuan);
    connect(linghunzhaohuan,SIGNAL(buttonSelected(int)),this,SLOT(LingHunZhaoHuan()));

    Button *linghunjingxiang;
    linghunjingxiang=new Button(4,"灵魂镜像");
    buttonArea->addButton(linghunjingxiang);
    connect(linghunjingxiang,SIGNAL(buttonSelected(int)),this,SLOT(LingHunJingXiang()));

    Button *linghunzhenbao;
    linghunzhenbao=new Button(5,"灵魂震爆");
    buttonArea->addButton(linghunzhenbao);
    connect(linghunzhenbao,SIGNAL(buttonSelected(int)),this,SLOT(LingHunZhenBao()));

    Button *linghunciyu;
    linghunciyu=new Button(6,"灵魂赐予");
    buttonArea->addButton(linghunciyu);
    connect(linghunciyu,SIGNAL(buttonSelected(int)),this,SLOT(LingHunCiYu()));
}
Beispiel #2
0
LingFu::LingFu()
{
    makeConnection();
    setMyRole(this);

    Button *leiMing,*fengXing,*checkCover;
    leiMing=new Button(3,QStringLiteral("灵符-雷鸣"));
    fengXing = new Button(4,QStringLiteral("灵符-风行"));

    buttonArea->addButton(leiMing);
    buttonArea->addButton(fengXing);
    //buttonArea->addButton(checkCover);
    connect(leiMing,SIGNAL(buttonSelected(int)),this,SLOT(leiMing()));
    connect(fengXing,SIGNAL(buttonSelected(int)),this,SLOT(fengXing()));

    checkCover = new Button(10,QStringLiteral("查看妖力"));
    buttonArea->addOutsideTurnButton(checkCover);

    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));


}
Beispiel #3
0
YongZhe::YongZhe()
{
    makeConnection();
setMyRole(this);

    Button *tiaoXin;
    tiaoXin=new Button(3,QStringLiteral("挑衅"));
    buttonArea->addButton(tiaoXin);
    connect(tiaoXin,SIGNAL(buttonSelected(int)),this,SLOT(TiaoXin()));
}
JianDi::JianDi()
{
    makeConnection();
    setMyRole(this);

    Button *checkCover;
    checkCover = new Button(10,QStringLiteral("查看剑魂"));
    buttonArea->addOutsideTurnButton(checkCover);

    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));
}
Beispiel #5
0
XianZhe::XianZhe()
{
    makeConnection();
    setMyRole(this);

    Button *moDaoFaDian;
    moDaoFaDian=new Button(3,"魔道法典");
    buttonArea->addButton(moDaoFaDian);
    connect(moDaoFaDian,SIGNAL(buttonSelected(int)),this,SLOT(MoDaoFaDian()));

    Button *shengJieFaDian;
    shengJieFaDian=new Button(4,"圣洁法典");
    buttonArea->addButton(shengJieFaDian);
    connect(shengJieFaDian,SIGNAL(buttonSelected(int)),this,SLOT(ShengJieFaDian()));
}
ZhongCai::ZhongCai()
{
    makeConnection();
    setMyRole(this);

    Button *moRiShenPan;
    moRiShenPan=new Button(3,QStringLiteral("末日审判"));
    buttonArea->addButton(moRiShenPan);
    connect(moRiShenPan,SIGNAL(buttonSelected(int)),this,SLOT(MoRiShenPan()));

    Button *panJueTianPing;
    panJueTianPing=new Button(4,QStringLiteral("判决天平"));
    buttonArea->addButton(panJueTianPing);
    connect(panJueTianPing,SIGNAL(buttonSelected(int)),this,SLOT(PanJueTianPing()));
}
ShengQiang::ShengQiang()
{
    makeConnection();
	setMyRole(this);
    Button *huiYao, *chengJie, *shengGuangQiYu;
    huiYao = new Button(3,QStringLiteral("辉耀"));
    buttonArea->addButton(huiYao);
    connect(huiYao,SIGNAL(buttonSelected(int)),this,SLOT(HuiYao()));

    chengJie = new Button(4,QStringLiteral("惩戒"));
    buttonArea->addButton(chengJie);
    connect(chengJie,SIGNAL(buttonSelected(int)),this,SLOT(ChengJie()));

    shengGuangQiYu = new Button(5,QStringLiteral("圣光祈愈"));
    buttonArea->addButton(shengGuangQiYu);
    connect(shengGuangQiYu,SIGNAL(buttonSelected(int)),this,SLOT(ShengGuangQiYu()));
}
MoGong::MoGong()
{
    makeConnection();
    setMyRole(this);

    Button *leiGuangSanShe, *checkCover;

    leiGuangSanShe=new Button(3,QStringLiteral("雷光散射"));
    buttonArea->addButton(leiGuangSanShe);
    connect(leiGuangSanShe,SIGNAL(buttonSelected(int)),this,SLOT(LeiGuangSanShe()));

    checkCover = new Button(10,QStringLiteral("查看充能"));
    buttonArea->addOutsideTurnButton(checkCover);
    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));
}
FengYin::FengYin()
{
    makeConnection();
    setMyRole(this);
    connect(playerArea,SIGNAL(playerUnready()),this,SLOT(onUnready()));
//新建技能按钮
    Button *fengYinFaShu,*wuXiShuFu,*fengYinPoSui;
    fengYinFaShu=new Button(3,QStringLiteral("封印法术"));
    buttonArea->addButton(fengYinFaShu);
    connect(fengYinFaShu,SIGNAL(buttonSelected(int)),this,SLOT(FengYinFaShu()));

    wuXiShuFu=new Button(4,QStringLiteral("五系束缚"));
    buttonArea->addButton(wuXiShuFu);
    connect(wuXiShuFu,SIGNAL(buttonSelected(int)),this,SLOT(WuXiShuFu()));

    fengYinPoSui=new Button(5,QStringLiteral("封印破碎"));
    buttonArea->addButton(fengYinPoSui);
    connect(fengYinPoSui,SIGNAL(buttonSelected(int)),this,SLOT(FengYinPoSui()));
}
Beispiel #10
0
MoDao::MoDao()
{
    makeConnection();
    setMyRole(this);

    Button *moDanRongHe,*moBaoChongJi,*huiMeiFengBao;
    moDanRongHe=new Button(3,QStringLiteral("魔弹融合"));
    buttonArea->addButton(moDanRongHe);
    connect(moDanRongHe,SIGNAL(buttonSelected(int)),this,SLOT(MoDanRongHe()));

    moBaoChongJi=new Button(4,QStringLiteral("魔爆冲击"));
    buttonArea->addButton(moBaoChongJi);
    connect(moBaoChongJi,SIGNAL(buttonSelected(int)),this,SLOT(MoBaoChongJi()));

    huiMeiFengBao=new Button(5,QStringLiteral("毁灭风暴"));
    buttonArea->addButton(huiMeiFengBao);
    connect(huiMeiFengBao,SIGNAL(buttonSelected(int)),this,SLOT(HuiMeiFengBao()));

    Player*myself=dataInterface->getMyself();
    myID=myself->getID();

    int myColor=myself->getColor();

    QString queue=dataInterface->getQueue();
    int playerMax=queue.count()/2;
    QList<Player*>playerList=dataInterface->getPlayerList();
    int i;
    //find myPos
    for(i=0;i<playerMax;i++)
        if(queue[i].digitValue()==myID)
            break;
    int ptr;
    do
    {
        i--;
        if(i==-1)
            i=playerMax-1;
        ptr=queue[i].digitValue();
    }while(playerList[ptr]->getColor()==myColor);
    nextClockwise=ptr;
}
Beispiel #11
0
TianShi::TianShi()
{
    makeConnection();
    setMyRole(this);

    connect(playerArea,SIGNAL(playerUnready()),this,SLOT(onUnready()));
    connect(handArea,SIGNAL(cardUnready()),this,SLOT(onUnready()));

    Button *fengZhiJieJin,*tianShiZhuFu,*tianShiZhiQiang;
    fengZhiJieJin=new Button(3,QStringLiteral("风之洁净"));
    buttonArea->addButton(fengZhiJieJin);
    connect(fengZhiJieJin,SIGNAL(buttonSelected(int)),this,SLOT(FengZhiJieJin()));

    tianShiZhuFu=new Button(4,QStringLiteral("天使祝福"));
    buttonArea->addButton(tianShiZhuFu);
    connect(tianShiZhuFu,SIGNAL(buttonSelected(int)),this,SLOT(TianShiZhuFu()));

    tianShiZhiQiang=new Button(5,QStringLiteral("天使之墙"));
    buttonArea->addButton(tianShiZhiQiang);
    connect(tianShiZhiQiang,SIGNAL(buttonSelected(int)),this,SLOT(TianShiZhiQiang()));
}
Beispiel #12
0
QiDao::QiDao()
{
    makeConnection();
    setMyRole(this);

    Button *weiLi,*xunJie,*guangHui,*qiHei;
    weiLi=new Button(3,QStringLiteral("威力赐福"));
    buttonArea->addButton(weiLi);
    connect(weiLi,SIGNAL(buttonSelected(int)),this,SLOT(WeiLiCiFu()));

    xunJie=new Button(4,QStringLiteral("迅捷赐福"));
    buttonArea->addButton(xunJie);
    connect(xunJie,SIGNAL(buttonSelected(int)),this,SLOT(XunJieCiFu()));

    guangHui=new Button(5,QStringLiteral("光辉信仰"));
    buttonArea->addButton(guangHui);
    connect(guangHui,SIGNAL(buttonSelected(int)),this,SLOT(GuangHuiXinYang()));

    qiHei=new Button(6,QStringLiteral("漆黑信仰"));
    buttonArea->addButton(qiHei);
    connect(qiHei,SIGNAL(buttonSelected(int)),this,SLOT(QiHeiXinYang()));
}
void Logic::getCommand(unsigned short proto_type, google::protobuf::Message* proto)
{
    QMutexLocker locker(&mutex);
    TipArea *tipArea;
    DecisionArea* decisionArea;
    BPArea* bpArea;
    SafeList<int> roleIDs;
    SafeList<int> options;
    PlayerArea* playerArea;
    int targetID,roleID,howMany;

    network::RoleRequest* char_pick;

    switch (proto_type)
    {
    case network::MSG_ROOMLIST_REP:
        lobby->fill((network::RoomListResponse*) proto);
        break;

    case network::MSG_GAME:
    {
        network::GameInfo* game_info = (network::GameInfo*) proto;
        if(game_info->has_player_id()){
            myID = game_info->player_id();
            dataInterface->setID(myID);            
            cleanRoom();
            if(myID == GUEST)
                gui->logAppend(QStringLiteral("<font color=\'pink\'>房间已满,进入观战模式</font>"));
            else
                gui->logAppend(QStringLiteral("<font color=\'pink\'>请准备</font>"));
        }
        if(game_info->has_room_id()){
            gui->getTeamArea()->setRoomID(game_info->room_id());
        }
        setupRoom(game_info->is_started(), game_info);

        for (int i = 0; i < game_info->player_infos_size(); ++i)
        {
            network::SinglePlayerInfo* player_info = (network::SinglePlayerInfo*)&(game_info->player_infos(i));
            targetID = player_info->id();
            if(player_info->has_role_id())
            {
                roleID = player_info->role_id();
                roles[targetID] = roleID;
                count++;
            }
            if(player_info->has_nickname()){
                dataInterface->setNickName(targetID, QString::fromStdString(player_info->nickname()));
            }
            if(player_info->has_team()){
                dataInterface->getPlayerById(targetID)->setTeam(player_info->team());
            }
            gui->getPlayerArea()->getPlayerItem(targetID)->setReady(player_info->ready());
        }

        if(count==dataInterface->getPlayerMax())
        {
            disconnect(getClient(),0,this,0);
            disconnect(gui->getDecisionArea(), 0, this, 0);
            disconnect(gui->getBPArea(),0,this,0);
            for(int i=0;i<dataInterface->getPlayerMax();i++){
                dataInterface->getPlayerList().at(i)->setRole(roles[i]);
                gui->getPlayerArea()->getPlayerItem(i)->setToolTip(dataInterface->getRoleSkillInfo(roles[i]));
            }

            roleID = myID == GUEST ? roles[0] : roles[myID];
            setMyRole(roleID);
            network::GameInfo* toRole = new network::GameInfo;
            toRole->CopyFrom(*game_info);
            myRole->decipher(network::MSG_GAME, toRole);
            gui->hideBP();
        }
        gui->getPlayerArea()->update();
        break;
    }
    case network::MSG_GOSSIP:
        if(gui!=NULL)
        {
            network::Gossip* gossip = (network::Gossip*) proto;
            gui->chatAppend(gossip->id(), QString::fromStdString(gossip->txt()));
        }
        break;
    case network::MSG_ERROR:
    {
        network::Error* error = (network::Error*)proto;
        if(error->dst_id() == myID){
            gui->reset();
        }
        switch(error->id())
        {
        //GE_DISCONNECTED
        case GE_DISCONNECTED:
        {
            int targetId = error->dst_id();
            gui->logAppend(QStringLiteral("<font color=\'red\'>玩家") + QString::number(targetId) + QStringLiteral("离开房间</font>"));
            dataInterface->setNickName(targetId, "");
            dataInterface->getPlayerById(targetId)->setTeam(-1);
            gui->getPlayerArea()->getPlayerItem(targetId)->setReady(false);
            gui->getPlayerArea()->update();
            break;
        }
        case GE_NOT_WELCOME:
            gui->logAppend(QStringLiteral("<font color=\'red\'>这个房主比较高冷,下个房间见。。</font>"));
            break;
        case GE_WRONG_PASSWORD:
            gui->logAppend(QStringLiteral("<font color=\'red\'>瞎蒙果然是不行的。。</font>"));
            break;
        default:
            gui->logAppend(QStringLiteral("<font color=\'red\'>错误代码") + QString::number(error->id()) + "</font>");
            break;
			}
        break;
    }
//选择角色
    case network::MSG_ROLE_REQ:
        char_pick = (network::RoleRequest*) proto;
        int targetId = char_pick->id();
        if(targetId != -1)
            gui->logAppend(QStringLiteral("等待玩家") + QString::number(targetId) + QStringLiteral("选择角色"));
        if(char_pick->strategy() == ROLE_STRATEGY_31)
        {
            if(targetId != myID)
                break;
            state=46;
            tipArea=gui->getTipArea();
            decisionArea=gui->getDecisionArea();
            tipArea->reset();
            howMany=char_pick->role_ids_size();
            for(int i=0;i<howMany;i++){
                roleID=char_pick->role_ids(i);
                tipArea->addBoxItem(QString::number(roleID)+"."+dataInterface->getRoleName(roleID));
            }
            tipArea->setMsg(QStringLiteral("请选择角色:"));
            tipArea->showBox();
            decisionArea->enable(0);
            gui->alert();
            break;
        }
        else if(char_pick->strategy() == ROLE_STRATEGY_BP)
        {
            state = 51;
            tipArea=gui->getTipArea();
            decisionArea=gui->getDecisionArea();
            bpArea = gui->getBPArea();
            tipArea->reset();
            howMany=char_pick->role_ids_size();
            for(int i=0;i<howMany;i++){
                roleIDs << char_pick->role_ids(i);
                options << char_pick->args(i);
            }            
            bpArea->BPStart(howMany, roleIDs, options, char_pick->opration());
            if(targetId != myID)
                break;
            if(char_pick->opration() == BP_BAN )
            {
                state = 52;
                bpArea = gui->getBPArea();
                bpArea->setMsg(QStringLiteral("请禁用一角色"));
                bpArea->setQuota(1);
                bpArea->enableAll();
                playerArea = gui->getPlayerArea();
                gui->alert();
            }
            else if(char_pick->opration() == BP_PICK )
            {
                state = 53;
                bpArea = gui->getBPArea();
                bpArea->setMsg(QStringLiteral("请选择一角色"));
                bpArea->setQuota(1);
                bpArea->enableAll();
                playerArea = gui->getPlayerArea();
                gui->alert();
            }
            break;
        }
    }
    delete proto;
}
Beispiel #14
0
AnSha::AnSha()
{
    makeConnection();
setMyRole(this);
}
KuangZhan::KuangZhan()
{
    makeConnection();
    setMyRole(this);
}
void Logic::getCommand(unsigned short proto_type, google::protobuf::Message* proto)
{
    TipArea *tipArea;
    DecisionArea* decisionArea;
    BPArea* bpArea;
    SafeList<int> roleIDs;
    SafeList<int> options;
    PlayerArea* playerArea;
    int targetID,roleID,howMany;    

    network::RoleRequest* char_pick;
    int targetId;
    switch (proto_type)
    {
    case network::MSG_ROOMLIST_REP:
        lobby->fill((network::RoomListResponse*) proto);
        break;
    case network::MSG_GAME:
    {
        network::GameInfo* game_info = (network::GameInfo*) proto;
        if(game_info->has_player_id()){
            myID = game_info->player_id();
            dataInterface->setID(myID);
            cleanRoom();
            if(myID == GUEST)
                gui->logAppend(QStringLiteral("<font color=\'pink\'>房间已满,进入观战模式</font>"));
            else{
                gui->logAppend(QStringLiteral("<font color=\'pink\'>请准备</font>"));
                gui->logAppend(QStringLiteral("<font color=\'pink\'>觉得某人烦的话,可以“mute n”,n是该玩家座次;“unmute n”恢复</font>"));
            }
        }
        if(game_info->has_room_id()){
            gui->getTeamArea()->setRoomID(game_info->room_id());
        }
        int count = 0;

        setupRoom(game_info -> is_started(), game_info);

        for (int i = 0; i < game_info->player_infos_size(); ++i)
        {
            network::SinglePlayerInfo* player_info = (network::SinglePlayerInfo*)&(game_info->player_infos(i));
            targetID = player_info->id();
            if(player_info->has_role_id())
            {
                roleID = player_info->role_id();
                roles[targetID] = roleID;
                dataInterface->getPlayerList().at(targetID)->setRole(roleID);
                gui->getPlayerArea()->getPlayerItem(targetID)->setToolTip(dataInterface->getRoleSkillInfo(roleID));
				count++;
            }
            if(player_info->has_nickname()){
                dataInterface->setNickName(targetID, QString::fromStdString(player_info->nickname()));
            }
            if(player_info->has_team()){
                dataInterface->getPlayerById(targetID)->setTeam(player_info->team());
            }
            gui->getPlayerArea()->getPlayerItem(targetID)->setReady(player_info->ready());
            if(player_info->has_leader()){
                gui->getPlayerArea()->getPlayerItem(targetID)->setLeader(player_info->leader());
            }
        }


        if(count == dataInterface->getPlayerMax())
        {
            disconnect(getClient(),0,this,0);
            disconnect(gui->getDecisionArea(), 0, this, 0);
            disconnect(gui->getBPArea(),0,this,0);

            roleID = myID == GUEST ? roles[0] : roles[myID];
            setMyRole(roleID);
            network::GameInfo* toRole = new network::GameInfo;
            toRole->CopyFrom(*game_info);
            myRole->decipher(network::MSG_GAME, toRole);
            gui->hideBP();
        }
        gui->getPlayerArea()->update();
        break;
    }

    case network::MSG_BECOME_LEADER_REQ:
        state = 60;
        gui->reset();
        tipArea = gui->getTipArea();
        tipArea->setMsg(QStringLiteral("要申请做队长吗?"));

        decisionArea = gui->getDecisionArea();
        decisionArea->enable(0);
        decisionArea->enable(1);
        gui->alert();
        break;

    case network::MSG_GOSSIP:
        if(gui!=NULL)
        {
            network::Gossip* gossip = (network::Gossip*)proto;
            switch (gossip->type())
            {
            case network::GOSSIP_TALK:
                gui->chatAppend(gossip->id(), QString(gossip->txt().c_str()));
                break;
            case network::GOSSIP_NOTICE:
                gui->logAppend(QString(gossip->txt().c_str()));
                break;
            }
        }
        break;
    case network::MSG_ERROR:
    {
        network::Error* error = (network::Error*)proto;
        if(error->dst_id() == myID){
            gui->reset();
        }
        switch(error->id())
        {
        case GE_DISCONNECTED:
        {
            int targetId = error->dst_id();
            gui->logAppend(QStringLiteral("<font color=\'red\'>玩家") + QString::number(targetId) + QStringLiteral("离开房间</font>"));
            dataInterface->setNickName(targetId, "");
            dataInterface->getPlayerById(targetId)->setTeam(-1);
            gui->getPlayerArea()->getPlayerItem(targetId)->setReady(false);
            gui->getPlayerArea()->update();
            break;
        }
        case GE_NOT_WELCOME:
            gui->logAppend(QStringLiteral("<font color=\'red\'>这个房主比较高冷,下个房间见。。</font>"));
            break;
        case GE_WRONG_PASSWORD:
            gui->logAppend(QStringLiteral("<font color=\'red\'>瞎蒙果然是不行的。。</font>"));
            break;
        default:
            gui->logAppend(QStringLiteral("<font color=\'red\'>错误代码") + QString::number(error->id()) + "</font>");
            break;
            }
        break;
    }
//选择角色
    case network::MSG_ROLE_REQ:
    {
        char_pick = (network::RoleRequest*) proto;
        targetId = char_pick->id();
        if(char_pick->strategy() == ROLE_STRATEGY_31)
        {
            gui->logAppend(QStringLiteral("<font color=\'white\'>等待玩家") + QString::number(targetId) + QStringLiteral("选择角色")+"</front");
            if(targetId != myID)
                break;
            state=46;
            tipArea=gui->getTipArea();
            decisionArea=gui->getDecisionArea();
            tipArea->reset();
            howMany=char_pick->role_ids_size();
            for(int i=0;i<howMany;i++){
                roleID=char_pick->role_ids(i);
                tipArea->addBoxItem(QString::number(roleID)+"."+dataInterface->getRoleName(roleID));
            }
            tipArea->setMsg(QStringLiteral("请选择角色:"));
            tipArea->showBox();
            decisionArea->enable(0);
            gui->alert();
            break;
        }
        else if(char_pick->strategy() == ROLE_STRATEGY_BP)
        {
            state = 51;
            tipArea=gui->getTipArea();
            decisionArea=gui->getDecisionArea();
            bpArea = gui->getBPArea();
            tipArea->reset();
            howMany=char_pick->role_ids_size();
            for(int i=0;i<howMany;i++){
                roleIDs << char_pick->role_ids(i);
                options << char_pick->args(i);
            }
            bpArea->BPStart(howMany, roleIDs, options, char_pick->opration());
            if(char_pick->opration() ==  BP_NULL )
            {
                int lastChosen = -1;
                int step = 0;
                for(int i = 0; i < howMany; i++){
                    if(options[i] > step){
                        step = options[i];
                        lastChosen = i;
                    }
                }
                if(step == 0){
                    gui->logAppend(QStringLiteral("以下英雄响应了召唤:"));
                    QString msg;
                    foreach(int id, roleIDs)
                        msg += QStringLiteral("<font color=\'yellow\'>%1 </font>").arg(dataInterface->getRoleName(id));
                    gui->logAppend(msg);
                }
                else {
                    QString msg = QStringLiteral("<font color=\'yellow\'>%1</font> %2 了<font color=\'yellow\'>%3</font>");
                    QString nickname = dataInterface->getPlayerList().at(targetId)->getNickname();
                    gui->logAppend(msg.arg(nickname, ((options[lastChosen]-1) % 4) < 2 ? "BAN" : "PICK", dataInterface->getRoleName(roleIDs[lastChosen])));
                }
            }