This commit is contained in:
Mykola Fesenko
2025-10-08 10:46:01 +02:00
parent 4504de8c48
commit 15537a81b1
16 changed files with 78 additions and 42 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -28,7 +28,11 @@ public class Chip {
public Circle circle; public Circle circle;
public Chip(int relX, int relY,double absX, double absY, Color color, Game game) { public int ring;
public Chip(int ring, int relX, int relY,double absX, double absY, Color color, Game game) {
this.ring = ring;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;

View File

@@ -28,6 +28,8 @@ public class Chip {
public Circle circle; public Circle circle;
public int ring;
public Chip(int relX, int relY,double absX, double absY, Color color, Game game) { public Chip(int relX, int relY,double absX, double absY, Color color, Game game) {
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;
@@ -52,8 +54,8 @@ public class Chip {
circle.setCenterX(absoluteX); circle.setCenterX(absoluteX);
} }
public void setPositionY(double Y) { public void setPositionY(double Y) {
absoluteX = Y; absoluteY = Y;
circle.setCenterX(absoluteY); circle.setCenterY(absoluteY);
} }
public Shape getShape() { public Shape getShape() {
return circle; return circle;

Binary file not shown.

View File

@@ -42,13 +42,13 @@ public class Game {
if (game_state == 0) { if (game_state == 0) {
Chip newChip; Chip newChip;
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE); newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
white_chips--; white_chips--;
setChipCount(white_chips,"White"); setChipCount(white_chips,"White");
} }
else { else {
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK); newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
black_chips--; black_chips--;
setChipCount(white_chips,"Black"); setChipCount(white_chips,"Black");
} }
@@ -64,8 +64,8 @@ public class Game {
} }
} }
public Chip addChip(int relX, int relY,double absX, double absY, Color color) { public Chip addChip(int ring,int relX, int relY,double absX, double absY, Color color) {
Chip chip = new Chip(relX,relY,absX,absY,color,this); Chip chip = new Chip(ring,relX,relY,absX,absY,color,this);
chips.add(chip); chips.add(chip);
addShape(chip.getShape()); addShape(chip.getShape());
return chip; return chip;
@@ -98,10 +98,10 @@ public class Game {
LTop.setText(value); LTop.setText(value);
} }
public boolean checkCombo(Chip chip) { public boolean checkCombo(Chip chip) {
return checkCombo(chip.relativeX, chip.relativeY); return checkCombo(chip.relativeX, chip.relativeY, chip.ring);
} }
public boolean checkCombo(int relX, int relY) { public boolean checkCombo(int relX, int relY, int ring) {
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY); ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY,ring);
ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY); ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY);
Chip start_chip = getChipByPos(relX,relY); Chip start_chip = getChipByPos(relX,relY);
@@ -119,8 +119,9 @@ public class Game {
return false; return false;
} }
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY) { public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY, int ring) {
ArrayList<Chip> result = new ArrayList<Chip>(); ArrayList<Chip> result = new ArrayList<Chip>();
System.out.println("Target: " + ring);
if (relX == 0) { if (relX == 0) {
result.add(getChipByPos(1,relY)); result.add(getChipByPos(1,relY));
result.add(getChipByPos(2,relY)); result.add(getChipByPos(2,relY));

View File

@@ -42,13 +42,13 @@ public class Game {
if (game_state == 0) { if (game_state == 0) {
Chip newChip; Chip newChip;
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE); newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
white_chips--; white_chips--;
setChipCount(white_chips,"White"); setChipCount(white_chips,"White");
} }
else { else {
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK); newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
black_chips--; black_chips--;
setChipCount(white_chips,"Black"); setChipCount(white_chips,"Black");
} }
@@ -64,8 +64,8 @@ public class Game {
} }
} }
public Chip addChip(int relX, int relY,double absX, double absY, Color color) { public Chip addChip(int ring,int relX, int relY,double absX, double absY, Color color) {
Chip chip = new Chip(relX,relY,absX,absY,color,this); Chip chip = new Chip(ring,relX,relY,absX,absY,color,this);
chips.add(chip); chips.add(chip);
addShape(chip.getShape()); addShape(chip.getShape());
return chip; return chip;
@@ -98,10 +98,10 @@ public class Game {
LTop.setText(value); LTop.setText(value);
} }
public boolean checkCombo(Chip chip) { public boolean checkCombo(Chip chip) {
return checkCombo(chip.relativeX, chip.relativeY); return checkCombo(chip.relativeX, chip.relativeY, chip.ring);
} }
public boolean checkCombo(int relX, int relY) { public boolean checkCombo(int relX, int relY, int ring) {
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY); ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY,ring);
ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY); ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY);
Chip start_chip = getChipByPos(relX,relY); Chip start_chip = getChipByPos(relX,relY);
@@ -119,8 +119,9 @@ public class Game {
return false; return false;
} }
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY) { public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY, int ring) {
ArrayList<Chip> result = new ArrayList<Chip>(); ArrayList<Chip> result = new ArrayList<Chip>();
System.out.println("Target: " + relY);
if (relX == 0) { if (relX == 0) {
result.add(getChipByPos(1,relY)); result.add(getChipByPos(1,relY));
result.add(getChipByPos(2,relY)); result.add(getChipByPos(2,relY));
@@ -132,7 +133,8 @@ public class Game {
else { else {
result.add(getChipByPos(0,relY)); result.add(getChipByPos(0,relY));
result.add(getChipByPos(1,relY)); result.add(getChipByPos(1,relY));
} // end of if-else } // end of if-else
System.out.println("Result: " + result.toString());
return result; return result;
} }
public ArrayList<Chip> getVerticalCloseChips(int relX, int relY) { public ArrayList<Chip> getVerticalCloseChips(int relX, int relY) {

Binary file not shown.

View File

@@ -134,41 +134,42 @@ public class Muehle extends Application {
Color button_color = Color.BLUE; Color button_color = Color.BLUE;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(0,0,i,topLeftX,topLeftY+ i*325,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game); MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(0,2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(1,0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(1,2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 2; i >=0; i--) {
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game); MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100 + 360,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
MuehleButton button = new MuehleButton(2,0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(0,2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }

View File

@@ -134,41 +134,43 @@ public class Muehle extends Application {
Color button_color = Color.BLUE; Color button_color = Color.BLUE;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(0,0,i,topLeftX,topLeftY+ i*325,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game); MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(0,2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(1,0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(1,2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 2; i >=0; i--) {
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game); System.out.println("Er" +( i*100 + 360));
MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100 + 360,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
MuehleButton button = new MuehleButton(2,0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(0,2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
shapes.add(button.getShape()); shapes.add(button.getShape());
} }
@@ -204,6 +206,8 @@ public class Muehle extends Application {
addShape(black_player_chips[i]); addShape(black_player_chips[i]);
} }
game.white_player_chips = white_player_chips;
game.black_player_chips = black_player_chips;
} }
public void addShape(Shape newShape) { public void addShape(Shape newShape) {

Binary file not shown.

Binary file not shown.

View File

@@ -20,7 +20,11 @@ public class MuehleButton {
public Circle circle; public Circle circle;
public MuehleButton(int relX, int relY, double absX, double absY, Color color, Game game) { public int ring;
public MuehleButton(int ring,int relX, int relY, double absX, double absY, Color color, Game game) {
this.ring = ring;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;

View File

@@ -20,7 +20,7 @@ public class MuehleButton {
public Circle circle; public Circle circle;
public MuehleButton(int relX, int relY, double absX, double absY, Color color, Game game) { public MuehleButton(int ring,int relX, int relY, double absX, double absY, Color color, Game game) {
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;
@@ -44,8 +44,8 @@ public class MuehleButton {
EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() { EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
System.out.println("Button Clicked!"); System.out.println("Button Clicked!");
MouseClick(); MouseClick();
} }
}; };

11
README.md Normal file
View File

@@ -0,0 +1,11 @@
Plan
* check for combination
* rework UI
* refactoring
* win/lose check
08.10.2025
Working on UI

7
README.~d Normal file
View File

@@ -0,0 +1,7 @@
Plan
* check for combination
* rework UI
* refactoring
* win/lose check