Browse Source

4gewinnt: updateGui Method created and added to playChip

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
76a32694c0
  1. 17
      src/main/java/de/tims/viergewinnt/ai/Logic.java

17
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -17,7 +17,10 @@ public class Logic {
int currentPlayer;
public int playChip(int[][] playfield, int column, int player) {
//add board update
//updateGui(playfield);
testForWin(playfield, player);
currentPlayer = (player % 2) + 1;
return 0;
@ -54,6 +57,20 @@ public class Logic {
return contentPanel;
}
public void updateGui(int[][] playfield) {
for(int i = 0; i < playfield.length; i++) {
for(int j = 0; j < playfield[i].length; j++) {
if(playfield[i][j] == 0) {
gamefield[j + 6 * i].setBackground(Color.white);
} else if(playfield[i][j] == 1) {
gamefield[j + 6 * i].setBackground(Color.red);
} else {
gamefield[j + 6 * i].setBackground(Color.yellow);
}
}
}
}
class ButtonListener implements ActionListener {
@Override

Loading…
Cancel
Save