mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' into player-and-zoom
This commit is contained in:
commit
620625f31f
@ -26,3 +26,42 @@
|
|||||||
#### Tile
|
#### Tile
|
||||||
*Brukerhistorie*
|
*Brukerhistorie*
|
||||||
* Som brett trenger jeg noe på meg som gir meg funksjonalitet
|
* Som brett trenger jeg noe på meg som gir meg funksjonalitet
|
||||||
|
|
||||||
|
#### Robot
|
||||||
|
*Krav*
|
||||||
|
* Må kunne dø
|
||||||
|
* Må kunne gjennopstå
|
||||||
|
* Må kunne ta skade
|
||||||
|
* Må peke i en gyldig retning
|
||||||
|
* Må bevege seg i pekende retning
|
||||||
|
|
||||||
|
|
||||||
|
*Brukerhistorie*
|
||||||
|
* Som robot må jeg kunne dytte en annen robot hvis det er lovlig å dytte roboten, for å kunne gjøre et gyldig trekk
|
||||||
|
* Som robot må jeg peke i en ortogonal retning for å ha en gyldig bevegelses retning
|
||||||
|
* Som robot må jeg kunne bevege meg i pekende retning, for å kunne gjøre et gyldig trekk
|
||||||
|
|
||||||
|
#### Vegg
|
||||||
|
*Krav*
|
||||||
|
* Må kunne stoppe en robot
|
||||||
|
|
||||||
|
*Brukerhistorie*
|
||||||
|
* Som vegg må jeg stoppe en robot fra å gå gjennom meg for hindre dem å gjøre et ugyldig trekk
|
||||||
|
* Som vegg må jeg kunne bli plassert i forskjellige retninger for å kunne bestemme den funksjonelle retningen til veggen
|
||||||
|
|
||||||
|
#### Brett
|
||||||
|
*Krav*
|
||||||
|
* Må kunne ha forskjellige tiles
|
||||||
|
|
||||||
|
*Brukerhistorie*
|
||||||
|
* Som brett må jeg kunne ha forskjellige tiles for å kunne vise alle aspektene av spillet
|
||||||
|
|
||||||
|
#### Hull
|
||||||
|
*Krav*
|
||||||
|
* Må kunne drepe en robot
|
||||||
|
|
||||||
|
#### Spiller
|
||||||
|
*Brukerhistorie*
|
||||||
|
* Som spiller må roboten min kunne gjennopstå om den har flere liv, for å kunne spille videre
|
||||||
|
* Som spiller må roboten min kunne dø, for å håntere om roboten tar for mye skade eller går i et hull/av kartet
|
||||||
|
* Som spiller må roboten min kunne ta skade, for å håntere påvirkning fra objekter som avgir skade til roboter
|
81
docs/team/referater/referat_25_02_2020.md
Normal file
81
docs/team/referater/referat_25_02_2020.md
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
## Oppmøte
|
||||||
|
Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter
|
||||||
|
Ikke tilstede:
|
||||||
|
|
||||||
|
## Agenda
|
||||||
|
- Planlegge brukerhistorier
|
||||||
|
|
||||||
|
|
||||||
|
## Møte
|
||||||
|
Det har blitt diskutert hvilke brukerhistorier det er vi trenger, og hvorfor. Hvilke krav de forskjellige brukerhistoriene har og hvordan vi kan løse dem.
|
||||||
|
Snakket om funksjonalitet på enkelte aspekter med spillet, og hvordad disse skal bli håndtert.
|
||||||
|
|
||||||
|
|
||||||
|
#### Idemyldring til krav/brukerhistorie:
|
||||||
|
- Stoppe robot fra å gå igjennom vegger
|
||||||
|
|
||||||
|
- Kunne gjør et gyldig trekk
|
||||||
|
|
||||||
|
- Kunne dytte en robot
|
||||||
|
|
||||||
|
- Vegger må ha forskjellige retningsorienteringer
|
||||||
|
|
||||||
|
- brett må kunne ha forskjellige tiles
|
||||||
|
|
||||||
|
- Robot må kunne gjennoppstå
|
||||||
|
|
||||||
|
- Robot må kunne ta skade
|
||||||
|
|
||||||
|
- Robot må kunne dø
|
||||||
|
|
||||||
|
- Hull må drepe robot
|
||||||
|
|
||||||
|
- Må kunne dytte en robot dersom det er gydig å dytte den
|
||||||
|
|
||||||
|
#### Brukerhistorie/notater
|
||||||
|
|
||||||
|
"Stoppe robot fra å gå gjennom vegg"
|
||||||
|
|
||||||
|
- Hvem: Vegg
|
||||||
|
|
||||||
|
- Hva: Stoppe robot fra å gå gjennom meg
|
||||||
|
|
||||||
|
- Hvorfor: For å hindre roboten i å gjøre et ugyldig trekk
|
||||||
|
|
||||||
|
"Kunne dytte en robot hvis det er lovlig å dytte den"
|
||||||
|
|
||||||
|
- Hvem: Robot
|
||||||
|
|
||||||
|
- Hvorfor: For å kunne gjøre gyldige trekk
|
||||||
|
|
||||||
|
"Vegger må kunne vøre i fordskjellige retninger"
|
||||||
|
|
||||||
|
- Hvem: Vegg
|
||||||
|
|
||||||
|
- Hva: Som vegg må jeg kunne bli plassert i forskjellige retninger
|
||||||
|
|
||||||
|
- Hvorfor: For å kunne bestemme den funksjonelle retningen til veggen
|
||||||
|
|
||||||
|
"Brett må kunne ha forskjellige tiles"
|
||||||
|
|
||||||
|
- Hvem: Brett
|
||||||
|
|
||||||
|
- Hva: Som brett må jeg kunne ha forskjellige tiles
|
||||||
|
|
||||||
|
- Hvorfor: For å kunne vise alle de forskjellige aspektene av spillets tiles.
|
||||||
|
|
||||||
|
"Robot må kunne gjennoppstå, dersom den har enda har flere liv"
|
||||||
|
|
||||||
|
- Hvem: Spiller
|
||||||
|
|
||||||
|
- Hva: Respawne roboten, dersom den ikke er tom for liv
|
||||||
|
|
||||||
|
- Hvorfor: Som spiller vil jeg at roboten min skal kunne gjennoppstå for å være i stand til å spille en runde til
|
||||||
|
|
||||||
|
"Robot må kunne ta skade"
|
||||||
|
|
||||||
|
- Hvem: Spiller
|
||||||
|
|
||||||
|
- Hva: Robot må kunne ta imot skade
|
||||||
|
|
||||||
|
- Hvorfor: For å håndtere andre objekters påvirkning på roboten
|
@ -42,8 +42,6 @@ public class GameLauncher extends ApplicationAdapter {
|
|||||||
camera.setToOrtho(false, game.getWidth() * tileDimensions,
|
camera.setToOrtho(false, game.getWidth() * tileDimensions,
|
||||||
game.getHeight() * tileDimensions);
|
game.getHeight() * tileDimensions);
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
/*MyTextInputListener listener = new MyTextInputListener();
|
|
||||||
Gdx.input.getTextInput(listener, "Input name", "", "Name");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,15 +84,4 @@ public class GameLauncher extends ApplicationAdapter {
|
|||||||
textureSheet.dispose();
|
textureSheet.dispose();
|
||||||
batch.dispose();
|
batch.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static class MyTextInputListener implements Input.TextInputListener {
|
|
||||||
@Override
|
|
||||||
public void input (String text) {
|
|
||||||
System.out.println(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void canceled () {
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
@ -8,8 +8,8 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
|
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
|
||||||
cfg.title = "Game Board";
|
cfg.title = "Game Board";
|
||||||
cfg.width = 768;
|
cfg.width = 900;
|
||||||
cfg.height = 769;
|
cfg.height = 900;
|
||||||
|
|
||||||
new LwjglApplication(new GameLauncher(), cfg);
|
new LwjglApplication(new GameLauncher(), cfg);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package inf112.fiasko.roborally.element_properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This enum represents an action on a programming card
|
|
||||||
*/
|
|
||||||
public enum Action {
|
|
||||||
ROTATE_RIGHT,
|
|
||||||
ROTATE_LEFT,
|
|
||||||
U_TURN,
|
|
||||||
MOVE_1,
|
|
||||||
MOVE_2,
|
|
||||||
MOVE_3,
|
|
||||||
BACK_UP
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package inf112.fiasko.roborally.game;
|
package inf112.fiasko.roborally.game;
|
||||||
|
|
||||||
import inf112.fiasko.roborally.element_properties.Direction;
|
|
||||||
import inf112.fiasko.roborally.element_properties.Position;
|
import inf112.fiasko.roborally.element_properties.Position;
|
||||||
import inf112.fiasko.roborally.element_properties.RobotID;
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||||
import inf112.fiasko.roborally.objects.Board;
|
import inf112.fiasko.roborally.objects.Board;
|
||||||
@ -30,7 +29,7 @@ public class Game implements IDrawableGame {
|
|||||||
try {
|
try {
|
||||||
runGameLoop();
|
runGameLoop();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -43,29 +42,49 @@ public class Game implements IDrawableGame {
|
|||||||
* @throws InterruptedException If interrupted while trying to sleep
|
* @throws InterruptedException If interrupted while trying to sleep
|
||||||
*/
|
*/
|
||||||
private void runGameLoop() throws InterruptedException {
|
private void runGameLoop() throws InterruptedException {
|
||||||
|
long cycleDelay = 600;
|
||||||
TimeUnit.SECONDS.sleep(3);
|
TimeUnit.SECONDS.sleep(3);
|
||||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.SOUTH);
|
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.rotateRobotLeft(RobotID.ROBOT_1);
|
gameBoard.rotateRobotLeft(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.EAST);
|
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.EAST);
|
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_1, Direction.SOUTH);
|
gameBoard.moveRobotForward(RobotID.ROBOT_1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.WEST);
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobot(RobotID.ROBOT_2, Direction.EAST);
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.rotateRobotRight(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,6 @@ public class Board {
|
|||||||
private IGrid<Wall> walls;
|
private IGrid<Wall> walls;
|
||||||
private IGrid<Tile> tiles;
|
private IGrid<Tile> tiles;
|
||||||
private Map<RobotID, Robot> robots;
|
private Map<RobotID, Robot> robots;
|
||||||
private List<Robot> deadRobots;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the board
|
* Initializes the board
|
||||||
@ -38,7 +37,6 @@ public class Board {
|
|||||||
}
|
}
|
||||||
this.robots.put(robot.getRobotId(), robot);
|
this.robots.put(robot.getRobotId(), robot);
|
||||||
}
|
}
|
||||||
this.deadRobots = new ArrayList<>();
|
|
||||||
this.boardWidth = tiles.getWidth();
|
this.boardWidth = tiles.getWidth();
|
||||||
this.boardHeight = tiles.getHeight();
|
this.boardHeight = tiles.getHeight();
|
||||||
this.walls = walls;
|
this.walls = walls;
|
||||||
@ -61,18 +59,6 @@ public class Board {
|
|||||||
return boardWidth;
|
return boardWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves all dead robots to their backups and makes them part of the board again
|
|
||||||
*/
|
|
||||||
public void respawnRobots() {
|
|
||||||
//TODO: Account for several robots re-spawning at same backup
|
|
||||||
for (Robot robot : deadRobots) {
|
|
||||||
robot.setPosition(robot.getBackupPosition());
|
|
||||||
robots.put(robot.getRobotId(), robot);
|
|
||||||
}
|
|
||||||
deadRobots = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all alive robots from the board
|
* Gets all alive robots from the board
|
||||||
* @return A list of alive robots
|
* @return A list of alive robots
|
||||||
@ -103,7 +89,6 @@ public class Board {
|
|||||||
*/
|
*/
|
||||||
public void removeDeadRobotFromBoard(Robot robot) {
|
public void removeDeadRobotFromBoard(Robot robot) {
|
||||||
robots.remove(robot.getRobotId());
|
robots.remove(robot.getRobotId());
|
||||||
deadRobots.add(robot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,6 +111,14 @@ public class Board {
|
|||||||
robot.setFacingDirection(newDirection);
|
robot.setFacingDirection(newDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves a robot one unit forward according to the direction it's currently facing
|
||||||
|
* @param robotID The robot to move
|
||||||
|
*/
|
||||||
|
public void moveRobotForward(RobotID robotID) {
|
||||||
|
moveRobot(robotID, robots.get(robotID).getFacingDirection());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves a robot one unit in a specified direction
|
* Moves a robot one unit in a specified direction
|
||||||
* @param robotID ID of the robot to move
|
* @param robotID ID of the robot to move
|
||||||
@ -212,7 +205,7 @@ public class Board {
|
|||||||
* @param robot The robot to kill
|
* @param robot The robot to kill
|
||||||
*/
|
*/
|
||||||
private void killRobot(Robot robot) {
|
private void killRobot(Robot robot) {
|
||||||
//TODO: Must remove a life from the robot/player
|
robot.setAmountOfLives(robot.getAmountOfLives() - 1);
|
||||||
removeDeadRobotFromBoard(robot);
|
removeDeadRobotFromBoard(robot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package inf112.fiasko.roborally.objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This Interface describes a card without a card suit
|
|
||||||
* @param <S> The value type
|
|
||||||
* @param <T> The symbol type
|
|
||||||
*/
|
|
||||||
public interface ICardWithoutSuit<S,T> {
|
|
||||||
/**
|
|
||||||
* Gets the value of the card
|
|
||||||
* @return The card value
|
|
||||||
*/
|
|
||||||
S getValue();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the symbol of the card
|
|
||||||
* @return The card symbol
|
|
||||||
*/
|
|
||||||
T getSymbol();
|
|
||||||
}
|
|
@ -8,6 +8,7 @@ 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 amountOfLives = 3;
|
||||||
private int robotDamageTaken = 0;
|
private int robotDamageTaken = 0;
|
||||||
private final RobotID robotId;
|
private final RobotID robotId;
|
||||||
private boolean inPowerDown = false;
|
private boolean inPowerDown = false;
|
||||||
@ -18,8 +19,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 +31,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 +106,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;
|
||||||
@ -128,4 +131,18 @@ public class Robot {
|
|||||||
}
|
}
|
||||||
this.facingDirection = newFacingDirection;
|
this.facingDirection = newFacingDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount if life the robot has left
|
||||||
|
* @param amountOfLives the new amount if lives the robot has left
|
||||||
|
*/
|
||||||
|
public void setAmountOfLives(int amountOfLives) {
|
||||||
|
this.amountOfLives = amountOfLives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of life a robot has left.
|
||||||
|
* @return amount of life left
|
||||||
|
*/
|
||||||
|
public int getAmountOfLives() { return this.amountOfLives; }
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import inf112.fiasko.roborally.objects.Wall;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class IOUtil {
|
public final class IOUtil {
|
||||||
private IOUtil() {}
|
private IOUtil() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ public class IOUtil {
|
|||||||
Direction direction;
|
Direction direction;
|
||||||
if (element.getClass().isAssignableFrom(Robot.class)) {
|
if (element.getClass().isAssignableFrom(Robot.class)) {
|
||||||
Robot robot = (Robot) element;
|
Robot robot = (Robot) element;
|
||||||
hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(robot);
|
hasRotatedTexture = false;
|
||||||
direction = robot.getFacingDirection();
|
direction = robot.getFacingDirection();
|
||||||
} else if (element.getClass().isAssignableFrom(Tile.class)) {
|
} else if (element.getClass().isAssignableFrom(Tile.class)) {
|
||||||
Tile tile = (Tile) element;
|
Tile tile = (Tile) element;
|
||||||
@ -116,7 +116,7 @@ public class IOUtil {
|
|||||||
direction = tile.getDirection();
|
direction = tile.getDirection();
|
||||||
} else if (element.getClass().isAssignableFrom(Wall.class)) {
|
} else if (element.getClass().isAssignableFrom(Wall.class)) {
|
||||||
Wall wall = (Wall) element;
|
Wall wall = (Wall) element;
|
||||||
hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(wall);
|
hasRotatedTexture = true;
|
||||||
direction = wall.getDirection();
|
direction = wall.getDirection();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown element type passed to function.");
|
throw new IllegalArgumentException("Unknown element type passed to function.");
|
||||||
|
@ -2,7 +2,7 @@ package inf112.fiasko.roborally.utility;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class ResourceUtil {
|
public final class ResourceUtil {
|
||||||
private ResourceUtil() {}
|
private ResourceUtil() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,24 +110,6 @@ public final class TextureConverterUtil {
|
|||||||
return tileSheetTileHasRotatedTextureMappings.get(tile.getTileType());
|
return tileSheetTileHasRotatedTextureMappings.get(tile.getTileType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether a wall has textures for different rotations
|
|
||||||
* @param wall The wall to check
|
|
||||||
* @return True if rotated versions of the texture exists. False otherwise
|
|
||||||
*/
|
|
||||||
public static boolean hasRotatedTexture(Wall wall) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether a robot has textures for different rotations
|
|
||||||
* @param robot The robot to check
|
|
||||||
* @return True if rotated versions of the texture exists. False otherwise
|
|
||||||
*/
|
|
||||||
public static boolean hasRotatedTexture(Robot robot) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads mappings between a tile and texture
|
* Loads mappings between a tile and texture
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
12 13
|
12 12
|
||||||
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 21;1
|
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 21;1
|
||||||
01;1 12;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 12;5 01;1
|
01;1 12;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 12;5 01;1
|
||||||
01;1 11;1 05;3 01;1 05;3 01;1 05;7 17;1 05;7 01;1 11;5 01;1
|
01;1 11;1 05;3 01;1 05;3 01;1 05;7 17;1 05;7 01;1 11;5 01;1
|
||||||
@ -11,7 +11,6 @@
|
|||||||
01;1 11;1 01;1 05;3 01;1 05;3 01;1 05;7 01;1 05;7 11;5 01;1
|
01;1 11;1 01;1 05;3 01;1 05;3 01;1 05;7 01;1 05;7 11;5 01;1
|
||||||
01;1 12;1 11;7 11;7 11;7 11;7 11;7 11;7 11;7 11;7 12;7 01;1
|
01;1 12;1 11;7 11;7 11;7 11;7 11;7 11;7 11;7 11;7 12;7 01;1
|
||||||
21;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
21;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
||||||
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
|
||||||
0 0 1;1 0 1;1 0 0 1;1 0 1;1 0 0
|
0 0 1;1 0 1;1 0 0 1;1 0 1;1 0 0
|
||||||
0 0 0 1;5 0 1;5 1;5 0 1;5 0 0 0
|
0 0 0 1;5 0 1;5 1;5 0 1;5 0 0 0
|
||||||
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
@ -24,4 +23,3 @@
|
|||||||
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
0 0 0 1;1 0 1;1 1;1 0 1;1 0 0 0
|
0 0 0 1;1 0 1;1 1;1 0 1;1 0 0 0
|
||||||
0 0 1;5 0 1;5 0 0 1;5 0 1;5 0 0
|
0 0 1;5 0 1;5 0 0 1;5 0 1;5 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 0
|
|
@ -13,12 +13,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BoardTest {
|
public class BoardTest {
|
||||||
private Grid<Tile> tileGrid;
|
private Grid<Tile> tileGrid;
|
||||||
private Grid<Wall> wallGrid;
|
private Grid<Wall> wallGrid;
|
||||||
private Position someValidPosition;
|
private Position someValidPosition1;
|
||||||
|
private Position someValidPosition5;
|
||||||
|
private Position someValidPosition6;
|
||||||
|
private Position someValidPosition7;
|
||||||
private List<Robot> robotList;
|
private List<Robot> robotList;
|
||||||
private Board board;
|
private Board board;
|
||||||
|
|
||||||
@ -26,16 +30,38 @@ public class BoardTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
tileGrid = new Grid<>(5, 5, new Tile(TileType.TILE, Direction.NORTH));
|
tileGrid = new Grid<>(5, 5, new Tile(TileType.TILE, Direction.NORTH));
|
||||||
wallGrid = new Grid<>(5, 5);
|
wallGrid = new Grid<>(5, 5);
|
||||||
someValidPosition = new Position(2, 2);
|
someValidPosition1 = new Position(2, 2);
|
||||||
|
Position someValidPosition2 = new Position(2, 1);
|
||||||
|
Position someValidPosition3 = new Position(2, 3);
|
||||||
|
Position someValidPosition4 = new Position(2, 4);
|
||||||
|
someValidPosition5 = new Position(3, 1);
|
||||||
|
someValidPosition6 = new Position(3, 2);
|
||||||
|
someValidPosition7 = new Position(3, 3);
|
||||||
|
Position someValidPosition8 = new Position(3, 4);
|
||||||
robotList = new ArrayList<>();
|
robotList = new ArrayList<>();
|
||||||
robotList.add(new Robot(RobotID.ROBOT_1, someValidPosition));
|
robotList.add(new Robot(RobotID.ROBOT_1, someValidPosition1));
|
||||||
robotList.add(new Robot(RobotID.ROBOT_2, someValidPosition));
|
robotList.add(new Robot(RobotID.ROBOT_2, someValidPosition2));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_3, someValidPosition3));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_4, someValidPosition4));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_5, someValidPosition5));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_6, someValidPosition6));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_7, someValidPosition7));
|
||||||
|
robotList.add(new Robot(RobotID.ROBOT_8, someValidPosition8));
|
||||||
wallGrid.setElement(2, 1, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
wallGrid.setElement(2, 1, new Wall(WallType.WALL_NORMAL, Direction.SOUTH));
|
||||||
wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST));
|
wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST));
|
||||||
wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST));
|
wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST));
|
||||||
board = new Board(tileGrid, wallGrid, robotList);
|
board = new Board(tileGrid, wallGrid, robotList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotCanPushRobots() {
|
||||||
|
board.moveRobot(RobotID.ROBOT_5, Direction.SOUTH);
|
||||||
|
assertNotEquals(someValidPosition5, robotList.get(4).getPosition());
|
||||||
|
assertNotEquals(someValidPosition6, robotList.get(5).getPosition());
|
||||||
|
assertNotEquals(someValidPosition7, robotList.get(6).getPosition());
|
||||||
|
assertFalse(board.getAliveRobots().contains(robotList.get(7)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotCanMove() {
|
public void robotCanMove() {
|
||||||
assertTrue(board.moveRobot(RobotID.ROBOT_1, Direction.SOUTH));
|
assertTrue(board.moveRobot(RobotID.ROBOT_1, Direction.SOUTH));
|
||||||
@ -71,15 +97,15 @@ public class BoardTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotCanBeRotatedRight() {
|
public void robotCanBeRotatedRight() {
|
||||||
assertEquals(Direction.NORTH, robotList.get(1).getFacingDirection());
|
assertEquals(Direction.NORTH, robotList.get(0).getFacingDirection());
|
||||||
board.rotateRobotRight(RobotID.ROBOT_2);
|
board.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
assertEquals(Direction.EAST, robotList.get(1).getFacingDirection());
|
assertEquals(Direction.EAST, robotList.get(0).getFacingDirection());
|
||||||
board.rotateRobotRight(RobotID.ROBOT_2);
|
board.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
assertEquals(Direction.SOUTH, robotList.get(1).getFacingDirection());
|
assertEquals(Direction.SOUTH, robotList.get(0).getFacingDirection());
|
||||||
board.rotateRobotRight(RobotID.ROBOT_2);
|
board.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
assertEquals(Direction.WEST, robotList.get(1).getFacingDirection());
|
assertEquals(Direction.WEST, robotList.get(0).getFacingDirection());
|
||||||
board.rotateRobotRight(RobotID.ROBOT_2);
|
board.rotateRobotRight(RobotID.ROBOT_1);
|
||||||
assertEquals(Direction.NORTH, robotList.get(1).getFacingDirection());
|
assertEquals(Direction.NORTH, robotList.get(0).getFacingDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (expected = IllegalArgumentException.class)
|
@Test (expected = IllegalArgumentException.class)
|
||||||
@ -90,8 +116,17 @@ public class BoardTest {
|
|||||||
|
|
||||||
@Test (expected = IllegalArgumentException.class)
|
@Test (expected = IllegalArgumentException.class)
|
||||||
public void multipleRobotsWithSameIDThrowsError() {
|
public void multipleRobotsWithSameIDThrowsError() {
|
||||||
Robot robot = new Robot(RobotID.ROBOT_1, someValidPosition);
|
Robot robot = new Robot(RobotID.ROBOT_1, someValidPosition1);
|
||||||
robotList.add(robot);
|
robotList.add(robot);
|
||||||
new Board(tileGrid, wallGrid, robotList);
|
new Board(tileGrid, wallGrid, robotList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void killRobotReducesAmountOfLivesByOne() {
|
||||||
|
Robot robot = board.getAliveRobots().get(1);
|
||||||
|
assertEquals(3, robot.getAmountOfLives());
|
||||||
|
robot.setPosition(new Position(0, 0));
|
||||||
|
board.moveRobot(robot.getRobotId(), Direction.NORTH);
|
||||||
|
assertEquals(2, robot.getAmountOfLives());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,61 +10,69 @@ import org.junit.Test;
|
|||||||
public class RobotTest {
|
public class RobotTest {
|
||||||
private Position robotPosition;
|
private Position robotPosition;
|
||||||
private Robot testRobot;
|
private Robot testRobot;
|
||||||
|
private final int nextFlag = 1;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
robotPosition = new Position(3,6);
|
robotPosition = new Position(3,6);
|
||||||
testRobot = new Robot(RobotID.ROBOT_6, robotPosition);
|
testRobot = new Robot(RobotID.ROBOT_6, robotPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetDamageOnInitializedRobot(){
|
public void testRobotGetDamageOnInitializedRobot(){
|
||||||
assertEquals(0, testRobot.getDamage());
|
assertEquals(0, testRobot.getDamageTaken());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetPlayerId(){
|
public void testRobotGetPlayerId(){
|
||||||
assertEquals(RobotID.ROBOT_6, testRobot.getRobotId());
|
assertEquals(RobotID.ROBOT_6, testRobot.getRobotId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetBackupOnInitializedRobot(){
|
public void testRobotGetBackupOnInitializedRobot(){
|
||||||
assertEquals(robotPosition, testRobot.getBackupPosition());
|
assertEquals(robotPosition, testRobot.getBackupPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotSetDamage() {
|
public void testRobotSetDamage() {
|
||||||
testRobot.setDamage(2);
|
testRobot.setDamageTaken(2);
|
||||||
assertEquals(2, testRobot.getDamage());
|
assertEquals(2, testRobot.getDamageTaken());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetPositionOnInitializedRobot(){
|
public void testRobotGetPositionOnInitializedRobot(){
|
||||||
assertEquals(robotPosition, testRobot.getPosition());
|
assertEquals(robotPosition, testRobot.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetPositionOnRobotWithNewPosition() {
|
public void testRobotGetPositionOnRobotWithNewPosition() {
|
||||||
Position newRobotPosition = new Position(8,12);
|
Position newRobotPosition = new Position(8,12);
|
||||||
testRobot.setPosition(newRobotPosition);
|
testRobot.setPosition(newRobotPosition);
|
||||||
assertEquals(newRobotPosition, testRobot.getPosition());
|
assertEquals(newRobotPosition, testRobot.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotIsInPowerDownOnInitializedRobot(){
|
public void testRobotIsInPowerDownOnInitializedRobot(){
|
||||||
assertEquals(false, testRobot.isInPowerDown());
|
assertEquals(false, testRobot.isInPowerDown());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotSetPowerDown() {
|
public void testRobotSetPowerDown() {
|
||||||
testRobot.setPowerDown(true);
|
testRobot.setPowerDown(true);
|
||||||
assertEquals(true, testRobot.isInPowerDown());
|
assertEquals(true, testRobot.isInPowerDown());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetNewFlag() {
|
public void testRobotGetNewFlag() {
|
||||||
int nextFlag = 2;
|
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag);
|
||||||
Position nextFlagPosition = new Position(3,4);
|
assertEquals(1, testRobot.getLastFlagVisited());
|
||||||
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
|
|
||||||
assertEquals(2, testRobot.getLastFlagVisited());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRobotGetNewBackup() {
|
public void testRobotGetNewBackup() {
|
||||||
int nextFlag = 2;
|
|
||||||
Position nextFlagPosition = new Position(3,4);
|
Position nextFlagPosition = new Position(3,4);
|
||||||
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
|
testRobot.setPosition(nextFlagPosition);
|
||||||
|
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag);
|
||||||
assertEquals(nextFlagPosition, testRobot.getBackupPosition());
|
assertEquals(nextFlagPosition, testRobot.getBackupPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user