06.10
This commit is contained in:
25
Game.java
25
Game.java
@@ -102,15 +102,19 @@ public class Game {
|
||||
}
|
||||
public boolean checkCombo(int relX, int relY) {
|
||||
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY);
|
||||
ArrayList<Chip> vChips = getHorizontalCloseChips(relX,relY);
|
||||
System.out.println(hChips.get(0).relativeX);
|
||||
Chip start_chip = getChipByPos(relX,relY);
|
||||
ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY);
|
||||
|
||||
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) {
|
||||
return true;
|
||||
Chip start_chip = getChipByPos(relX,relY);
|
||||
System.out.println("Size" + hChips.toString());
|
||||
if (hChips.get(0) != null && hChips.get(1) != null ) {
|
||||
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) {
|
||||
return true;
|
||||
if(vChips.get(0) != null && vChips.get(1) != null) {
|
||||
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -128,7 +132,8 @@ public class Game {
|
||||
else {
|
||||
result.add(getChipByPos(0,relY));
|
||||
result.add(getChipByPos(1,relY));
|
||||
} // end of if-else
|
||||
} // end of if-else
|
||||
System.out.println("Result: " + result.toString());
|
||||
return result;
|
||||
}
|
||||
public ArrayList<Chip> getVerticalCloseChips(int relX, int relY) {
|
||||
@@ -148,9 +153,9 @@ public class Game {
|
||||
return result;
|
||||
}
|
||||
public Chip getChipByPos(int relX, int relY) {
|
||||
|
||||
for (int i = 0; i < chips.size()-1; i++) {
|
||||
for (int i = 0; i <= chips.size() - 1; i++) {
|
||||
if (chips.get(i).relativeX == relX && chips.get(i).relativeY == relY ) {
|
||||
System.out.println("X" + chips.get(i).relativeX);
|
||||
return chips.get(i);
|
||||
} // end of if
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user