mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Oppdaterer Robot til å bruke en RobotID i stedet for en playerId int
This commit is contained in:
parent
37f6e44220
commit
9c5a2b60e7
@ -1,13 +1,14 @@
|
|||||||
package inf112.fiasko.roborally.objects;
|
package inf112.fiasko.roborally.objects;
|
||||||
|
|
||||||
import inf112.fiasko.roborally.element_properties.Position;
|
import inf112.fiasko.roborally.element_properties.Position;
|
||||||
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this class represents a robot
|
* This class represents a robot
|
||||||
*/
|
*/
|
||||||
public class Robot {
|
public class Robot {
|
||||||
private int robotDamageTaken = 0;
|
private int robotDamageTaken = 0;
|
||||||
private final int playerId;
|
private final RobotID robotId;
|
||||||
private boolean inPowerDown = false;
|
private boolean inPowerDown = false;
|
||||||
private int lastFlagVisited = 0;
|
private int lastFlagVisited = 0;
|
||||||
private Position backupPosition;
|
private Position backupPosition;
|
||||||
@ -15,11 +16,11 @@ public class Robot {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new robot
|
* Instantiates a new robot
|
||||||
* @param playerId gives the robot a identifier that links it too the correct player
|
* @param robotId gives the robot a identifier that links it too the correct player
|
||||||
* @param spawnPosition gives the robot its starting position on the map
|
* @param spawnPosition gives the robot its starting position on the map
|
||||||
*/
|
*/
|
||||||
public Robot (int playerId, Position spawnPosition){
|
public Robot (RobotID robotId, Position spawnPosition) {
|
||||||
this.playerId=playerId;
|
this.robotId = robotId;
|
||||||
this.backupPosition = spawnPosition;
|
this.backupPosition = spawnPosition;
|
||||||
this.currentPosition = spawnPosition;
|
this.currentPosition = spawnPosition;
|
||||||
}
|
}
|
||||||
@ -33,7 +34,7 @@ public class Robot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the robot's damage too a given amount
|
* Sets the robot's 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 setDamage (int damage){
|
||||||
@ -91,8 +92,8 @@ public class Robot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the robots backup position
|
* Gets the robot's backup position
|
||||||
* @return robots backup position
|
* @return The robot's backup position
|
||||||
*/
|
*/
|
||||||
public Position getBackupPosition(){
|
public Position getBackupPosition(){
|
||||||
return backupPosition;
|
return backupPosition;
|
||||||
@ -102,8 +103,8 @@ public class Robot {
|
|||||||
* Gets the identifier of the players controlling the robot
|
* Gets the identifier of the players controlling the robot
|
||||||
* @return player identifier
|
* @return player identifier
|
||||||
*/
|
*/
|
||||||
public int getPlayerId(){
|
public RobotID getRobotId(){
|
||||||
return playerId;
|
return robotId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package inf112.fiasko.roborally.objects;
|
|||||||
import inf112.fiasko.roborally.element_properties.Position;
|
import inf112.fiasko.roborally.element_properties.Position;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ public class RobotTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp(){
|
public void setUp(){
|
||||||
robotPosition = new Position(3,6);
|
robotPosition = new Position(3,6);
|
||||||
testRobot = new Robot(6, robotPosition);
|
testRobot = new Robot(RobotID.ROBOT_6, robotPosition);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetDamageOnInitializedRobot(){
|
public void testRobotGetDamageOnInitializedRobot(){
|
||||||
@ -20,7 +21,7 @@ public class RobotTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetPlayerId(){
|
public void testRobotGetPlayerId(){
|
||||||
assertEquals(6, testRobot.getPlayerId());
|
assertEquals(RobotID.ROBOT_6, testRobot.getRobotId());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetBackupOnInitializedRobot(){
|
public void testRobotGetBackupOnInitializedRobot(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user