mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
ccc5f3af17
10
docs/team/referater/referat_27_02_2020_nr2.md
Normal file
10
docs/team/referater/referat_27_02_2020_nr2.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
## Oppmøte
|
||||||
|
Tilstede: Steinar, Gabriel, Kristian, Petter
|
||||||
|
Ikke tilstede: Torbjørn
|
||||||
|
|
||||||
|
## Agenda
|
||||||
|
- Gjøre ferdig innlevering til oblig 2
|
||||||
|
|
||||||
|
|
||||||
|
## Møte
|
||||||
|
Retting og omformulering av oppgavesvar.
|
@ -37,6 +37,31 @@ public class Game implements IDrawableGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return gameBoard.getBoardWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return gameBoard.getBoardHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Tile> getTilesToDraw() {
|
||||||
|
return gameBoard.getTiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Wall> getWallsToDraw() {
|
||||||
|
return gameBoard.getWalls();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Robot> getRobotsToDraw() {
|
||||||
|
return gameBoard.getAliveRobots();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does whatever the game wants to do
|
* Does whatever the game wants to do
|
||||||
* @throws InterruptedException If interrupted while trying to sleep
|
* @throws InterruptedException If interrupted while trying to sleep
|
||||||
@ -86,29 +111,4 @@ public class Game implements IDrawableGame {
|
|||||||
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
TimeUnit.MILLISECONDS.sleep(cycleDelay);
|
||||||
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
gameBoard.moveRobotForward(RobotID.ROBOT_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWidth() {
|
|
||||||
return gameBoard.getBoardWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return gameBoard.getBoardHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Tile> getTilesToDraw() {
|
|
||||||
return gameBoard.getTiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Wall> getWallsToDraw() {
|
|
||||||
return gameBoard.getWalls();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Robot> getRobotsToDraw() {
|
|
||||||
return gameBoard.getAliveRobots();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,30 @@ public class Board {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves all dead robots to their backups and makes them part of the board again, and if a robot has no lives
|
||||||
|
* it will be removed from the game.
|
||||||
|
*/
|
||||||
|
public void respawnRobots() {
|
||||||
|
for (Robot robot : deadRobots) {
|
||||||
|
if (robot.getAmountOfLives() > 0) {
|
||||||
|
robot.setPosition(robot.getBackupPosition());
|
||||||
|
robot.setFacingDirection(Direction.NORTH);
|
||||||
|
robots.put(robot.getRobotId(), robot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deadRobots = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a specific robot is currently alive on the board
|
||||||
|
* @param robot the ID of the robot you want to check
|
||||||
|
* @return True/False based on if the robot was found.
|
||||||
|
*/
|
||||||
|
public boolean isRobotAlive(RobotID robot) {
|
||||||
|
return robots.containsKey(robot);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a potential robot move would be blocked by a wall
|
* Checks if a potential robot move would be blocked by a wall
|
||||||
* @param robotPosition The current position of the robot
|
* @param robotPosition The current position of the robot
|
||||||
@ -284,26 +308,4 @@ public class Board {
|
|||||||
}
|
}
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves all dead robots to their backups and makes them part of the board again, and if a robot has no lives
|
|
||||||
* it will be removed from the game.
|
|
||||||
*/
|
|
||||||
public void respawnRobots() {
|
|
||||||
for (Robot robot : deadRobots) {
|
|
||||||
if (robot.getAmountOfLives() > 0) {
|
|
||||||
robot.setPosition(robot.getBackupPosition());
|
|
||||||
robot.setFacingDirection(Direction.NORTH);
|
|
||||||
robots.put(robot.getRobotId(), robot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deadRobots = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific robot is currently alive on the board
|
|
||||||
* @param robot the ID of the robot you want to check
|
|
||||||
* @return True/False based on if the robot was found.
|
|
||||||
*/
|
|
||||||
public boolean isRobotAlive(RobotID robot) { return robots.containsKey(robot); }
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user