void Planet::findPosition() { Point2D a; for ( int j = 0; j <getPopulation(); j++) { for (int k = j + 1; k < getPopulation(); k++) { if (a.getDistance(population[j]->getPosition(), population[k]->getPosition()) < 5) { int random = rand() % 2 + 1; switch (random) { case 1: population[j]->Attack(*population[j]); break; case 2: addPopulation(entity, 1); } } else if (a.getDistance(population[j]->getPosition(), population[k]->getPosition()) == 0) { movePopulation(); } } } }
/** * @brief Select a new Cell * @details If there isn't a selected Cell and the Cell belongs to the player, select that Cell * If there is already a selected Cell move the population from the previous selected cell to @hc * * @param hc a pointer to the new selected Cell * @return true if hc is selected at the end false otherwise. */ bool MainWindow::newSelectedCell(HexaCell *hc) { if (selectedCell == nullptr && hc->getPlayerID() == 1) { selectedCell = hc; return true; } else if (selectedCell != nullptr) { list<HexaCell*> c = hexaCellBoard->dijkstra(selectedCell, hc, 1); if (!c.empty()) { movePopulation(c,1); } selectedCell->setSelected(false); selectedCell = nullptr; for( auto i : path ) { i->setHighlight(false); } path.clear(); return false; } return false; }