repaired moving
This commit is contained in:
70
Game.java
70
Game.java
@@ -20,9 +20,9 @@ public class Game {
|
|||||||
,{18,5,21},{1,10,19},{22,13,7},{20,15,23},{11,16,14},{2,17,8}
|
,{18,5,21},{1,10,19},{22,13,7},{20,15,23},{11,16,14},{2,17,8}
|
||||||
,{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,6},{3,5,9,12},{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},{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
|
||||||
,{20,23},{15,17,11,14},{2,16,8},{3,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";
|
||||||
@@ -30,6 +30,7 @@ public class Game {
|
|||||||
public int white_chips = 3;
|
public int white_chips = 3;
|
||||||
public int black_chips = 3;
|
public int black_chips = 3;
|
||||||
|
|
||||||
|
|
||||||
public int white_combos = 0;
|
public int white_combos = 0;
|
||||||
public int black_combos = 0;
|
public int black_combos = 0;
|
||||||
|
|
||||||
@@ -137,13 +138,13 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeMuehleButton(MuehleButton button) {
|
public void removeMuehleButton(MuehleButton button) {
|
||||||
for (int i = 0; i < buttons.size(); i++) {
|
for (int i = 0; i < buttons.size(); i++) {
|
||||||
if (buttons.get(i).id == button.id) {
|
if (buttons.get(i).id == button.id) {
|
||||||
//buttons.remove(i);
|
//buttons.remove(i);
|
||||||
button.destroy();
|
button.destroy();
|
||||||
} // end of if
|
} // end of if
|
||||||
} // end of for
|
} // end of for
|
||||||
}
|
}
|
||||||
public void addShape(Shape newShape) {
|
public void addShape(Shape newShape) {
|
||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
|
|
||||||
@@ -166,23 +167,23 @@ public class Game {
|
|||||||
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
|
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
|
||||||
if(current_selection == null) {
|
if(current_selection == null) {
|
||||||
current_selection = chip;
|
current_selection = chip;
|
||||||
drawAvaibleButtons(current_selection);
|
drawAvaibleMoves(current_selection);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
current_selection = chip;
|
current_selection = chip;
|
||||||
hideAllButtons();
|
hideAllButtons();
|
||||||
drawAvaibleButtons(current_selection);
|
drawAvaibleMoves(current_selection);
|
||||||
} // end of if-else
|
} // end of if-else
|
||||||
}
|
}
|
||||||
else if (currentTurnPlayer == "Black" && chip.color == Color.BLACK){
|
else if (currentTurnPlayer == "Black" && chip.color == Color.BLACK){
|
||||||
if(current_selection == null) {
|
if(current_selection == null) {
|
||||||
current_selection = chip;
|
current_selection = chip;
|
||||||
drawAvaibleButtons(current_selection);
|
drawAvaibleMoves(current_selection);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
current_selection = chip;
|
current_selection = chip;
|
||||||
hideAllButtons();
|
hideAllButtons();
|
||||||
drawAvaibleButtons(current_selection);
|
drawAvaibleMoves(current_selection);
|
||||||
}
|
}
|
||||||
} // end of if-else
|
} // end of if-else
|
||||||
|
|
||||||
@@ -192,10 +193,18 @@ public class Game {
|
|||||||
public void hideAllButtons() {
|
public void hideAllButtons() {
|
||||||
for (int i = 0; i < buttons.size(); i++) {
|
for (int i = 0; i < buttons.size(); i++) {
|
||||||
if (!buttons.get(i).isDestroyed) {
|
if (!buttons.get(i).isDestroyed) {
|
||||||
buttons.get(i).setActive(false);
|
buttons.get(i).setActive(false);
|
||||||
} // end of if
|
} // end of if
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void drawAvaibleMoves(Chip chip) {
|
||||||
|
if(getAmouuntOfColorChips(chip.color) > 3) {
|
||||||
|
drawAvaibleMoves(chip);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawAllAvaibleButtons(chip);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void drawAvaibleButtons(Chip chip) {
|
public void drawAvaibleButtons(Chip chip) {
|
||||||
ArrayList<MuehleButton> avaible_buttons = new ArrayList<MuehleButton>();
|
ArrayList<MuehleButton> avaible_buttons = new ArrayList<MuehleButton>();
|
||||||
for (int i = 0; i < close_chips[chip.id].length ;i++ ) {
|
for (int i = 0; i < close_chips[chip.id].length ;i++ ) {
|
||||||
@@ -219,6 +228,17 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawAllAvaibleButtons(Chip chip) {
|
||||||
|
//ArrayList<MuehleButton> avaible_buttons = new ArrayList<MuehleButton>();
|
||||||
|
|
||||||
|
for (int i = 0; i < buttons.size(); i++) {
|
||||||
|
if(isItTaken(buttons.get(i).id) == false) {
|
||||||
|
//avaible_buttons.add(buttons.get(i));
|
||||||
|
buttons.get(i).setActive(true);
|
||||||
|
}
|
||||||
|
} // end of for
|
||||||
|
}
|
||||||
|
|
||||||
public void removeChipTurn() {
|
public void removeChipTurn() {
|
||||||
if (white_combos > 0 || black_combos > 0) {
|
if (white_combos > 0 || black_combos > 0) {
|
||||||
if (white_combos > 0) {
|
if (white_combos > 0) {
|
||||||
@@ -243,7 +263,17 @@ public class Game {
|
|||||||
hideAllButtons();
|
hideAllButtons();
|
||||||
if (current_selection != null) {
|
if (current_selection != null) {
|
||||||
current_selection = null;
|
current_selection = null;
|
||||||
} // end of if
|
}
|
||||||
|
|
||||||
|
if(getAmouuntOfColorChips(Color.BLACK) == 2) {
|
||||||
|
setLabelText("White won!!!");
|
||||||
|
game_state = 4;
|
||||||
|
}
|
||||||
|
if(getAmouuntOfColorChips(Color.WHITE) == 2) {
|
||||||
|
setLabelText("Black won!!!");
|
||||||
|
game_state = 4;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game_state = 0;
|
game_state = 0;
|
||||||
@@ -352,4 +382,14 @@ public class Game {
|
|||||||
}
|
}
|
||||||
} // end of if-else
|
} // end of if-else
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAmouuntOfColorChips(Color color) {
|
||||||
|
int result = 0;
|
||||||
|
for (int i = 0; i < chips.size(); i++) {
|
||||||
|
if (chips.get(i).color == color) {
|
||||||
|
result++;
|
||||||
|
} // end of if
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user