Ejemplo n.º 1
0
void Server::incomingConnection(int socketDescriptor)
{
    Thread *thread = new Thread(socketDescriptor, this);
    for (int i = 0; i < numberOfPlayers; i++){
        if (!players[i]->isConnected()){
            players[i]->setConnectionThread(thread);
            connect(players[i], SIGNAL(fromPlayer(QString)), this, SLOT(fromClient(QString)));
            break;
        }
    }
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(thread, SIGNAL(started()), thread, SLOT(threadStarted()));
    connect(thread, SIGNAL(threadRead()), this, SLOT(checkPlayers()));
    thread->start();
}
Ejemplo n.º 2
0
        void UpdateAI(const uint32 diff)
        {
            if (checkPlayers())
            {
                if (!eventStarted)  // Event not started, player found
                {
                    _events.ScheduleEvent(EVENT_NEXT_MOVEMENT, 1000);
                    _events.ScheduleEvent(EVENT_LIGHTNING, 5000);
                    eventStarted = true;
                }
            }
            else
            {
                if (eventStarted)  // Event started, no player found
                    Reset();

                return;
            }

            _events.Update(diff);

            switch (_events.ExecuteEvent())
            {
                case EVENT_NEXT_MOVEMENT:
                {
                    if (me->HasAura(SPELL_STUNNED))
                        _events.ScheduleEvent(EVENT_NEXT_MOVEMENT, 2000);

                    GoToNextPos();
                    break;
                }
                case EVENT_STUNNED:
                {
                    me->RemoveAurasDueToSpell(SPELL_STUNNED);
                    me->CastSpell(me, SPELL_SERPENT_SWEEP, false);
                    _events.ScheduleEvent(EVENT_NEXT_MOVEMENT, 3000);
                    break;
                }
                case EVENT_LIGHTNING:
                {
                    if (Player* player = GetRandomPlayer())
                        me->CastSpell(player, SPELL_LIGHTNING, false);

                    _events.ScheduleEvent(EVENT_LIGHTNING, 5000);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
void PollingWatcher::addFactory(PollingPlayerFactory* factory)
{
    if (factory->exists()) {
        Player::Ptr player = factory->create();
        if (!player.isNull()) {
            m_players.insert(player);
            m_usedFactories.insert(factory);
            emit newPlayer(player);
        } else {
            kWarning() << "Failed to create a player";
            m_polledFactories.insert(factory);
        }
    } else {
        m_polledFactories.insert(factory);
    }

    if (!m_timer) {
        m_timer = new QTimer(this);
        m_timer->setInterval(5000);
        connect(m_timer, SIGNAL(timeout()), this, SLOT(checkPlayers()));
        m_timer->start();
    }
}
Ejemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
        checkPlayers();
            qDebug() << "open database " ;

    //QSQLITE check
    if (!QSqlDatabase::drivers().contains("QSQLITE"))
    {
        QMessageBox::critical(this, "Ошибка", "Драйвер SQLite не найден, выход");
        qApp->exit(2);
    }
    //test

QDir dir = QDir::homePath() + "/.rks";
if (!dir.exists()) {dir.mkpath(QDir::homePath() + "/.rks/teams");}
ui->mnuLeague->setEnabled(false);
ui->mnuStats->setEnabled(false);
//временно
leag = true;
loaded = false;
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->sortByColumn(8);
//статусбар
infolabel = new QLabel (this);
statusBar()->addWidget(infolabel);
//положние
QFile f(QDir::homePath() + config);
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {qDebug() << "Config read error."; return;}
QByteArray state = f.readAll();
restoreState(state);
f.close();
ui->dockWidget_2->setVisible(false);

}