diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index 49582bc..6fc6f9f 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -53,6 +53,15 @@ public class GameLogic { } if(countFields == this.board.length) finished = true; + // check rows + for (int i = 0; i < this.board[0].length; i++) { + for (int j = 0; j < this.board.length; j++) { + if(board[i][j] == player) countFields++; + break; + } + } + if(countFields == this.board.length) finished = true; + return finished; } diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index 266d2bc..223fd9c 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -149,7 +149,11 @@ class GameLogicTest { Arguments.of("check win in row 0 for player 1", 'x', true, new char[][] {{'x', 'x', 'x'}, {'o', '-', '-'}, - {'-', '-', 'o'}}) + {'-', '-', 'o'}}), + Arguments.of("check win in row 0 for player 2", 'x', true, new char[][] + {{'o', 'o', 'o'}, + {'x', 'o', '-'}, + {'-', '-', 'x'}}) ); }