Browse Source

Merge remote-tracking branch 'origin/Final_Refactoring' into develop

develop
Jonas Wagner 3 years ago
parent
commit
e830f06651
  1. 2
      README.md
  2. 14
      src/main/java/Gameboard.java
  3. 1
      src/main/java/Player.java
  4. 30
      src/test/java/GameTest.java
  5. 19
      src/test/java/GameboardTest.java

2
README.md

@ -25,7 +25,7 @@ Test-Driven entwickelt, daher haben wir eine sehr große Testabdeckung für unse
## Voraussetzungen
- [Java 1.15](https://www.java.com/de/) (sollte aber auch mit fast allen weiteren Versionen funktionieren)
- [Java 1.15+](https://www.java.com/de/)
### Dependencies für Maven

14
src/main/java/Gameboard.java

@ -182,16 +182,4 @@ public class Gameboard {
}
return res;
}
}
/*
0-39 Spielfelder
Rot Ziel: 40,41,42,43
Blau Ziel: 44,45,46,47
Gelb Ziel: 48,49,50,51
Grün Ziel: 52.53.54.55
Rot Daneben: 56,57,58,59
Blau Daneben: 60,61,62,63
Gelb Daneben: 64.65.66.67
Grün Daneben: 68.69,70,71
*/
}

1
src/main/java/Player.java

@ -70,7 +70,6 @@ public class Player {
*/
public int choose(ArrayList<Integer> usableFigures) {
StringBuilder out = new StringBuilder("[");
Iterator<Integer> it = usableFigures.iterator();
for(int i = 0; i<usableFigures.size(); i++) {
out.append(usableFigures.get(i) + 1);
if(i < usableFigures.size()-1) {

30
src/test/java/GameTest.java

@ -76,13 +76,13 @@ public class GameTest {
1,
true
),
Arguments.of("Figures on Field - d: 6 - c: 1",
Arguments.of("Figures in Base + One in Finish (movable) - d: 5 - c: 1",
Arrays.asList(42, -1, -1, -1),
5,
1,
false
),
Arguments.of("Figures on Field - d: 6 - c: 1",
Arguments.of("Figures in Base + Two in Finish - d: 5 - c: 1",
Arrays.asList(42, 43, -1, -1),
5,
1,
@ -130,53 +130,59 @@ public class GameTest {
static Stream<Arguments> usableFiguresData () {
return Stream.of(
Arguments.of( //Würfel 1-6 - Keine Figur im Ziel - Alle Figuren auf dem Spielfeld - StartFeld frei - Keine Figur vor Ziel
Arguments.of(
"Alle Figuren",
1,
Arrays.asList(10, 25, 2, 17),
new ArrayList<>(Arrays.asList(0, 1, 2, 3))
),
Arguments.of( //Würfel 6 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld frei - Keine Figur vor Ziel
"Figuren die nicht am Spielfeld stehen",
Arguments.of(
"Nur Figuren aus der Base",
6,
Arrays.asList(10, -1, -1, -1),
new ArrayList<>(Arrays.asList(1, 2, 3))
),
Arguments.of( //Würfel 6 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Keine Figur vor Ziel
Arguments.of(
"Figur die das Startfeld besetzt",
6,
Arrays.asList(10, 0, -1, -1),
new ArrayList<>(List.of(1))
),
Arguments.of( //Würfel 5 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel
Arguments.of(
"Figur vor dem Ziel - kann man benutzen",
5,
Arrays.asList(10, 37, -1, -1),
new ArrayList<>(Arrays.asList(0,1))
),
Arguments.of( //Würfel 5 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel
Arguments.of(
"Figur vor dem Ziel - kann man nicht benutzen",
5,
Arrays.asList(10, 39, -1, -1),
new ArrayList<>(List.of(0))
),
Arguments.of( //Würfel 5 - Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel
Arguments.of(
"Nur Figuren die auf ein freies Feld kommen",
2,
Arrays.asList(10, 12, -1, -1),
new ArrayList<>(List.of(1))
),
Arguments.of( //Würfel 6 - 1 Figur auf dem Spielfeld - StartFeld besetzt
Arguments.of(
"Figur auf Startfeld",
6,
Arrays.asList(-1, -1, -1, 0),
new ArrayList<>(List.of(3))
),
Arguments.of( //Würfel 6 - 1 Figur auf dem Spielfeld - StartFeld besetzt
"Figur auf Startfeld",
Arguments.of(
"Im Ziel überworfen nur andere Figuren möglich",
5,
Arrays.asList(-1, 41, -1, 0),
new ArrayList<>(List.of(3))
),
Arguments.of(
"Im Haus bewegen",
2,
Arrays.asList(-1, 41, -1, 0),
new ArrayList<>(List.of(1, 3))
)
);
}

19
src/test/java/GameboardTest.java

@ -8,7 +8,6 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.stream.Stream;
@ -44,7 +43,7 @@ public class GameboardTest {
void checkGameboardFieldType(String testname, int Pos, int expectedResult) {
gb.initGameboard();
int currentType = gb.board[Pos];
assertThat(currentType).describedAs("Field Type").isEqualTo(expectedResult);
assertThat(currentType).describedAs(testname).isEqualTo(expectedResult);
}
static Stream<Arguments> FieldStream () {
@ -92,9 +91,12 @@ public class GameboardTest {
" "," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," "," "," "," "," ",
" "," "," "," "," "," ","\u001b[31;1m1\u001b[0m", "\u001b[31;1m2\u001b[0m","\u001b[31;1m3\u001b[0m","\u001b[31;1m4\u001b[0m",
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m","\u001b[34;1m4\u001b[0m","\u001b[33;1m1\u001b[0m","\u001b[33;1m2\u001b[0m","\u001b[33;1m3\u001b[0m","\u001b[33;1m4\u001b[0m","\u001b[32;1m1\u001b[0m","\u001b[32;1m2\u001b[0m",
"\u001b[32;1m3\u001b[0m","\u001b[32;1m4\u001b[0m"}
" "," "," "," "," "," ","\u001b[31;1m1\u001b[0m",
"\u001b[31;1m2\u001b[0m","\u001b[31;1m3\u001b[0m","\u001b[31;1m4\u001b[0m",
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m",
"\u001b[34;1m4\u001b[0m","\u001b[33;1m1\u001b[0m","\u001b[33;1m2\u001b[0m",
"\u001b[33;1m3\u001b[0m","\u001b[33;1m4\u001b[0m","\u001b[32;1m1\u001b[0m",
"\u001b[32;1m2\u001b[0m", "\u001b[32;1m3\u001b[0m","\u001b[32;1m4\u001b[0m"}
),
Arguments.of(
"Figures on Board",
@ -117,9 +119,10 @@ public class GameboardTest {
" "," "," "," ",
" "," "," "," ",
" "," "," "," ",
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m","\u001b[34;1m4\u001b[0m",
" "," "," ","\u001b[33;1m4\u001b[0m",
"\u001b[32;1m1\u001b[0m","\u001b[32;1m2\u001b[0m","\u001b[32;1m3\u001b[0m","\u001b[32;1m4\u001b[0m"}
"\u001b[34;1m1\u001b[0m","\u001b[34;1m2\u001b[0m","\u001b[34;1m3\u001b[0m",
"\u001b[34;1m4\u001b[0m", " "," "," ","\u001b[33;1m4\u001b[0m",
"\u001b[32;1m1\u001b[0m","\u001b[32;1m2\u001b[0m","\u001b[32;1m3\u001b[0m",
"\u001b[32;1m4\u001b[0m"}
)
);
}

Loading…
Cancel
Save