Skip to content

Commit

Permalink
#79 Wrong Disc count
Browse files Browse the repository at this point in the history
  • Loading branch information
oers committed Nov 19, 2024
1 parent 9023022 commit 1431995
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1431995

Please sign in to comment.