30.09 ptp

This commit is contained in:
Mykola Fesenko
2025-09-30 10:51:52 +02:00
parent c94eb0f036
commit 5de88e7fae
12 changed files with 408 additions and 175 deletions

View File

@@ -1,3 +1,7 @@
import javafx.scene.shape.Shape;
import java.util.ArrayList;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
/**
*
* Beschreibung
@@ -7,19 +11,57 @@
*/
public class Game {
public String currentTurnPlayer = "White";
public int white_chips = 7;
public int black_chips = 7;
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips
public int white_chips = 9;
public int black_chips = 9;
public void addShape;
public ArrayList<Shape> buttons = new ArrayList<Shape>();
public ArrayList<Chip> chips = new ArrayList<Chip>();
public Pane game_board;
public Chip current_selection;
public void start() {
public void start(Pane gameBoard) {
game_board = gameBoard;
}
public void chip_button_clicked(MuehleButton button) {
System.out.println(button.absoluteX);
}
if (game_state == 0) {
if (currentTurnPlayer == "White") {
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
white_chips--;
}
else {
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
black_chips--;
}
game_board.getChildren().remove(button.getShape());
nextTurn();
} // end of if
}
public void addChip(int relX, int relY,double absX, double absY, Color color) {
Chip chip = new Chip(relX,relY,absX,absY,color,this);
addShape(chip.getShape());
}
public void addShape(Shape newShape) {
game_board.getChildren().add(newShape);
}
public void chip_clicked(Chip chip) {
System.out.println(chip.relativeX);
}
public void nextTurn() {
if (currentTurnPlayer == "White") {
currentTurnPlayer = "Black";
}
else {
currentTurnPlayer = "White";
} // end of if-else
}
}