summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-10-28 21:41:13 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-10-28 21:41:13 +0100
commitd5fc1cb7f0b86835e0ca7500725bcef5ab0790d4 (patch)
treefd950ab29196e7ffe720bfb03adf46810367d558
parentc3f5a513f7bc3300f42be349f11d4444c3039cbd (diff)
downloadRustAndDust-d5fc1cb7f0b86835e0ca7500725bcef5ab0790d4.zip
RustAndDust-d5fc1cb7f0b86835e0ca7500725bcef5ab0790d4.tar.gz
SearchBoard: isFlankAttack takes care of border case where los goes between 2 hexes
-rw-r--r--core/src/ch/asynk/rustanddust/engine/SearchBoard.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
index 1d8ed88..9ca9f5d 100644
--- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
+++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
@@ -356,10 +356,17 @@ public class SearchBoard
private boolean isFlankAttack(int angle, List<Node> los)
{
+ Node before = los.get(los.size() - 3);
Node from = los.get(los.size() - 2);
Node to = los.get(los.size() - 1);
+ boolean special = (distance(from, to) == distance(before, to));
+
Orientation o = Orientation.fromMove(to.col, to.row, from.col, from.row);
- return o.isInSides(angle);
+ if (!special)
+ return o.isInSides(angle);
+
+ Orientation o2 = Orientation.fromMove(to.col, to.row, before.col, before.row);
+ return (o.isInSides(angle) && o2.isInSides(angle));
}
private boolean isClearAttack(Tile from, List<Node> los)