67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
import javafx.scene.shape.Shape;
|
|
import java.util.ArrayList;
|
|
import javafx.scene.layout.Pane;
|
|
import javafx.scene.paint.Color;
|
|
/**
|
|
*
|
|
* Beschreibung
|
|
*
|
|
* @version 1.0 vom 30.09.2025
|
|
* @author
|
|
*/
|
|
|
|
public class Game {
|
|
|
|
public String currentTurnPlayer = "White";
|
|
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 ArrayList<Shape> buttons = new ArrayList<Shape>();
|
|
public ArrayList<Chip> chips = new ArrayList<Chip>();
|
|
public Pane game_board;
|
|
public Chip current_selection;
|
|
|
|
public void start(Pane gameBoard) {
|
|
game_board = gameBoard;
|
|
}
|
|
|
|
public void chip_button_clicked(MuehleButton button) {
|
|
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
|
|
}
|
|
} |