From cf9cb03b1529f525eced8e734f9e5449f64fbd74 Mon Sep 17 00:00:00 2001 From: Julius Dewender Date: Sun, 31 Jan 2021 12:13:40 +0100 Subject: [PATCH] test farmer initial placement --- .../src/main/java/de/fd/fh/Game.java | 13 +++++++++--- .../src/test/java/de/fd/fh/GameTest.java | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/fh.fd.ci.client/src/main/java/de/fd/fh/Game.java b/fh.fd.ci.client/src/main/java/de/fd/fh/Game.java index f0bb2a1..6d5cf4b 100644 --- a/fh.fd.ci.client/src/main/java/de/fd/fh/Game.java +++ b/fh.fd.ci.client/src/main/java/de/fd/fh/Game.java @@ -17,15 +17,22 @@ public class Game for (int i = 0; i < Figure.fieldLength; i++) // row { if (i == Game.whiteRowOther - || i == Game.whiteRowFarmer - || i == Game.blackRowOther - || i == Game.blackRowFarmer) + || i == Game.blackRowOther) { for (int j = 0; j < Figure.fieldLength; j++) // col { mField[i * Figure.fieldLength + j] = new Figure(); } } + + if (i == Game.whiteRowFarmer + || i == Game.blackRowFarmer) + { + for (int j = 0; j < Figure.fieldLength; j++) // col + { + mField[i * Figure.fieldLength + j] = new FigureFarmer(); + } + } } } } diff --git a/fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java b/fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java index 4aab295..858efc2 100644 --- a/fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java +++ b/fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java @@ -41,4 +41,25 @@ class GameTest } } } + + @Test + void newGameInitializationFigurePositionsFarmer() + { + Game g = new Game(); + g.initNewGame(); + + // weiße Bauern + for (int j = 0; j < Figure.fieldLength; j++) // col + { + assertEquals(new FigureFarmer().getClass(), + g.mField[Game.whiteRowFarmer * Figure.fieldLength + j].getClass()); + } + + // schwarze Bauern + for (int j = 0; j < Figure.fieldLength; j++) // col + { + assertEquals(new FigureFarmer().getClass(), + g.mField[Game.blackRowFarmer * Figure.fieldLength + j].getClass()); + } + } } \ No newline at end of file