コード例 #1
0
void Challenge::manageStuff(Player *p, const ChallengeInfo &c)
{
    if (c.desc() == ChallengeInfo::Accepted) {
        if (p != dest) {
            cancel(src);
            return;
        }
        if (!src->okForBattle()) {
            cancel(src);
            return;
        }

        /* Make sure the challenged one selected a team of the correct tier, correct gen */
        if (p->team(c.team).tier != desc.desttier || p->team(c.team).gen != desc.gen) {
            cancel(src);
            return;
        }

        src->removeChallenge(this);
        dest->removeChallenge(this);

        desc.rated = server->allowThroughChallenge && server->canHaveRatedBattle(src->id(), dest->id(), src->team(desc.team), dest->team(c.team), false, false);

        emit battleStarted(src->id(), dest->id(), desc, desc.team, c.team);

        delete this;
        return;
    }
    if (c.desc() == ChallengeInfo::Busy || c.desc() == ChallengeInfo::Cancelled || c.desc() == ChallengeInfo::Refused) {
        cancel(p, c.desc() == ChallengeInfo::Refused);
        return;
    }
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: ObKo/HoSpLo
void CMainWindow::connectSignals()
{
    CChatManager *Manager = CChatManager::instance();
    CNetworkClient *Network = CNetworkClient::instance();
    CBattleManager *BattleManager = CBattleManager::instance();

    connect(ui->ChatTabWidget->tabBar(), SIGNAL(tabCloseRequested(int)), Manager, SLOT(closeChannel(int)));
    connect(ui->ChatTabWidget->tabBar(), SIGNAL(currentChanged(int)), Manager, SLOT(changeCurrentChannel(int)));
    connect(ui->ChatTabWidget->tabBar(), SIGNAL(tabMoved(int,int)), Manager, SLOT(moveChannel(int,int)));
    connect(Manager, SIGNAL(joined(CChannel*)), this, SLOT(createTab(CChannel*)));
    connect(Manager, SIGNAL(closeTab(int)), this, SLOT(removeTab(int)));
    connect(Manager, SIGNAL(currentChanged(CChannel*)), ui->ChatTabWidget->chatView(), SLOT(loadChannel(CChannel*)));
    connect(ui->ChannelsView, SIGNAL(doubleClicked(QModelIndex)), CChatManager::instance(), SLOT(doubleClicked(QModelIndex)));
    connect(ui->ChannelUserView, SIGNAL(doubleClicked(QModelIndex)),
            CUserManager::instance()->chatModel(), SLOT(doubleClicked(QModelIndex)));
    connect(ui->actionChatSend, SIGNAL(triggered()), this, SLOT(sendChat()));
    connect(ui->actionBattleSend, SIGNAL(triggered()), this, SLOT(sendBattle()));
    connect(Manager, SIGNAL(currentChanged(int)), ui->ChatTabWidget->tabBar(), SLOT(setCurrentIndex(int)));
    connect(ui->BattleListView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            CBattleManager::instance(), SLOT(battleSelected(QModelIndex)));
    connect(ui->BattleListView, SIGNAL(doubleClicked(QModelIndex)), CBattleManager::instance(), SLOT(doubleClicked(QModelIndex)));
    connect(ui->BattlePreviewView, SIGNAL(doubleClicked(QModelIndex)),
            CBattleManager::instance()->battlePreviewModel(), SLOT(doubleClicked(QModelIndex)));
    connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(showConnectDialog()));
    connect(&ConnectDialog, SIGNAL(connect(QString,int,QString,QString)), Network, SLOT(connectToServer(QString,int,QString,QString)));
    connect(Network, SIGNAL(disconnected()), this, SLOT(networkDisconnected()));
    connect(Network, SIGNAL(connected()), this, SLOT(networkConnected()));
    connect(Network, SIGNAL(multiplayerDisabled()), this, SLOT(disableMultiplayerGUI()));
    connect(Network, SIGNAL(multiplayerEnabled()), this, SLOT(enableMultiplayerGUI()));
    connect(ui->actionDisconnect, SIGNAL(triggered()), Network, SLOT(disconnect()));
    connect(CBattleManager::instance(), SIGNAL(currentMapChanged(CMap*)), ui->MapInfo, SLOT(setMap(CMap*)));
    connect(CBattleroomManager::instance(), SIGNAL(mapChanged(CMap*)), ui->BattleMapInfo, SLOT(setMap(CMap*)));
    connect(CBattleroomManager::instance(), SIGNAL(updateChat(CChannel*)), ui->BattleChatText, SLOT(loadChannel(CChannel*)));
    connect(CBattleroomManager::instance(), SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(ui->LeaveBattleButton, SIGNAL(clicked()), CBattleroomManager::instance(), SLOT(leaveBattle()));
    connect(ui->DownloadButton, SIGNAL(clicked()), this, SLOT(execDownload()));

    connect(ui->actionDeleteDownload, SIGNAL(triggered()), this, SLOT(removeDownload()));

    connect(ui->actionDownloadMap, SIGNAL(triggered()), BattleManager, SLOT(downloadMapForBattle()));
    connect(ui->actionDownloadMod, SIGNAL(triggered()), BattleManager, SLOT(downloadModForBattle()));

    connect(ui->DownloadView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showDownloadContextMenu(QPoint)));
    connect(ui->BattleListView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showBattleContextMenu(QPoint)));

    connect(Network, SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(CDownloadManager::instance(), SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(Manager, SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(CDownloadManager::instance(), SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(Network, SIGNAL(agreement(QString)), this, SLOT(showAgreement(QString)));

    connect(ui->actionReloadUnitSync, SIGNAL(triggered()), CUnitSync::instance(), SLOT(reload()));
    connect(CUnitSync::instance(), SIGNAL(error(int,QString)), this, SLOT(error(int,QString)));
    connect(CUserManager::instance(), SIGNAL(lobbyUserBattleStatusChanged(CBattleStatus*)),
            this, SLOT(updateBattleStatus(CBattleStatus*)));

    connect(CUnitSync::instance(), SIGNAL(loaded()), this, SLOT(unitsyncLoaded()));
    connect(CUnitSync::instance(), SIGNAL(unloaded()), this, SLOT(unitsyncUnloaded()));

    connect(ui->actionUpdateStatus, SIGNAL(triggered()), this, SLOT(changeBattleStatus()));

    connect(CBattleroomManager::instance(), SIGNAL(battleJoined(CBattle*)), this, SLOT(enableBattleroom(CBattle*)));
    connect(CBattleroomManager::instance(), SIGNAL(battleClosed()), this, SLOT(disableBattleroom()));
    connect(CBattleroomManager::instance(), SIGNAL(gameStarted()), this, SLOT(lockBattleroom()));
    connect(CBattleroomManager::instance(), SIGNAL(gameEnded()), this, SLOT(unlockBattleroom()));
    connect(CBattleroomManager::instance(), SIGNAL(battleStarted()), this, SLOT(onBattleStarted()));
    connect(CBattleroomManager::instance(), SIGNAL(battleEnded()), this, SLOT(onBattleEnded()));
    connect(ui->SelectColorButton, SIGNAL(clicked()), this, SLOT(selectColor()));
    connect(ui->StartBattleButton, SIGNAL(clicked()), CBattleroomManager::instance(), SLOT(startGame()));

    connect(&ColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(colorSelected(QColor)));
}