Browse Source

Add FieldTypes to Gameboard

AIPlayer
Felix Krull 3 years ago
parent
commit
036c0dccdd
  1. 16
      src/main/java/Gameboard.java
  2. 27
      src/test/java/GameboardTest.java

16
src/main/java/Gameboard.java

@ -2,7 +2,21 @@ public class Gameboard {
int[] board;
public Gameboard() {
board = new int[11];
board = new int[56];
}
public void initGameboard (){
board[0] = 1;
board[10] = 1;
board[20] = 1;
board[30] = 1;
board[9] = 2;
board[19] = 2;
board[29] = 2;
board[39] = 2;
for (int i = 40; i < board.length; i++) {
board[i] = 3;
}
}
}

27
src/test/java/GameboardTest.java

@ -19,7 +19,7 @@ public class GameboardTest {
@Test
void checkGameboardSize() {
String expectedResult = "11";
String expectedResult = "56";
String currentResult = "" + gb.board.length;
assertThat(currentResult).describedAs("Dimensions").isEqualTo(expectedResult);
@ -27,7 +27,7 @@ public class GameboardTest {
@Test
void checkGameboardFilled() {
int[] expectedGameboard = new int[11];
int[] expectedGameboard = new int[56];
for(int i = 0; i < expectedGameboard.length; i++) {
expectedGameboard[i] = 0;
}
@ -36,5 +36,28 @@ public class GameboardTest {
assertThat(givenGameboard).describedAs("Initial Gameboard").isEqualTo(expectedGameboard);
}
@ParameterizedTest
@MethodSource("FieldStream")
void checkGameboardFieldType(String testname, int Pos, int expectedResult) {
gb.initGameboard();
int currentType = gb.board[Pos];
assertThat(currentType).describedAs("Field Type").isEqualTo(expectedResult);
}
static Stream<Arguments> FieldStream () {
return Stream.of(
Arguments.of("Normal Path", 1, 0),
Arguments.of("Starting Field", 0, 1),
Arguments.of("Starting Field", 10, 1),
Arguments.of("Starting Field", 20, 1),
Arguments.of("Starting Field", 30, 1),
Arguments.of("Doorway Field", 9, 2),
Arguments.of("Doorway Field", 19, 2),
Arguments.of("Doorway Field", 29, 2),
Arguments.of("Doorway Field", 39, 2),
Arguments.of("House Field", 40, 3),
Arguments.of("House Field", 55, 3)
);
}
}
Loading…
Cancel
Save