added check to stop nullpointexception

This commit is contained in:
Tobydrama 2020-04-20 18:49:50 +02:00
parent 4fe0439297
commit 13730dd592

View File

@ -167,7 +167,7 @@ public class Board {
if(robots.containsKey(robotID)){ if(robots.containsKey(robotID)){
robots.get(robotID).setPowerDown(powerDown); robots.get(robotID).setPowerDown(powerDown);
} }
else { else if (getRobotFromDeadRobots(robotID)!=null) {
getRobotFromDeadRobots(robotID).setPowerDown(powerDown); getRobotFromDeadRobots(robotID).setPowerDown(powerDown);
} }
} }
@ -184,9 +184,10 @@ public class Board {
if(robots.containsKey(robotID)){ if(robots.containsKey(robotID)){
return robots.get(robotID).isInPowerDown(); return robots.get(robotID).isInPowerDown();
} }
else { else if (getRobotFromDeadRobots(robotID)!=null){
return getRobotFromDeadRobots(robotID).isInPowerDown(); return getRobotFromDeadRobots(robotID).isInPowerDown();
} }
return false;
} }
private Robot getRobotFromDeadRobots(RobotID robotID){ private Robot getRobotFromDeadRobots(RobotID robotID){
for (Robot robot:deadRobots) { for (Robot robot:deadRobots) {