1
0
mirror of https://github.com/inf112-v20/Fiasko.git synced 2025-03-03 16:49:45 +01:00
This commit is contained in:
torlunjen 2020-04-21 16:08:22 +02:00
commit 88378588ad
7 changed files with 212 additions and 5 deletions
docs/team/referater
src
main/java/inf112/fiasko/roborally
test
java/inf112/fiasko/roborally/objects
resources/boards

@ -0,0 +1,12 @@
## Oppmøte
Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter
Ikke tilstede:
## Agenda
- Fortsette arbeidet med MVP
- Et gruppemedlem skal ha møte med foreleser, skal oppdatere gruppen på hva som blir avgjort her
## Møte
Vi starter å fortsette arbeidet vi holdt på me fra sist gang med en gang. Et gruppemedlem drar på møte me
foreleser og oppdaterer gruppen på hva som ble snakket om der.

@ -92,7 +92,13 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
@Override @Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (chosenCards.size() == maxCards) { if (chosenCards.size() == maxCards) {
roboRallyWrapper.roboRallyGame.setProgram(getCards()); List<ProgrammingCard> oldProgram = roboRallyWrapper.roboRallyGame.getProgram();
int lockedCardsInt = 5-maxCards;
List<ProgrammingCard> newProgram = getCards();
for(int i = 5; i>(5-lockedCardsInt);i--){
newProgram.add(oldProgram.get(i));
}
roboRallyWrapper.roboRallyGame.setProgram(newProgram);
roboRallyWrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN); roboRallyWrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper)); roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
return true; return true;

@ -43,13 +43,13 @@ class RoboRallyClientListener extends Listener {
wrapper.server != null, info.getPlayerName(), wrapper.server); wrapper.server != null, info.getPlayerName(), wrapper.server);
} else if (object instanceof ProgrammingCardDeck) { } else if (object instanceof ProgrammingCardDeck) {
if(((ProgrammingCardDeck) object).isEmpty()){ if(((ProgrammingCardDeck) object).isEmpty()){
wrapper.roboRallyGame.setProgram(new ArrayList<>());
if (wrapper.roboRallyGame.getRobotPowerdown()){ if (wrapper.roboRallyGame.getRobotPowerdown()){
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN); wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
} }
else { else {
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN); wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
} }
wrapper.roboRallyGame.setProgram(new ArrayList<>());
} }
else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);} else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);}
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start(); new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();

@ -4,7 +4,7 @@ package inf112.fiasko.roborally.networking.containers;
* This class represents a response saying that something went wrong with the request * This class represents a response saying that something went wrong with the request
*/ */
public class ErrorResponse { public class ErrorResponse {
private final String errorMessage; private String errorMessage;
private boolean critical; private boolean critical;
/** /**
@ -16,6 +16,9 @@ public class ErrorResponse {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
this.critical = false; this.critical = false;
} }
public ErrorResponse(){
}
/** /**
* Constructs a new error response * Constructs a new error response

@ -181,11 +181,10 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
removeNonLockedProgrammingCardsFromPlayers(); removeNonLockedProgrammingCardsFromPlayers();
} }
if (gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID())) { if (getPlayerFromName(this.playerName)!=null&& gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID())) {
setGameState(GameState.CHOOSING_STAY_IN_POWER_DOWN); setGameState(GameState.CHOOSING_STAY_IN_POWER_DOWN);
} else { } else {
setGameState(GameState.LOADING); setGameState(GameState.LOADING);
} }
} }

@ -1,6 +1,7 @@
package inf112.fiasko.roborally.objects; package inf112.fiasko.roborally.objects;
import inf112.fiasko.roborally.elementproperties.Action; import inf112.fiasko.roborally.elementproperties.Action;
import inf112.fiasko.roborally.elementproperties.Direction;
import inf112.fiasko.roborally.elementproperties.Position; import inf112.fiasko.roborally.elementproperties.Position;
import inf112.fiasko.roborally.elementproperties.RobotID; import inf112.fiasko.roborally.elementproperties.RobotID;
import inf112.fiasko.roborally.utility.BoardLoaderUtil; import inf112.fiasko.roborally.utility.BoardLoaderUtil;
@ -109,6 +110,159 @@ public class PhaseTest {
assertEquals(robot4.getRobotId(), board.getRobotOnPosition(new Position(3, 7))); assertEquals(robot4.getRobotId(), board.getRobotOnPosition(new Position(3, 7)));
} }
@Test
public void robotFiresLaserAndHitsAnotherRobot() throws InterruptedException {
FakeGame testGame = new FakeGame();
List<Robot> bot = new ArrayList<>();
List<Player> botPlayer = new ArrayList<>();
Position bot1Position = new Position(9, 12);
Position bot2Position = new Position(9, 13);
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
bot.add(bot1);
bot.add(bot2);
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
botPlayer.add(botPlayer1);
botPlayer.add(botPlayer2);
try {
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
assertEquals(0, bot2.getDamageTaken());
assertEquals(0, bot1.getDamageTaken());
testPhase.fireAllLasers();
assertEquals(0, bot2.getDamageTaken());
assertEquals(1, bot1.getDamageTaken());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void robotFiresLaserAndHitsAWallDoesNotDamageRobotOnOtherSide() throws InterruptedException {
FakeGame testGame = new FakeGame();
List<Robot> bot = new ArrayList<>();
List<Player> botPlayer = new ArrayList<>();
Position bot1Position = new Position(9, 11);
Position bot2Position = new Position(9, 13);
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
bot.add(bot1);
bot.add(bot2);
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
botPlayer.add(botPlayer1);
botPlayer.add(botPlayer2);
try {
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
assertEquals(0, bot2.getDamageTaken());
assertEquals(0, bot1.getDamageTaken());
testPhase.fireAllLasers();
assertEquals(0, bot2.getDamageTaken());
assertEquals(0, bot1.getDamageTaken());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void robotGetsHitBy2Lasers() throws InterruptedException {
FakeGame testGame = new FakeGame();
List<Robot> bot = new ArrayList<>();
List<Player> botPlayer = new ArrayList<>();
Position bot1Position = new Position(9, 12);
Position bot2Position = new Position(9, 13);
Position bot3Position = new Position(8, 12);
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
Robot bot3 = new Robot(RobotID.ROBOT_3, bot3Position);
bot.add(bot1);
bot.add(bot2);
bot.add(bot3);
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
Player botPlayer3 = new Player(RobotID.ROBOT_3, "Player 3");
botPlayer.add(botPlayer1);
botPlayer.add(botPlayer2);
botPlayer.add(botPlayer3);
bot3.setFacingDirection(Direction.EAST);
try {
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
assertEquals(0, bot1.getDamageTaken());
testPhase.fireAllLasers();
assertEquals(2, bot1.getDamageTaken());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void robotFiresLaserAndHitsARobotDoesNotDamageRobotOnOtherSide() throws InterruptedException {
FakeGame testGame = new FakeGame();
List<Robot> bot = new ArrayList<>();
List<Player> botPlayer = new ArrayList<>();
Position bot1Position = new Position(9, 12);
Position bot2Position = new Position(9, 13);
Position bot3Position = new Position(9, 14);
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
Robot bot3 = new Robot(RobotID.ROBOT_3, bot3Position);
bot.add(bot1);
bot.add(bot2);
bot.add(bot3);
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
Player botPlayer3 = new Player(RobotID.ROBOT_3, "Player 3");
botPlayer.add(botPlayer1);
botPlayer.add(botPlayer2);
botPlayer.add(botPlayer3);
try {
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
assertEquals(0, bot1.getDamageTaken());
testPhase.fireAllLasers();
assertEquals(1, bot1.getDamageTaken());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void robotGetsRotatedByCog() throws InterruptedException {
FakeGame testGame = new FakeGame();
List<Robot> bot = new ArrayList<>();
List<Player> botPlayer = new ArrayList<>();
Position bot1Position = new Position(0, 0);
Position bot2Position = new Position(1, 0);
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
bot.add(bot1);
bot.add(bot2);
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
botPlayer.add(botPlayer1);
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
botPlayer.add(botPlayer2);
try {
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
assertEquals(Direction.NORTH, bot1.getFacingDirection());
testPhase.rotateCogwheels();
assertEquals(Direction.EAST, bot1.getFacingDirection());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test @Test
public void programmingCardsGetsPlayedInOrder() throws InterruptedException { public void programmingCardsGetsPlayedInOrder() throws InterruptedException {
List<ProgrammingCard> testProgram1 = new ArrayList<>(); List<ProgrammingCard> testProgram1 = new ArrayList<>();

@ -0,0 +1,33 @@
12 16
03;1 04;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 21;7
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 01;1 02;1 01;1 05;3 01;1 05;7 01;1 05;7 11;5 01;1
01;1 11;1 05;3 01;1 05;3 01;1 02;1 01;1 05;7 01;1 11;5 01;1
01;1 11;1 01;1 05;3 01;1 22;7 01;1 05;7 01;1 05;7 11;5 01;1
01;1 11;1 05;3 01;1 05;3 01;1 22;7 01;1 02;1 01;1 11;5 01;1
01;1 11;1 01;1 05;3 01;1 02;1 01;1 05;7 01;1 05;7 11;5 01;1
01;1 11;1 05;3 18;1 05;3 01;1 05;7 01;1 05;7 01;1 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
21;7 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
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
29;1 27;1 01;1 25;1 01;1 23;1 24;1 01;1 26;1 01;1 28;1 30;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 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
0 1;3 0 0 0 0 0 0 0 0 1;7 0
1;7 0 0 0 0 0 0 0 0 0 0 1;3
0 1;3 0 0 0 0 0 0 0 0 1;7 0
0 1;3 0 0 0 0 0 0 0 0 1;7 0
1;7 0 0 0 0 0 0 0 0 0 0 1;3
0 1;3 0 0 0 0 0 0 0 0 1;7 0
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 1;5 0 1;5 0 0 1;5 0 1;5 0 0
0 0 1;1 0 1;1 0 0 1;1 0 1;1 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 1;7 0 1;7 0 1;7 1;7 1;7 0 1;7 0 1;7
0 0 1;5 0 1;5 0 0 1;5 0 1;5 0 0