This commit is contained in:
Mykola Fesenko
2025-10-06 10:59:18 +02:00
parent 0d892f03bb
commit 4504de8c48
3 changed files with 28 additions and 21 deletions

Binary file not shown.

View File

@@ -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
}

View File

@@ -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;
}
@@ -148,11 +152,9 @@ public class Game {
return result;
}
public Chip getChipByPos(int relX, int relY) {
for (int i = 0; i < chips.size()-1; i++) {
System.out.println(i);
for (int i = 0; i <= chips.size() - 1; i++) {
if (chips.get(i).relativeX == relX && chips.get(i).relativeY == relY ) {
System.out.println("Found");
System.out.println("X" + chips.get(i).relativeX);
return chips.get(i);
} // end of if
}