diff --git a/project/src/androidTest/java/de/earthlingz/oerszebra/DroidZebraTest.java b/project/src/androidTest/java/de/earthlingz/oerszebra/DroidZebraTest.java index 8f55c42..7b27c68 100644 --- a/project/src/androidTest/java/de/earthlingz/oerszebra/DroidZebraTest.java +++ b/project/src/androidTest/java/de/earthlingz/oerszebra/DroidZebraTest.java @@ -65,6 +65,22 @@ public void testIssue22() throws InterruptedException { assertSame(32, countSquares(ZebraEngine.PLAYER_BLACK)); } + @Test + public void testIssue79() throws InterruptedException { + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_SEND); + intent.setType("message/rfc822"); + intent.putExtra(Intent.EXTRA_TEXT, "E6F6C4D6F7C3C6C7G6H6C8G8C2B2A2C1G7C5B3B6A6H8E3A3F4A1"); + + zebra.runOnUiThread(() -> zebra.onNewIntent(intent)); + waitForOpenendDialogs(false); + assertSame(34, countSquares(ZebraEngine.PLAYER_EMPTY)); + assertSame(15, countSquares(ZebraEngine.PLAYER_WHITE)); + assertSame(15, countSquares(ZebraEngine.PLAYER_BLACK)); + assertSame(32,zebra.getState().getBlackScore()); + assertSame(32,zebra.getState().getWhiteScore()); + } + @Test public void testCrash1() throws InterruptedException { Intent intent = new Intent(); diff --git a/project/src/main/java/de/earthlingz/oerszebra/BoardView/GameStateBoardModel.java b/project/src/main/java/de/earthlingz/oerszebra/BoardView/GameStateBoardModel.java index 1ec7a1a..c8084d0 100644 --- a/project/src/main/java/de/earthlingz/oerszebra/BoardView/GameStateBoardModel.java +++ b/project/src/main/java/de/earthlingz/oerszebra/BoardView/GameStateBoardModel.java @@ -70,7 +70,12 @@ public void processGameOver() { int max = currentBoard.size() * currentBoard.size(); if (getBlackScore() + getWhiteScore() < max) { //adjust result - if (getBlackScore() > getWhiteScore()) { + if (getBlackScore() == getWhiteScore()) { + int empty = max - blackScore - whiteScore; + this.blackScore = blackScore + empty/2; + this.whiteScore = whiteScore + empty/2; + } + else if (getBlackScore() > getWhiteScore()) { this.blackScore = max - getWhiteScore(); } else { this.whiteScore = max - getBlackScore();