30.09 ptp
This commit is contained in:
59
Game.java
59
Game.java
@@ -1,4 +1,7 @@
|
||||
import javafx.scene.shape.Shape;
|
||||
import java.util.ArrayList;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
/**
|
||||
*
|
||||
* Beschreibung
|
||||
@@ -8,19 +11,57 @@ import javafx.scene.shape.Shape;
|
||||
*/
|
||||
|
||||
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; 2 = player can remove chip
|
||||
public int white_chips = 9;
|
||||
public int black_chips = 9;
|
||||
|
||||
public void addShape(Shape shape);
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user