From 76a32694c0717c4b2f348f4c7cc945ca7999fc06 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 10 Jan 2022 20:03:51 +0100 Subject: [PATCH] 4gewinnt: updateGui Method created and added to playChip --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 56707b5..59104a3 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/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