void Game::update() { if (State != STATE_GAME) return; SceneHandler->update(); // check scene flags unsigned short flags = SceneHandler->getFlags(); if (flags & EVENT_WIN) incPoints(); if (flags & EVENT_LOSE) decPoints(); if (flags & EVENT_BALLCOLL) SceneHandler->tellEnemies(); SceneHandler->resetFlags(); // update view ViewHandler->update(); }
///////////////////////////////////////////////////////////////////////////// // calculate trade routes ///////////////////////////////////////////////////////////////////////////// void CGLView::tradeRoutes() { int i, j; int nTile2, nTile3; int nC2, nC3; int nCity; int nPoints; //reset all players trade route points counts for(i = 0; i < m_iNumPlayers; i++) { decPoints(i, m_pGame->m_players[i].m_nTradePoints, TRUE); m_pGame->m_players[i].m_nTradePoints = 0; } //look for trade routes from each city for(i = 0; i < m_nTiles; i++) { //look at each side for(j = 0; j < 6; j++) { //get the bordering tiles nTile2 = m_pBoard[i].getSide(j); nTile3 = m_pBoard[i].getSide((j + 5) % 6); nC2 = (j + 4) % 6; nC3 = (j + 2) % 6; //avoid multiple runs through the list by only using the lowest //tile of any combination of three if((nTile2 < i) || (nTile3 < i)) { continue; } //see if there is a city/settlement here nCity = m_pBoard[i].getCity(j); //if zero, continue if(0 == nCity) { continue; } //determine the starting island if(TRUE == VALID_LAND(m_pBoard[i].getType())) { m_nTradeIsland = m_pBoard[i].getIsland(); } else if((-1 != nTile2) && (TRUE == VALID_LAND(m_pBoard[nTile2].getType()))) { m_nTradeIsland = m_pBoard[nTile2].getIsland(); } else if(-1 != nTile3) { m_nTradeIsland = m_pBoard[nTile3].getIsland(); } //set values for traversing m_nTradePlayer = nCity % 10; //the originating city must be on the starting island of the player if(m_nTradeIsland != m_pGame->m_players[m_nTradePlayer].m_nHomeIsland) { continue; } //run the algorithm nPoints = tradeIterateStart(i, j); //set the extra chit markers m_pBoard[i].setExtra(j, nPoints); m_pBoard[nTile2].setExtra(nC2, nPoints); m_pBoard[nTile3].setExtra(nC3, nPoints); //set the players point total m_pGame->m_players[m_nTradePlayer].m_nTradePoints += nPoints; } } //finally, reincrement all the trade route points for(i = 0; i < m_iNumPlayers; i++) { incPoints(i, m_pGame->m_players[i].m_nTradePoints); } }