#include "Game.h" Game::Game(uint width, uint height, PlayerNumber num): m_Field(width, height) { //m_vPlayers.resize(num); // is it possible to resize it without trying to fill it? (i.e. fill with null pointers) for(PlayerNumber i = 0; i path; std::vector< std::vector > secondPassPath; for(std::vector::iterator player = m_vPlayers.begin(); player != m_vPlayers.end(); ++player) { if (player->isAlive()) { path = player->move(); secondPassPath.push_back(path); for(std::vector::iterator coord = path.begin(); coord != path.end(); ++coord) { try { Cell& cell = m_Field.getCell(*coord); if (!(cell.getState() == EMPTY_CELL || (cell.getState() == PLAYER && (cell.getPlayer()->getNumber() == player->getNumber())))) { player->kill(); cell.setState(BOOM); if (cell.getState() == PLAYER_JUST_MOVED) { (cell.getPlayer())->kill(); } } else { cell.setState(PLAYER_JUST_MOVED); cell.setPlayer(&(*player)); } } catch (std::exception out_of_bounds) { // doesn't that catch just any exception and name it out_of_bounds? player->kill(); // set the cell before as boom? } } } } for(std::vector< std::vector >::iterator it = secondPassPath.begin(); it != secondPassPath.end(); ++it) { for(std::vector::iterator coord = it->begin(); coord != it->end(); ++coord) { try { Cell& cell = m_Field.getCell(*coord); if (coord == it->end() -1) { cell.setState(PLAYER); } else { cell.setState(PLAYER_WALL); } } catch (std::exception out_of_bounds) {} // don't do anything } } }