mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Fikser litt på kommentarer og kodestil i Robot
This commit is contained in:
parent
fe42257cb4
commit
43613ce669
@ -18,8 +18,8 @@ public class Robot {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new robot
|
* Instantiates a new robot
|
||||||
* @param robotId gives the robot a identifier that links it too the correct player
|
* @param robotId The global identifier of the robot
|
||||||
* @param spawnPosition gives the robot its starting position on the map
|
* @param spawnPosition The starting position of the robot
|
||||||
*/
|
*/
|
||||||
public Robot (RobotID robotId, Position spawnPosition) {
|
public Robot (RobotID robotId, Position spawnPosition) {
|
||||||
this.robotId = robotId;
|
this.robotId = robotId;
|
||||||
@ -30,65 +30,67 @@ public class Robot {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the damage the robot has taken
|
* Gets the damage the robot has taken
|
||||||
* @return the amount of damage the robot has received
|
* @return The amount of damage the robot has received
|
||||||
*/
|
*/
|
||||||
public int getDamage(){
|
public int getDamageTaken() {
|
||||||
return robotDamageTaken;
|
return robotDamageTaken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the robot's damage to a given amount
|
* Sets the robot's taken damage to a given amount
|
||||||
* @param damage the amount of damage the robot has received
|
* @param damage The amount of damage the robot has received
|
||||||
*/
|
*/
|
||||||
public void setDamage (int damage){
|
public void setDamageTaken(int damage) {
|
||||||
this.robotDamageTaken = damage;
|
this.robotDamageTaken = damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the robot's current position on the map
|
* Gets the robot's current position on the board
|
||||||
* @return the robot's current position
|
* @return The robot's current position
|
||||||
*/
|
*/
|
||||||
public Position getPosition() {
|
public Position getPosition() {
|
||||||
return currentPosition;
|
return currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* places the robot on a new position
|
* Sets the robot's current position on the board
|
||||||
* @param newPosition the new position for the robot
|
* @param newPosition The new position of the robot
|
||||||
*/
|
*/
|
||||||
public void setPosition( Position newPosition ) {
|
public void setPosition( Position newPosition ) {
|
||||||
this.currentPosition = newPosition;
|
this.currentPosition = newPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places the status of the powerdown field
|
* Sets power-down status
|
||||||
* @param powerDownStatus True if robot is going to go to powerdown. False otherwise
|
* @param powerDownStatus Whether the robot is currently in power-down
|
||||||
*/
|
*/
|
||||||
public void setPowerDown(Boolean powerDownStatus) {
|
public void setPowerDown(Boolean powerDownStatus) {
|
||||||
this.inPowerDown = powerDownStatus;
|
this.inPowerDown = powerDownStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the status of the robot's powerdown field
|
* Gets the robot's power-down status
|
||||||
* @return robot's powerdown status
|
* @return Whether the robot is currently in power-down
|
||||||
*/
|
*/
|
||||||
public Boolean isInPowerDown(){
|
public Boolean isInPowerDown(){
|
||||||
return inPowerDown;
|
return inPowerDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the robot's last visited flag too the new flag and places its backup on the flags position
|
* Set the robot's last visited flag to the new flag and places its backup on the flag's position
|
||||||
* @param currentFlag the flag the robot is standing on
|
* @param currentFlag The flag the robot is standing on
|
||||||
* @param newBackupPosition the position of the flag
|
|
||||||
*/
|
*/
|
||||||
public void setLastFlagVisitedAndBackupPosition(int currentFlag, Position newBackupPosition){
|
public void setLastFlagVisitedAndUpdateBackupPosition(int currentFlag) {
|
||||||
|
if (currentFlag - 1 != this.lastFlagVisited) {
|
||||||
|
throw new IllegalArgumentException("The robot has not yet visited the previous flag!");
|
||||||
|
}
|
||||||
this.lastFlagVisited = currentFlag;
|
this.lastFlagVisited = currentFlag;
|
||||||
this.backupPosition = newBackupPosition;
|
this.backupPosition = currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the correct flag the robot visited
|
* Gets the last flag the robot visited
|
||||||
* @return last visited flag
|
* @return Last visited flag
|
||||||
*/
|
*/
|
||||||
public int getLastFlagVisited() {
|
public int getLastFlagVisited() {
|
||||||
return lastFlagVisited;
|
return lastFlagVisited;
|
||||||
@ -103,8 +105,8 @@ public class Robot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the identifier of the players controlling the robot
|
* Gets the robot ID
|
||||||
* @return player identifier
|
* @return Robot ID
|
||||||
*/
|
*/
|
||||||
public RobotID getRobotId() {
|
public RobotID getRobotId() {
|
||||||
return robotId;
|
return robotId;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user