pre-final
This commit is contained in:
@@ -17,8 +17,7 @@ public class Chip {
|
|||||||
|
|
||||||
public Color color;
|
public Color color;
|
||||||
|
|
||||||
public int relativeX;
|
|
||||||
public int relativeY;
|
|
||||||
|
|
||||||
public double absoluteX;
|
public double absoluteX;
|
||||||
public double absoluteY;
|
public double absoluteY;
|
||||||
@@ -30,11 +29,10 @@ public class Chip {
|
|||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
|
|
||||||
public Chip(int id, int relX, int relY,double absX, double absY, Color color, Game game) {
|
public Chip(int id,double absX, double absY, Color color, Game game) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
relativeX = relX;
|
|
||||||
relativeY = relY;
|
|
||||||
|
|
||||||
absoluteX = absX;
|
absoluteX = absX;
|
||||||
absoluteY = absY;
|
absoluteY = absY;
|
||||||
|
|||||||
45
Game.java
45
Game.java
@@ -21,14 +21,14 @@ public class Game {
|
|||||||
,{0,1,2},{9,10,11},{18,19,20},{3,4,5},{12,13,14},{6,7,8},{21,22,23},{15,16,17}
|
,{0,1,2},{9,10,11},{18,19,20},{3,4,5},{12,13,14},{6,7,8},{21,22,23},{15,16,17}
|
||||||
};
|
};
|
||||||
public int[][] close_chips = {{1,3},{0,2,10},{1,17},{0,4,6},{3,5,9,12},{4,18,21} // 0 1 2 3 4 5
|
public int[][] close_chips = {{1,3},{0,2,10},{1,17},{0,4,6},{3,5,9,12},{4,18,21} // 0 1 2 3 4 5
|
||||||
,{3,7},{6,8},{7,17},{4,10},{9,11,19,1},{10,16},{4,13},{7,12,14,22},{13,16} // 6 7 8 9 10 11 12 13 14
|
,{3,7},{6,8,13},{7,17},{4,10},{9,11,19,1},{10,16},{4,13},{7,12,14,22},{13,16} // 6 7 8 9 10 11 12 13 14
|
||||||
,{16,20,23},{15,17,11,14},{2,16,8},{5,19},{18,20,10},{19,15},{5,22},{21,13,23} // 15 16 17 18 19 20 21 22 22
|
,{16,20,23},{15,17,11,14},{2,16,8},{5,19},{18,20,10},{19,15},{5,22},{21,13,23} // 15 16 17 18 19 20 21 22 22
|
||||||
,{22,15}
|
,{22,15}
|
||||||
};
|
};
|
||||||
public String currentTurnPlayer = "White";
|
public String currentTurnPlayer = "White";
|
||||||
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2,3 = player can remove chip
|
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2,3 = player can remove chip
|
||||||
public int white_chips = 3;
|
public int white_chips = 9;
|
||||||
public int black_chips = 3;
|
public int black_chips = 9;
|
||||||
|
|
||||||
|
|
||||||
public int white_combos = 0;
|
public int white_combos = 0;
|
||||||
@@ -57,13 +57,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.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
|
newChip = addChip(button.id,button.absoluteX,button.absoluteY,Color.WHITE);
|
||||||
white_chips--;
|
white_chips--;
|
||||||
setChipCount(white_chips,"White");
|
setChipCount(white_chips,"White");
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newChip = addChip(button.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
|
newChip = addChip(button.id,button.absoluteX,button.absoluteY,Color.BLACK);
|
||||||
black_chips--;
|
black_chips--;
|
||||||
setChipCount(white_chips,"Black");
|
setChipCount(white_chips,"Black");
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public void moveChip(Chip chip,MuehleButton target) {
|
public void moveChip(Chip chip,MuehleButton target) {
|
||||||
Chip newChip = new Chip(target.id,0,0,target.absoluteX,target.absoluteY,chip.color,chip.game);
|
Chip newChip = new Chip(target.id,target.absoluteX,target.absoluteY,chip.color,chip.game);
|
||||||
//MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX, chip.absoluteY,chip.game);
|
//MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX, chip.absoluteY,chip.game);
|
||||||
|
|
||||||
//buttons.remove(target);
|
//buttons.remove(target);
|
||||||
@@ -118,8 +118,8 @@ public class Game {
|
|||||||
checkCombo(newChip);
|
checkCombo(newChip);
|
||||||
removeChipTurn();
|
removeChipTurn();
|
||||||
}
|
}
|
||||||
public Chip addChip(int id,int relX, int relY,double absX, double absY, Color color) {
|
public Chip addChip(int id,double absX, double absY, Color color) {
|
||||||
Chip chip = new Chip(id,relX,relY,absX,absY,color,this);
|
Chip chip = new Chip(id,absX,absY,color,this);
|
||||||
chips.add(chip);
|
chips.add(chip);
|
||||||
addShape(chip.getShape());
|
addShape(chip.getShape());
|
||||||
return chip;
|
return chip;
|
||||||
@@ -151,17 +151,6 @@ public class Game {
|
|||||||
}
|
}
|
||||||
public void chip_clicked(Chip chip) {
|
public void chip_clicked(Chip chip) {
|
||||||
System.out.println("Chipd id: " + chip.id);
|
System.out.println("Chipd id: " + chip.id);
|
||||||
if(game_state == 2 && chip.color == Color.BLACK) {
|
|
||||||
removeChip(chip);
|
|
||||||
white_combos--;
|
|
||||||
removeChipTurn();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (game_state == 3 && chip.color == Color.WHITE) {
|
|
||||||
removeChip(chip);
|
|
||||||
black_combos--;
|
|
||||||
removeChipTurn();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game_state == 1) {
|
if (game_state == 1) {
|
||||||
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
|
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
|
||||||
@@ -189,6 +178,21 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(game_state == 2 && chip.color == Color.BLACK) {
|
||||||
|
removeChip(chip);
|
||||||
|
white_combos--;
|
||||||
|
removeChipTurn();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (game_state == 3 && chip.color == Color.WHITE) {
|
||||||
|
|
||||||
|
removeChip(chip);
|
||||||
|
black_combos--;
|
||||||
|
removeChipTurn();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void hideAllButtons() {
|
public void hideAllButtons() {
|
||||||
for (int i = 0; i < buttons.size(); i++) {
|
for (int i = 0; i < buttons.size(); i++) {
|
||||||
@@ -199,7 +203,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
public void drawAvaibleMoves(Chip chip) {
|
public void drawAvaibleMoves(Chip chip) {
|
||||||
if(getAmouuntOfColorChips(chip.color) > 3) {
|
if(getAmouuntOfColorChips(chip.color) > 3) {
|
||||||
drawAvaibleMoves(chip);
|
drawAvaibleButtons(chip);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drawAllAvaibleButtons(chip);
|
drawAllAvaibleButtons(chip);
|
||||||
@@ -241,6 +245,7 @@ public class Game {
|
|||||||
|
|
||||||
public void removeChipTurn() {
|
public void removeChipTurn() {
|
||||||
if (white_combos > 0 || black_combos > 0) {
|
if (white_combos > 0 || black_combos > 0) {
|
||||||
|
hideAllButtons();
|
||||||
if (white_combos > 0) {
|
if (white_combos > 0) {
|
||||||
setLabelText("White, You can remove "+ white_combos + " Black Pieces");
|
setLabelText("White, You can remove "+ white_combos + " Black Pieces");
|
||||||
game_state = 2;
|
game_state = 2;
|
||||||
|
|||||||
21
Muehle.java
21
Muehle.java
@@ -58,7 +58,7 @@ public class Muehle extends Application {
|
|||||||
drawPlayerChips();
|
drawPlayerChips();
|
||||||
|
|
||||||
//lTop.setAlignment();
|
//lTop.setAlignment();
|
||||||
setTopLabel("Test Label");
|
// setTopLabel("Test Label");
|
||||||
|
|
||||||
|
|
||||||
primaryStage.setOnCloseRequest(e -> System.exit(0));
|
primaryStage.setOnCloseRequest(e -> System.exit(0));
|
||||||
@@ -149,49 +149,49 @@ public class Muehle extends Application {
|
|||||||
int id_count = 0;
|
int id_count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,0,i,topLeftX,topLeftY+ i*325,game);
|
MuehleButton button = new MuehleButton(id_count,topLeftX,topLeftY+ i*325,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100,game);
|
MuehleButton button = new MuehleButton(id_count,topRightX -230,topLeftY+ i*100,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,2,i,topRightX + 140,topLeftY+ i*325,game);
|
MuehleButton button = new MuehleButton(id_count,topRightX + 140,topLeftY+ i*325,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,0,i,topLeftX + 100,topLeftY+ i*220 +100,game);
|
MuehleButton button = new MuehleButton(id_count,topLeftX + 100,topLeftY+ i*225 +100,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,2,i,topRightX +40,topLeftY+ i*220 +100,game);
|
MuehleButton button = new MuehleButton(id_count,topRightX +40,topLeftY+ i*225 +100,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100 + 460,game);
|
MuehleButton button = new MuehleButton(id_count,topRightX -230,topLeftY+ i*100 + 460,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|
||||||
MuehleButton button = new MuehleButton(id_count,0,i,topLeftX +200,topLeftY+ i*130 +200,game);
|
MuehleButton button = new MuehleButton(id_count,topLeftX +200,topLeftY+ i*130 +200,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(id_count,2,i,topLeftX +540,topLeftY+ i*130 +200,game);
|
MuehleButton button = new MuehleButton(id_count,topLeftX +540,topLeftY+ i*130 +200,game);
|
||||||
id_count++;
|
id_count++;
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
}
|
}
|
||||||
@@ -236,6 +236,9 @@ public class Muehle extends Application {
|
|||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// end methods
|
// end methods
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ public class MuehleButton {
|
|||||||
|
|
||||||
public Game game;
|
public Game game;
|
||||||
|
|
||||||
public int relativeX;
|
|
||||||
public int relativeY;
|
|
||||||
|
|
||||||
public double absoluteX;
|
public double absoluteX;
|
||||||
public double absoluteY;
|
public double absoluteY;
|
||||||
@@ -26,11 +25,10 @@ public class MuehleButton {
|
|||||||
|
|
||||||
public boolean isDestroyed = false;
|
public boolean isDestroyed = false;
|
||||||
|
|
||||||
public MuehleButton(int id,int relX, int relY, double absX, double absY, Game game) {
|
public MuehleButton(int id, double absX, double absY, Game game) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
relativeX = relX;
|
|
||||||
relativeY = relY;
|
|
||||||
|
|
||||||
absoluteX = absX;
|
absoluteX = absX;
|
||||||
absoluteY = absY;
|
absoluteY = absY;
|
||||||
@@ -57,8 +55,8 @@ public class MuehleButton {
|
|||||||
circle.setFill(this.color);
|
circle.setFill(this.color);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//circle.setFill(Color.rgb(0,0,0,0));
|
circle.setFill(Color.rgb(0,0,0,0));
|
||||||
circle.setFill(Color.rgb(0,255,0));
|
//circle.setFill(Color.rgb(0,255,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void destroy( ) {
|
public void destroy( ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user