Browse Source

4gewinnt: change to player 2 after player 1 played added

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
27c4b6122b
  1. 5
      src/main/java/de/tims/viergewinnt/ai/Logic.java
  2. 13
      src/test/java/de/tims/viergewinnt/ai/LogicTest.java

5
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -17,8 +17,9 @@ public class Logic {
int currentPlayer;
public int playChip(int[][] playfield, int column, int player) {
//add board update
testForWin(playfield, player);
currentPlayer = 2;
return 0;
}
@ -45,6 +46,8 @@ public class Logic {
for(int i = 0; i < gamefield.length; i++) {
gamefield[i] = new JLabel();
gamefield[i].setBorder(BorderFactory.createLineBorder(Color.gray));
gamefield[i].setOpaque(true);
gamefield[i].setBackground(Color.white);
playfieldPanel.add(gamefield[i]);
}

13
src/test/java/de/tims/viergewinnt/ai/LogicTest.java

@ -39,6 +39,19 @@ class LogicTest {
assertEquals(expectedResult, realResult);
}
@Test
void changePlayerTo2Test() {
int[][] playfield = new int[6][6];
int column = 0;
int player = 1;
int expectedResult = 2;
testObj.playChip(playfield, column, player);
int realResult = testObj.currentPlayer;
assertEquals(expectedResult, realResult);
}
private static Stream<Arguments> playfieldResults() {
int[][] playfield1 = {{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},

Loading…
Cancel
Save