@ -64,6 +64,13 @@ public class GameLogic {
countFields = 0;
}
// check diagonal left
for (int i = this.board.length - 1, j = this.board.length - 1; i >= 0 ; i--, j--) {
if (board[i][j] == player) countFields++;
if(countFields == this.board.length) return finished = true;
return finished;
@ -196,13 +196,17 @@ class GameLogicTest {
{'-', '-', '-'}}),
Arguments.of("check a draw for player 2", 'o', false, new char[][]
{{'o', 'o', 'x'},
{'o', 'o', 'x'},
{'o', 'x', 'x'},
{'x', 'x', 'o'}}),
Arguments.of("check a draw for player 1", 'x', false, new char[][]
{'x', 'x', 'o'}})
);
Arguments.of("check diagonal left win for player 1", 'x', true, new char[][]
{{'x', 'o', 'x'},
{'x', 'x', 'o'},
{'o', 'o', 'x'}})
xxxxxxxxxx
xxxxxxxxxx