bool Controller::parseErrorInfo(const QString& data) { QRegExp rx("wronguser:"******"Wrong user"; return true; } return false; }
void Controller::onGameStart() { if( !model->checkMyField() ) { emit gameError( GEM_WRONG_FIELD ); return; } if( client->state() == QAbstractSocket::ConnectedState ) { emit gameError( GEM_ALREADY_CONNECTED ); return; } qDebug( "Connected to host %s:%d as %s", qPrintable( serverAddress.toString() ), serverPort, qPrintable( model->getLogin() ) ); client->connectToHost( serverAddress, serverPort ); }
void MainWindow::play() { Game *g = new Game(ui->serverLineEdit->text(), 995, ui->usernameLineEdit->text(), ui->passwordLineEdit->text(), botPath, this); connect(g, SIGNAL(error(Game::Error)), this, SLOT(gameError(Game::Error))); connect(g, SIGNAL(started(const Player&)), this, SLOT(gameStarted(const Player&))); connect(g, SIGNAL(waiting(const Player&)), this, SLOT(gameWaiting(const Player&))); connect(g, SIGNAL(ended(bool)), this, SLOT(gameEnded(bool))); GameWidget *gw = new GameWidget("Waiting for opponent...", this); connect(g, SIGNAL(state(const QString&)), &(gw->gameScene()), SLOT(setGameState(const QString&))); connect(g, SIGNAL(started(const Player &)), gw, SLOT(gameStarted(const Player &))); gw->show(); g->play(); }