mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-03-03 16:49:45 +01:00
lagger til en del hjelpe funkjsoner
lagg til setpowerdown som setter powerdown til en gitt robot lagg til repairRobotOnTile som reparere roboter en skade fra en gitt robot lagg til executepowerdown som setter skaden til en gitt robot til 0
This commit is contained in:
parent
4df45f39a0
commit
dafa5c87a3
@ -135,6 +135,35 @@ public class Board {
|
||||
moveRobot(robotID, Direction.getReverseDirection(robots.get(robotID).getFacingDirection()));
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the powerdown status of the robot
|
||||
* @param robotID the robotid of the robot
|
||||
* @param powerdown the status of the powerdown
|
||||
*/
|
||||
public void setPowerDown(RobotID robotID,Boolean powerdown){
|
||||
robots.get(robotID).setPowerDown(powerdown);
|
||||
}
|
||||
|
||||
/**
|
||||
* removes one damage for a given robot given that it has taken som damage before
|
||||
* @param robotID the ID of the robot
|
||||
*/
|
||||
public void repairRobotOnTile(RobotID robotID){
|
||||
Robot robot = robots.get(robotID);
|
||||
int newDamage =Math.max(robot.getDamageTaken()-1,0);
|
||||
robot.setDamageTaken(newDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the damage taken of robots in powerdown to 0
|
||||
*/
|
||||
public void executePowerdown(){
|
||||
for (Robot robot:robots.values()) {
|
||||
if(robot.isInPowerDown()){
|
||||
robot.setDamageTaken(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Moves a robot one unit in a specified direction
|
||||
* @param robotID ID of the robot to move
|
||||
|
Loading…
x
Reference in New Issue
Block a user