Example #1
0
bool GameManager::startGame(uint idCampaign)
{
    m_campaignManager.joinCampaign( idCampaign, m_accountManager.accountId());
    m_campaignManager.setCurrentCampaign( idCampaign);

    //Remove unprocessed events
    //Read events
    QString str = QString("DELETE FROM  `simplisim_dejavu`.`geo_events` WHERE ( \
        `EMITTER` =%1 OR  `RECIPIENT` =%1 ) AND  `PROCESSED` =0").arg( m_gameData.accountId() );
    QSqlQuery query(str);
    query.exec();

    m_positionLogger.start();

    //Notify the others players using the intercom
    m_messageModel.sendSystemMessage( m_gameData.accountName() + " joined the campaign");

    m_gameTimer->start(3000);

    m_playerModel.resetModel();
    m_messageModel.resetModel();
    m_geoLocalItemsModel.resetModel(); //QTimer::singleShot(1000, &m_geoLocalItemsModel, SLOT(resetModel()) );


    emit campaignNameChanged();
    emit gameStarted();
    return true;
}
Example #2
0
void WaitJoinDialog::onGameStarted()
{
    mJoined = false;
    disconnect(Client::instance(), SIGNAL(gameStarted()), this, SLOT(onGameStarted()));
    disconnect(Client::instance(), SIGNAL(opponentJoined(const Player&)), this, SLOT(onOpponentJoined(const Player&)));
    qDebug() << "disconnect 'opponentJoined' to WaitJoinDialog::onOpponentJoined (onGameStarted)";

    MainWindow::instance()->setMode(MW_WAIT);
    UI::instance()->setPlayerColor(PT_ME, PC_WHITE);
    UI::instance()->startGame();
}
void SimpleBallGamePlugin::onStartGame()
{
	//TODO: this is copied from previous reset(), still needs refactoring
	disconnectConnections();

	delete m_logic;
	delete m_summary;

	m_logic = new SimpleBallGameLogic(this);
	m_summary = new SimpleBallGameSummary(this);

	createConnections();
	m_logic->startGame();

	emit gameStarted();
}
Example #4
0
void Board::newGame()
{
	if (!endGame()) {
		return;
	}

	m_flash_timer->stop();
	m_shift_timer->stop();
	delete m_piece;
	m_piece = 0;

	emit hideMessage();
	m_started = true;
	m_done = false;
	m_paused = false;
	m_removed_lines = 0;
	m_level = 1;
	m_score = 0;
	m_shift_timer->setInterval(m_shiftTime);
	m_next_piece = (rand() % 7) + 1;
	m_topCellY = 19;
	m_difficultyLevel = FirstLevel;
	m_shiftTime = m_firstLevelShiftTime;

	for (int i = 0; i < 4; ++i)
		m_full_lines[i] = -1;

	for (int col = 0; col < 10; ++col) {
		for (int row = 0; row < 20; ++row) {
			m_cells[col][row] = 0;
		}
	}

	emit pauseAvailable(true);
	emit levelUpdated(m_level);
	emit linesRemovedUpdated(m_removed_lines);
	emit scoreUpdated(m_score);
	emit gameStarted();

	setCursor(Qt::BlankCursor);
	createPiece();
}
Example #5
0
void WaitJoinDialog::onOpponentJoined(const Player& opponent)
{
    qDebug() << "WaitJoinDialog::onOpponentJoined ";
    /*
    // Thiss should fix a bug with a double calling of onOpponentJoined
    if(mJoined)
    {
        qDebug() << "WaitJoinDialog::onOpponentJoined. Double joining refused.";
        return;
    }
    else
    {
        mJoined = true;
    }*/

    disconnect(Client::instance(), SIGNAL(opponentJoined(const Player&)), this, SLOT(onOpponentJoined(const Player&)));
    qDebug() << "disconnect 'opponentJoined' to WaitJoinDialog::onOpponentJoined ";


    int tableID = UI::instance()->getGameTable();

    UI::instance()->setPlayerName(PT_OPPONENT, opponent.name);
    UI::instance()->setPlayerRating(PT_OPPONENT, opponent.rating);

    // Get player name by ID
    QString ratingText = (opponent.rating == RATING_NOT_AVAILABLE) ? tr("not available") : QString::number(opponent.rating);
    if(MainWindow::instance()->showQuestion(opponent.name + " " + tr("wants to play chess with you") + "\n" +
              "(" + tr("opponent rating") + ": "+ ratingText + ") \n\n" +
              tr("Start the game?")))
    {
        MainWindow::instance()->setMode(MW_WAIT);
        connect(Client::instance(), SIGNAL(gameStarted()), this, SLOT(onGameStarted()));
        Client::instance()->approveGame(tableID);
    }
    else
    {
        connect(Client::instance(), SIGNAL(gameRejected()), this, SLOT(onGameRejected()));
        Client::instance()->rejectGame(tableID);
    }
}
Example #6
0
void MineField::cellClicked( int row, int col )
{
    if ( state() == GameOver )
	return;
    if ( state() == Waiting ) {
	Mine* m = mine( row, col );
	if ( !m )
	    return;
	m->setState( Mine::Empty );
	nonminecount--;
	placeMines();
	setState( Playing );
	emit gameStarted();
	updateMine( row, col );
    } else { // state() == Playing
	holdTimer->stop();
	if ( ignoreClick )
	    ignoreClick = FALSE;
	else
	    updateMine( row, col );
    }
}
Example #7
0
GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem(0)
{
    connect(p_game, SIGNAL(levelStarted(bool)), SLOT(intro(bool)));
    connect(p_game, SIGNAL(gameStarted()), this, SLOT(start()));
    connect(p_game, SIGNAL(pauseChanged(bool,bool)), this, SLOT(setPaused(bool,bool)));
    connect(p_game, SIGNAL(elementEaten(qreal,qreal)), this, SLOT(hideElement(qreal,qreal)));
    connect(p_game, SIGNAL(bonusOn()), this, SLOT(displayBonus()));
    connect(p_game, SIGNAL(bonusOff()), this, SLOT(hideBonus()));

    // Connection between Game and GameScene for the display of won points when a bonus or a ghost is eaten
    connect(p_game, SIGNAL(pointsToDisplay(long,qreal,qreal)), this, SLOT(displayPoints(long,qreal,qreal)));

    // Create the theme instance
    m_theme = new KGameTheme();

    // Load the SVG file
    m_renderer = new QSvgRenderer();
    loadTheme();

    // Create the MazeItem
    m_mazeItem = new MazeItem();
    // Give the maze the shared renderer to avoid loading the whole SVG file again
    m_mazeItem->setSharedRenderer(m_renderer);
    // Set the element Id to the right value
    m_mazeItem->setElementId(QLatin1Literal("maze"));
    m_mazeItem->setZValue(-2);

    // Create the KapmanItem
    m_kapmanItem = new KapmanItem(p_game->getKapman());
    m_kapmanItem->setSharedRenderer(m_renderer);
    m_kapmanItem->setElementId(QLatin1Literal("kapman_0"));
    // Corrects the position of the KapmanItem
    m_kapmanItem->update(p_game->getKapman()->getX(), p_game->getKapman()->getY());
    m_kapmanItem->setZValue(2);
    // Stops the Kapman animation
    m_kapmanItem->stopAnim();

    // Create the GhostItems
    for (int i = 0; i < p_game->getGhosts().size(); ++i) {
        GhostItem *ghost = new GhostItem(p_game->getGhosts()[i]);
        ghost->setSharedRenderer(m_renderer);
        ghost->setElementId(p_game->getGhosts()[i]->getImageId());
        ghost->update(p_game->getGhosts()[i]->getX(), p_game->getGhosts()[i]->getY());
        // At the beginning, the ghosts are above the kapman because they eat him
        ghost->setZValue(3);
        m_ghostItems.append(ghost);
    }
    // Create the Pill and Energizer items
    m_elementItems = new ElementItem **[m_game->getMaze()->getNbRows()];
    for (int i = 0; i < m_game->getMaze()->getNbRows(); ++i) {
        m_elementItems[i] = new ElementItem*[m_game->getMaze()->getNbColumns()];
        for (int j = 0; j < m_game->getMaze()->getNbColumns(); ++j) {
            if (m_game->getMaze()->getCell(i, j).getElement() != NULL) {
                // Create the element and set the image
                ElementItem *element = new ElementItem(m_game->getMaze()->getCell(i, j).getElement());
                element->setSharedRenderer(m_renderer);
                element->setElementId(m_game->getMaze()->getCell(i, j).getElement()->getImageId());
                element->update(m_game->getMaze()->getCell(i, j).getElement()->getX(), m_game->getMaze()->getCell(i, j).getElement()->getY());
                m_elementItems[i][j] = element;
            } else {
                m_elementItems[i][j] = NULL;
            }
        }
    }
    // Create the Bonus item
    m_bonusItem = new ElementItem(m_game->getBonus());
    m_bonusItem->setSharedRenderer(m_renderer);
    m_bonusItem->setElementId(QLatin1Literal("bonus1"));

    // All elements are created, update theme properties
    updateSvgIds();
    updateThemeProperties();

    // Create the introduction labels
    m_introLabel = new QGraphicsTextItem(i18n("GET READY!!!"));
    m_introLabel->setFont(QFont(QLatin1Literal("Helvetica"), 25, QFont::Bold, false));
    m_introLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    m_introLabel->setZValue(4);
    m_introLabel2 = new QGraphicsTextItem(i18n("Press any arrow key to start"));
    m_introLabel2->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Bold, false));
    m_introLabel2->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    m_introLabel2->setZValue(4);
    // Create the new level label
    m_newLevelLabel = new QGraphicsTextItem();
    m_newLevelLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false));
    m_newLevelLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    m_newLevelLabel->setZValue(4);
    // Create the pause label
    m_pauseLabel = new QGraphicsTextItem(i18n("PAUSED"));
    m_pauseLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false));
    m_pauseLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    m_pauseLabel->setZValue(4);

    // Display the MazeItem
    addItem(m_mazeItem);
    // Display the KapmanItem
    addItem(m_kapmanItem);
    // Display each GhostItem
    for (int i = 0; i < m_ghostItems.size(); ++i) {
        addItem(m_ghostItems[i]);
    }
    // Display each Pill and Energizer item and introduction labels
    intro(true);
}
void InitSceneController::startGame() {
	emit gameStarted(mPoints);
}
Example #9
0
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)));
}