mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
removing attack order once the target unit is destroyed
This commit is contained in:
@@ -248,6 +248,24 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::attack(Order order){
|
||||
if(orders[0].targets[0].unit){
|
||||
bool unitFound = false;
|
||||
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
vector<Unit*> units = pl->getUnits();
|
||||
|
||||
if(find(units.begin(), units.end(), orders[0].targets[0].unit) != units.end()){
|
||||
unitFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!unitFound)
|
||||
removeOrder(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setOrder(Order order) {
|
||||
while (!orders.empty())
|
||||
removeOrder(0);
|
||||
|
||||
Reference in New Issue
Block a user