Browse Source

test initial white farmer move

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

15
fh.fd.ci.client/src/main/java/de/fd/fh/Game.java

@ -36,4 +36,19 @@ public class Game
}
}
}
boolean moveFigure(int src, int dst)
{
Figure f = mField[src];
if (!f.moveAllowed(src, dst, mField))
{
return false;
}
mField[dst] = f;
mField[src] = null;
return true;
}
}

20
fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java

@ -66,4 +66,24 @@ class GameTest
g.mField[Game.blackRowFarmer * Figure.fieldLength + j]);
}
}
@Test
void moveFarmerWhite() // weißer Bauer ganz links um ein Feld noch vorne bewegen
{
Game g = new Game();
g.initNewGame();
// zu bewegende Figur
Figure f = g.mField[Game.whiteRowFarmer * 8 + 0];
// Ziel sollte leer sein
assertNull(g.mField[(Game.whiteRowFarmer - 1) * 8 + 0]);
// Figur bewegen
assertTrue(g.moveFigure(Game.whiteRowFarmer * 8 + 0, (Game.whiteRowFarmer - 1) * 8 + 0));
// Figur sollte nun verschoben sein
assertNull(g.mField[Game.whiteRowFarmer * 8 + 0]);
assertSame(f, g.mField[(Game.whiteRowFarmer - 1) * 8 + 0]);
}
}
Loading…
Cancel
Save