Skip to content

Commit 30bc5e0

Browse files
authored
reversatile-79 (#90)
* closes #79 Wrong Disc count * undo button
1 parent 5eb96d5 commit 30bc5e0

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

project/src/androidTest/java/de/earthlingz/oerszebra/BasicTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package de.earthlingz.oerszebra;
22

3+
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
4+
35
import androidx.fragment.app.DialogFragment;
46
import androidx.fragment.app.Fragment;
57
import androidx.fragment.app.FragmentActivity;
@@ -22,6 +24,7 @@ public void init() throws InterruptedException {
2224
while (zebra == null && !zebra.initialized()) {
2325
Thread.sleep(100);
2426
}
27+
getInstrumentation().waitForIdleSync();
2528
}
2629

2730
void waitForOpenendDialogs(boolean dismiss) throws InterruptedException {

project/src/androidTest/java/de/earthlingz/oerszebra/DroidZebraTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ public void testIssue22() throws InterruptedException {
6565
assertSame(32, countSquares(ZebraEngine.PLAYER_BLACK));
6666
}
6767

68+
@Test
69+
public void testIssue79() throws InterruptedException {
70+
Intent intent = new Intent();
71+
intent.setAction(Intent.ACTION_SEND);
72+
intent.setType("message/rfc822");
73+
intent.putExtra(Intent.EXTRA_TEXT, "E6F6C4D6F7C3C6C7G6H6C8G8C2B2A2C1G7C5B3B6A6H8E3A3F4A1");
74+
75+
zebra.runOnUiThread(() -> zebra.onNewIntent(intent));
76+
waitForOpenendDialogs(false);
77+
assertSame(34, countSquares(ZebraEngine.PLAYER_EMPTY));
78+
assertSame(15, countSquares(ZebraEngine.PLAYER_WHITE));
79+
assertSame(15, countSquares(ZebraEngine.PLAYER_BLACK));
80+
assertSame(32,zebra.getState().getBlackScore());
81+
assertSame(32,zebra.getState().getWhiteScore());
82+
}
83+
6884
@Test
6985
public void testCrash1() throws InterruptedException {
7086
Intent intent = new Intent();

project/src/main/java/de/earthlingz/oerszebra/BoardView/GameStateBoardModel.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ public void processGameOver() {
7070
int max = currentBoard.size() * currentBoard.size();
7171
if (getBlackScore() + getWhiteScore() < max) {
7272
//adjust result
73-
if (getBlackScore() > getWhiteScore()) {
73+
if (getBlackScore() == getWhiteScore()) {
74+
int empty = max - blackScore - whiteScore;
75+
this.blackScore = blackScore + empty/2;
76+
this.whiteScore = whiteScore + empty/2;
77+
}
78+
else if (getBlackScore() > getWhiteScore()) {
7479
this.blackScore = max - getWhiteScore();
7580
} else {
7681
this.whiteScore = max - getBlackScore();

project/src/main/java/de/earthlingz/oerszebra/DroidZebra.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ void redo() {
220220
}
221221

222222
void undo() {
223-
menu.findItem(R.id.menu_take_back).setEnabled(false);
224223
engine.undoMove(gameState);
225224
}
226225

@@ -715,7 +714,6 @@ public void onError(String error) {
715714

716715
@Override
717716
public void onBoard(GameState gameState) {
718-
menu.findItem(R.id.menu_take_back).setEnabled(true);
719717
int sideToMove = gameState.getSideToMove();
720718

721719
//triggers animations

0 commit comments

Comments
 (0)