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
a886b5e23d
10
docs/team/referater/referat_20_04_2020.md
Normal file
10
docs/team/referater/referat_20_04_2020.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
## Oppmøte
|
||||||
|
Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter
|
||||||
|
Ikke tilstede:
|
||||||
|
|
||||||
|
## Agenda
|
||||||
|
- Fortsette arbeidet med MVP
|
||||||
|
|
||||||
|
## Møte
|
||||||
|
Vi starter med å diskutere noen bugs som vi har funnet, og hvordan vi skal håndtere dem.
|
||||||
|
Går deretter videre til å jobbe i grupper med å reparere disse bugsene samt fortsette på MVP.
|
@ -444,6 +444,7 @@ public class Board {
|
|||||||
int flagNr = flagID.getTileTypeID() % 16;
|
int flagNr = flagID.getTileTypeID() % 16;
|
||||||
if (flagNr - 1 == robot.getLastFlagVisited()) {
|
if (flagNr - 1 == robot.getLastFlagVisited()) {
|
||||||
robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr);
|
robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr);
|
||||||
|
setHasTouchedFlagThisTurnFromRobotID(robotID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ public class Phase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gameBoard.updateFlagOnRobot(robotID, flag.getElement().getTileType());
|
gameBoard.updateFlagOnRobot(robotID, flag.getElement().getTileType());
|
||||||
gameBoard.setHasTouchedFlagThisTurnFromRobotID(robotID, true);
|
|
||||||
checkIfPlayerWon(robotID, flags.size());
|
checkIfPlayerWon(robotID, flags.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ public class BoardTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void flagDoesNotUpdatedOnRobotWithWringLastVisitedFlag() {
|
public void flagDoesNotUpdatedOnRobotWithWrongLastVisitedFlag() {
|
||||||
Robot testRobot = robotList.get(6);
|
Robot testRobot = robotList.get(6);
|
||||||
assertEquals(0, testRobot.getLastFlagVisited());
|
assertEquals(0, testRobot.getLastFlagVisited());
|
||||||
board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_2);
|
board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_2);
|
||||||
|
66
src/test/java/inf112/fiasko/roborally/objects/FakeGame.java
Normal file
66
src/test/java/inf112/fiasko/roborally/objects/FakeGame.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package inf112.fiasko.roborally.objects;
|
||||||
|
|
||||||
|
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||||
|
import inf112.fiasko.roborally.networking.containers.PowerDownContainer;
|
||||||
|
import inf112.fiasko.roborally.networking.containers.ProgamsContainer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FakeGame implements InteractableGame {
|
||||||
|
private String winningPlayerName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameState getGameState() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGameState(GameState gameState) {
|
||||||
|
//Not needed for testing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWinningPlayerName() {
|
||||||
|
return winningPlayerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveAllPrograms(ProgamsContainer programs) throws InterruptedException {
|
||||||
|
//Not needed for testing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveStayInPowerDown(PowerDownContainer powerDowns) {
|
||||||
|
//Not needed for testing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProgrammingCardDeck getPlayerHand() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlayerHand(ProgrammingCardDeck playerHand) {
|
||||||
|
//Not needed for testing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProgramSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProgrammingCard> getProgram() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgram(List<ProgrammingCard> program) {
|
||||||
|
//Not needed for testing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWinningPlayerName(String winningPlayerName) {
|
||||||
|
this.winningPlayerName = winningPlayerName;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package inf112.fiasko.roborally.objects;
|
package inf112.fiasko.roborally.objects;
|
||||||
|
|
||||||
|
import inf112.fiasko.roborally.elementproperties.Action;
|
||||||
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;
|
||||||
@ -10,22 +11,48 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.*;
|
||||||
|
|
||||||
public class PhaseTest {
|
public class PhaseTest {
|
||||||
private Phase phase;
|
private Phase phase;
|
||||||
private Board board;
|
private Board board;
|
||||||
private Position robot1Position;
|
private Position robot1Position = new Position(2, 2);
|
||||||
|
private Position robot2Position = new Position(3, 2);
|
||||||
|
private Position robot3Position = new Position(7 , 2);
|
||||||
|
private Position robot4Position = new Position(3 , 8);
|
||||||
|
private Position robot5Position = new Position(2 , 14);
|
||||||
|
private Position robot6Position = new Position(2 , 15);
|
||||||
|
private Robot robot1 = new Robot(RobotID.ROBOT_1, robot1Position);
|
||||||
|
private Robot robot2 = new Robot(RobotID.ROBOT_2, robot2Position);
|
||||||
|
private Robot robot3 = new Robot(RobotID.ROBOT_3, robot3Position);
|
||||||
|
private Robot robot4 = new Robot(RobotID.ROBOT_4, robot4Position);
|
||||||
|
private Robot robot5 = new Robot(RobotID.ROBOT_5, robot5Position);
|
||||||
|
private Robot robot6 = new Robot(RobotID.ROBOT_6, robot6Position);
|
||||||
|
private Player player1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
private Player player2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
private Player player3 = new Player(RobotID.ROBOT_3, "Player 3");
|
||||||
|
private Player player4 = new Player(RobotID.ROBOT_4, "Player 4");
|
||||||
|
private Player player5 = new Player(RobotID.ROBOT_5, "Player 5");
|
||||||
|
private Player player6 = new Player(RobotID.ROBOT_6, "Player 6");
|
||||||
|
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
List<Robot> robots = new ArrayList<>();
|
robots.add(robot1);
|
||||||
robot1Position = new Position(2, 2);
|
robots.add(robot2);
|
||||||
robots.add(new Robot(RobotID.ROBOT_1, robot1Position));
|
robots.add(robot3);
|
||||||
robots.add(new Robot(RobotID.ROBOT_2, new Position(3, 2)));
|
robots.add(robot4);
|
||||||
|
robots.add(robot5);
|
||||||
|
robots.add(robot6);
|
||||||
|
|
||||||
List<Player> playerList = new ArrayList<>();
|
List<Player> playerList = new ArrayList<>();
|
||||||
playerList.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
playerList.add(player1);
|
||||||
playerList.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
playerList.add(player2);
|
||||||
|
playerList.add(player3);
|
||||||
|
playerList.add(player4);
|
||||||
|
playerList.add(player5);
|
||||||
|
playerList.add(player6);
|
||||||
try {
|
try {
|
||||||
board = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
|
board = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
|
||||||
this.phase = new Phase(board, playerList, 0, null);
|
this.phase = new Phase(board, playerList, 0, null);
|
||||||
@ -39,4 +66,95 @@ public class PhaseTest {
|
|||||||
phase.moveAllConveyorBelts();
|
phase.moveAllConveyorBelts();
|
||||||
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(robot1Position));
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(robot1Position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void playerWinsAfterTouchingAllFlagsInCorrectOrder() {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> robot = new ArrayList<>();
|
||||||
|
List<Player> player = new ArrayList<>();
|
||||||
|
robot.add(new Robot(RobotID.ROBOT_1, new Position(0,0)));
|
||||||
|
player.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/win_test_board.txt", robot);
|
||||||
|
Phase testPhase = new Phase(board, player, 0, testGame);
|
||||||
|
testPhase.checkAllFlags();
|
||||||
|
assertEquals("Player 1", testGame.getWinningPlayerName());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotRegistersFlagWhenOnCorrectOne() {
|
||||||
|
assertEquals(robot3.getLastFlagVisited(), 0);
|
||||||
|
assertFalse(robot3.hasTouchedFlagThisTurn());
|
||||||
|
phase.checkAllFlags();
|
||||||
|
assertEquals(robot3.getLastFlagVisited(), 1);
|
||||||
|
assertTrue(robot3.hasTouchedFlagThisTurn());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotDoesNotRegistersWrongFlag() {
|
||||||
|
assertEquals(robot4.getLastFlagVisited(), 0);
|
||||||
|
assertFalse(robot4.hasTouchedFlagThisTurn());
|
||||||
|
phase.checkAllFlags();
|
||||||
|
assertEquals(robot4.getLastFlagVisited(), 0);
|
||||||
|
assertFalse(robot4.hasTouchedFlagThisTurn());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void actionDoesPerformAnAction() throws InterruptedException {
|
||||||
|
assertEquals(robot4.getRobotId(), board.getRobotOnPosition(robot4Position));
|
||||||
|
phase.makeMove(RobotID.ROBOT_4, Action.MOVE_1);
|
||||||
|
assertEquals(robot4.getRobotId(),board.getRobotOnPosition(new Position(3, 7)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void programmingCardsGetsPlayedInOrder() throws InterruptedException {
|
||||||
|
List<ProgrammingCard> testProgram1 = new ArrayList<>();
|
||||||
|
List<ProgrammingCard> testProgram2 = new ArrayList<>();
|
||||||
|
List<ProgrammingCard> testProgram3 = new ArrayList<>();
|
||||||
|
ProgrammingCard card1 = new ProgrammingCard(1, Action.MOVE_1);
|
||||||
|
ProgrammingCard card2 = new ProgrammingCard(2, Action.ROTATE_RIGHT);
|
||||||
|
ProgrammingCard card3 = new ProgrammingCard(3, Action.MOVE_1);
|
||||||
|
ProgrammingCard card4 = new ProgrammingCard(4, Action.MOVE_1);
|
||||||
|
ProgrammingCard card5 = new ProgrammingCard(5, Action.MOVE_1);
|
||||||
|
ProgrammingCard card6 = new ProgrammingCard(10, Action.MOVE_1);
|
||||||
|
ProgrammingCard card7 = new ProgrammingCard(11, Action.ROTATE_RIGHT);
|
||||||
|
ProgrammingCard card8 = new ProgrammingCard(12, Action.MOVE_1);
|
||||||
|
ProgrammingCard card9 = new ProgrammingCard(13, Action.MOVE_1);
|
||||||
|
ProgrammingCard card10 = new ProgrammingCard(14, Action.MOVE_1);
|
||||||
|
ProgrammingCard card11 = new ProgrammingCard(100, Action.ROTATE_LEFT);
|
||||||
|
ProgrammingCard card12= new ProgrammingCard(200, Action.ROTATE_LEFT);
|
||||||
|
ProgrammingCard card13 = new ProgrammingCard(300, Action.ROTATE_LEFT);
|
||||||
|
ProgrammingCard card14 = new ProgrammingCard(400, Action.ROTATE_LEFT);
|
||||||
|
ProgrammingCard card15 = new ProgrammingCard(500, Action.ROTATE_LEFT);
|
||||||
|
testProgram1.add(card1);
|
||||||
|
testProgram1.add(card2);
|
||||||
|
testProgram1.add(card3);
|
||||||
|
testProgram1.add(card4);
|
||||||
|
testProgram1.add(card5);
|
||||||
|
testProgram2.add(card6);
|
||||||
|
testProgram2.add(card7);
|
||||||
|
testProgram2.add(card8);
|
||||||
|
testProgram2.add(card9);
|
||||||
|
testProgram2.add(card10);
|
||||||
|
testProgram3.add(card11);
|
||||||
|
testProgram3.add(card12);
|
||||||
|
testProgram3.add(card13);
|
||||||
|
testProgram3.add(card14);
|
||||||
|
testProgram3.add(card15);
|
||||||
|
player1.setProgram(testProgram3);
|
||||||
|
player2.setProgram(testProgram3);
|
||||||
|
player3.setProgram(testProgram3);
|
||||||
|
player4.setProgram(testProgram3);
|
||||||
|
player5.setProgram(testProgram1);
|
||||||
|
player6.setProgram(testProgram2);
|
||||||
|
assertEquals(robot5.getRobotId(), board.getRobotOnPosition(robot5Position));
|
||||||
|
assertEquals(robot6.getRobotId(), board.getRobotOnPosition(robot6Position));
|
||||||
|
phase.runProgrammingCards(1);
|
||||||
|
assertEquals(robot5.getRobotId(), board.getRobotOnPosition(new Position(2, 12)));
|
||||||
|
assertEquals(robot6.getRobotId(), board.getRobotOnPosition(new Position(2, 14)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
3
src/test/resources/boards/win_test_board.txt
Normal file
3
src/test/resources/boards/win_test_board.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
1 1
|
||||||
|
17;1
|
||||||
|
0
|
Loading…
x
Reference in New Issue
Block a user