pre-final
This commit is contained in:
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}
|
||||
};
|
||||
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
|
||||
,{22,15}
|
||||
};
|
||||
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 white_chips = 3;
|
||||
public int black_chips = 3;
|
||||
public int white_chips = 9;
|
||||
public int black_chips = 9;
|
||||
|
||||
|
||||
public int white_combos = 0;
|
||||
@@ -57,13 +57,13 @@ public class Game {
|
||||
if (game_state == 0) {
|
||||
Chip newChip;
|
||||
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--;
|
||||
setChipCount(white_chips,"White");
|
||||
|
||||
}
|
||||
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--;
|
||||
setChipCount(white_chips,"Black");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class Game {
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
//buttons.remove(target);
|
||||
@@ -118,8 +118,8 @@ public class Game {
|
||||
checkCombo(newChip);
|
||||
removeChipTurn();
|
||||
}
|
||||
public Chip addChip(int id,int relX, int relY,double absX, double absY, Color color) {
|
||||
Chip chip = new Chip(id,relX,relY,absX,absY,color,this);
|
||||
public Chip addChip(int id,double absX, double absY, Color color) {
|
||||
Chip chip = new Chip(id,absX,absY,color,this);
|
||||
chips.add(chip);
|
||||
addShape(chip.getShape());
|
||||
return chip;
|
||||
@@ -151,17 +151,6 @@ public class Game {
|
||||
}
|
||||
public void chip_clicked(Chip chip) {
|
||||
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(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() {
|
||||
for (int i = 0; i < buttons.size(); i++) {
|
||||
@@ -199,7 +203,7 @@ public class Game {
|
||||
}
|
||||
public void drawAvaibleMoves(Chip chip) {
|
||||
if(getAmouuntOfColorChips(chip.color) > 3) {
|
||||
drawAvaibleMoves(chip);
|
||||
drawAvaibleButtons(chip);
|
||||
}
|
||||
else {
|
||||
drawAllAvaibleButtons(chip);
|
||||
@@ -241,6 +245,7 @@ public class Game {
|
||||
|
||||
public void removeChipTurn() {
|
||||
if (white_combos > 0 || black_combos > 0) {
|
||||
hideAllButtons();
|
||||
if (white_combos > 0) {
|
||||
setLabelText("White, You can remove "+ white_combos + " Black Pieces");
|
||||
game_state = 2;
|
||||
|
||||
Reference in New Issue
Block a user