From a6ed74febe5e7c294881e74b94b539c0a1a689e3 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Wed, 2 Feb 2022 15:05:40 +0100 Subject: [PATCH] 4gewinnt: updated playChip method and tests --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 6 ++---- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 4aba921..123202a 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -71,12 +71,10 @@ public class Logic { } public int playChip(int column) { - - //add board update - + setField(getCurrentPlayer(), getFreePlace(column), column); updateGui(); if(testForWin()) { - calcScore(); + gameover(); } setCurrentPlayer((getCurrentPlayer() % 2) + 1); return 0; diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 02d6719..76ff279 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -44,7 +44,7 @@ class LogicTest { int realResult = testObj.playChip(column); - assertEquals(expectedResult, realResult); + assertEquals(expectedResult == realResult, 1 == testObj.getField(5, 0)); } @Test