From d5fc1cb7f0b86835e0ca7500725bcef5ab0790d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 28 Oct 2015 21:41:13 +0100 Subject: SearchBoard: isFlankAttack takes care of border case where los goes between 2 hexes --- core/src/ch/asynk/rustanddust/engine/SearchBoard.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 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 los) -- cgit v1.1-2-g2b99