summaryrefslogtreecommitdiffstats
path: root/core/test/ch/asynk/tankontank/LineOfSightTest.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-01 10:45:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-01 10:45:06 +0200
commit048f714663da82a70dc7423881daf7b9195a32d9 (patch)
tree803977db34d773c7b492a291624bee647dc755fa /core/test/ch/asynk/tankontank/LineOfSightTest.java
parent46b0fbb938636ed24ac93ffc4a07db2d515541ce (diff)
downloadRustAndDust-048f714663da82a70dc7423881daf7b9195a32d9.zip
RustAndDust-048f714663da82a70dc7423881daf7b9195a32d9.tar.gz
FakeBoard and FakeTile go into test/../Helpers
Diffstat (limited to 'core/test/ch/asynk/tankontank/LineOfSightTest.java')
-rw-r--r--core/test/ch/asynk/tankontank/LineOfSightTest.java61
1 files changed, 1 insertions, 60 deletions
diff --git a/core/test/ch/asynk/tankontank/LineOfSightTest.java b/core/test/ch/asynk/tankontank/LineOfSightTest.java
index 8c15908..2f901af 100644
--- a/core/test/ch/asynk/tankontank/LineOfSightTest.java
+++ b/core/test/ch/asynk/tankontank/LineOfSightTest.java
@@ -13,65 +13,6 @@ import ch.asynk.tankontank.engine.SearchBoard.Node;
import static org.junit.Assert.assertTrue;
-class FakeTile extends Tile
-{
- public boolean offMap;
-
- public FakeTile()
- {
- super();
- offMap = false;
- }
-
- public FakeTile(boolean offMap)
- {
- this.offMap = offMap;
- }
-
- public boolean isOffMap()
- {
- return offMap;
- }
- public boolean blockLineOfSightFrom(Tile from) { return false; }
- public boolean atLeastOneMove(Pawn pawn) { return true; }
- public boolean road(Board.Orientation side) { return false; }
- public int costFrom(Pawn pawn, Board.Orientation side, boolean road) { return 1; }
- public boolean hasTargetsFor(Pawn pawn) { return false; }
-}
-
-class FakeBoard extends Board
-{
- private int cols;
- private int rows;
- public FakeTile fakeTiles[];
-
- public FakeBoard(int cols, int rows)
- {
- super();
- this.cols = cols;
- this.rows = rows;
- fakeTiles = new FakeTile[cols * rows];
- for (int i = 0; i < rows; i++) {
- for ( int j = 0; j < cols; j ++)
- fakeTiles[j + (i * cols)] = new FakeTile();
- }
- fakeTiles[19].offMap = true;
- fakeTiles[39].offMap = true;
- fakeTiles[59].offMap = true;
- fakeTiles[79].offMap = true;
- }
-
- @Override
- public Tile getTile(int col, int row)
- {
- int colOffset = ((row + 1) / 2);
- if ((col < colOffset) || (row < 0) || (row >= rows) || ((col - colOffset) >= cols))
- return new FakeTile(true);;
- int idx = ((col - colOffset)) + (row * cols);
- return fakeTiles[idx];
- }
-}
-
public class LineOfSightTest
{
private SearchBoard sb;
@@ -81,7 +22,7 @@ public class LineOfSightTest
{
int cols = 10;
int rows = 9;
- FakeBoard fakeBoard = new FakeBoard(cols, rows);
+ Helpers.FakeBoard fakeBoard = new Helpers.FakeBoard(cols, rows);
sb = new SearchBoard(fakeBoard, cols, rows);
}