Browse Source

test farmer initial placement

feat-figureMovement
JD 4 years ago
parent
commit
cf9cb03b15
  1. 13
      fh.fd.ci.client/src/main/java/de/fd/fh/Game.java
  2. 21
      fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java

13
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 for (int i = 0; i < Figure.fieldLength; i++) // row
{ {
if (i == Game.whiteRowOther 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 for (int j = 0; j < Figure.fieldLength; j++) // col
{ {
mField[i * Figure.fieldLength + j] = new Figure(); 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();
}
}
} }
} }
} }

21
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());
}
}
} }
Loading…
Cancel
Save