Fixed more bugs
diff --git a/bin/TicTacToe.apk b/bin/TicTacToe.apk
index d2b5fd8..b392638 100644
--- a/bin/TicTacToe.apk
+++ b/bin/TicTacToe.apk
Binary files differ
diff --git a/bin/classes.dex b/bin/classes.dex
index 2bb4095..a805a2f 100644
--- a/bin/classes.dex
+++ b/bin/classes.dex
Binary files differ
diff --git a/bin/classes/com/tictactoe/MainActivity$2.class b/bin/classes/com/tictactoe/MainActivity$2.class
index 68867b2..f53cc61 100644
--- a/bin/classes/com/tictactoe/MainActivity$2.class
+++ b/bin/classes/com/tictactoe/MainActivity$2.class
Binary files differ
diff --git a/bin/classes/com/tictactoe/MainActivity.class b/bin/classes/com/tictactoe/MainActivity.class
index 5a78710..bac725b 100644
--- a/bin/classes/com/tictactoe/MainActivity.class
+++ b/bin/classes/com/tictactoe/MainActivity.class
Binary files differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
index 9750512..d635e70 100644
--- a/bin/resources.ap_
+++ b/bin/resources.ap_
Binary files differ
diff --git a/src/com/tictactoe/MainActivity.java b/src/com/tictactoe/MainActivity.java
index fc986da..41a9d62 100644
--- a/src/com/tictactoe/MainActivity.java
+++ b/src/com/tictactoe/MainActivity.java
@@ -112,21 +112,14 @@
generateLoss();
return;
}
- if(i == 1){
- if(checkSecondDiagonalComputer(i)){
- computerClick(i, j);
- generateLoss();
- return;
- }
+
+ } else if (i + j == 2) {
+ if (checkSecondDiagonalComputer(i)) {
+ computerClick(i, j);
+ generateLoss();
+ return;
}
- }
- if (i + j == 2) {
- if (checkSecondDiagonalComputer(i)) {
- computerClick(i, j);
- generateLoss();
- return;
- }
- }
+ }
if ((boxForComputer((i + 1) % 3, j) && boxForComputer(
(i + 2) % 3, j))
|| (boxForComputer(i, (j + 1) % 3) && boxForComputer(
@@ -142,33 +135,25 @@
for (int j = 0; j < 3; j++) {
if (boxIsEmpty(i, j)) {
board[i][j].setEnabled(true);
- if (i == j ) {
+ if (i == j) {
if (checkFirstDiagonalHuman(i, j)) {
computerClick(i, j);
if (checkDraw()) {
generateDraw();
+
}
- if(i == 1) {
- if(checkSecondDiagonalHuman(i)){
- computerClick(i, j);
- if(checkDraw()){
- generateDraw();
- }
- }
- }
- return; // check the case where i == j == 1
+ return;
}
- }
- if (i + j == 2) {
- if (checkSecondDiagonalHuman(i)) {
- computerClick(i, j);
- if (checkDraw()) {
- generateDraw();
- return;
- }
-
+ }
+ if (i + j == 2) {
+ if (checkSecondDiagonalHuman(i)) {
+ computerClick(i, j);
+ if (checkDraw()) {
+ generateDraw();
}
+ return;
}
+ }
if ((boxForHuman((i + 1) % 3, j) && boxForHuman(
(i + 2) % 3, j))
|| (boxForHuman(i, (j + 1) % 3) && boxForHuman(
@@ -256,14 +241,13 @@
private boolean checkUserWin(int a, int b) {
if (a == b) {
- if(a + b == 2){
- if(checkFirstDiagonalHuman(a, b)){
- return checkFirstDiagonalHuman(a, b);
- } else {
- return checkSecondDiagonalHuman(a);
- }
+ if (checkFirstDiagonalHuman(a, b)) {
+ return checkFirstDiagonalHuman(a, b);
}
- }
+ if (a == 1) {
+ return checkSecondDiagonalHuman(a);
+ }
+ }
if (a + b == 2) {
return checkSecondDiagonalHuman(a);
} else {