summaryrefslogtreecommitdiffstats
path: root/core/test/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-10-30 22:53:39 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-10-30 22:53:39 +0100
commitaab970b43a20cdb4ddab4ab2f13173e7f615a896 (patch)
treecf92e204c28d4bb61fd58b940ad7bbeb8ccf7e23 /core/test/ch/asynk
parent95f7198f5a8c7ec18a62ead32d58b61ed1625669 (diff)
downloadRustAndDust-aab970b43a20cdb4ddab4ab2f13173e7f615a896.zip
RustAndDust-aab970b43a20cdb4ddab4ab2f13173e7f615a896.tar.gz
tests: add isFlankAttack() checks
Diffstat (limited to 'core/test/ch/asynk')
-rw-r--r--core/test/ch/asynk/rustanddust/Attacks.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/test/ch/asynk/rustanddust/Attacks.java b/core/test/ch/asynk/rustanddust/Attacks.java
index 4130615..4cfa596 100644
--- a/core/test/ch/asynk/rustanddust/Attacks.java
+++ b/core/test/ch/asynk/rustanddust/Attacks.java
@@ -111,4 +111,32 @@ public class Attacks
setPawn(target, sb.get(5, 2), Orientation.NORTH);
sb.possibleTargetsFrom(shooter, targets);
}
+
+ private void checkFlank(int col, int row, Orientation o, boolean isFlank)
+ {
+ setPawn(target, sb.get(col, row), o);
+ assertTrue(sb.canAttack(target, shooter, true));
+ assertTrue(target.isFlankAttack() == isFlank);
+ }
+
+ @Test public void test_4() {
+ checkFlank(9, 4, Orientation.SOUTH, false);
+ checkFlank(9, 5, Orientation.SOUTH, false);
+ checkFlank(9, 6, Orientation.SOUTH, false);
+ checkFlank(9, 7, Orientation.SOUTH, false);
+ checkFlank(8, 7, Orientation.SOUTH, false);
+ checkFlank(7, 7, Orientation.SOUTH_EAST, true);
+ checkFlank(6, 7, Orientation.SOUTH_EAST, true);
+ checkFlank(5, 6, Orientation.SOUTH_EAST, true);
+ checkFlank(4, 5, Orientation.NORTH, true);
+ checkFlank(3, 4, Orientation.NORTH, true);
+ checkFlank(3, 3, Orientation.NORTH, true);
+ checkFlank(3, 2, Orientation.NORTH, true);
+ checkFlank(3, 1, Orientation.NORTH, true);
+ checkFlank(4, 1, Orientation.NORTH, true);
+ checkFlank(5, 1, Orientation.SOUTH_WEST, false);
+ checkFlank(6, 1, Orientation.SOUTH_WEST, false);
+ checkFlank(7, 2, Orientation.SOUTH_WEST, false);
+ checkFlank(8, 3, Orientation.SOUTH_WEST, false);
+ }
}