diff --git a/src/de/itsblue/ConnectFour/GameBoard.java b/src/de/itsblue/ConnectFour/GameBoard.java
index 1ec292e..54490b9 100644
--- a/src/de/itsblue/ConnectFour/GameBoard.java
+++ b/src/de/itsblue/ConnectFour/GameBoard.java
@@ -97,7 +97,7 @@ public class GameBoard extends JPanel {
// if the container is empty -> add the plate
this.BoardContainers[column][i].insertPlate(plate);
- PlateType winCheckResult = this.checkContainerForWin(column, i);
+ PlateType winCheckResult = this.checkForWin();
if (winCheckResult == null)
return "ok";
@@ -162,6 +162,25 @@ public class GameBoard extends JPanel {
return containerSize;
}
+ /**
+ * Function to check if there is a chain of at least four plates of the same
+ * color anywhere on the board
+ *
+ * @return null
if there was no matching chain; otherwise the
+ * PlateType of the chain that was found
+ */
+ public PlateType checkForWin() {
+ for (int c = 0; c < this.boardColumns; c++) {
+ for (int r = 0; r < this.boardRows; r++) {
+ PlateType res = this.checkContainerForWin(c, r);
+ if (res != null)
+ return res;
+ }
+ }
+
+ return null;
+ }
+
/**
* Function to check if a certain container is the beginning of a four plate log
* chain of plates of the same type what would indicate the end of the game. If
@@ -169,8 +188,8 @@ public class GameBoard extends JPanel {
*
* @param c column of the container to check
* @param r row of the container to check
- * @return null
if there was no matching chain or the PlateType of
- * the chain
+ * @return null
if there was no matching chain; otherwise the
+ * PlateType of the chain that was found
*/
public PlateType checkContainerForWin(int c, int r) {