summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-07-08 16:16:28 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-07-08 16:16:28 +0200
commit05c76772de7db306cab01eebb248810665547504 (patch)
tree17a77ad427f24f1ee22770736fb2e357089593f8
parentd7013cbbb335c2a70fd6f48a30d0c48b050f4c43 (diff)
downloadgdx-boardgame-05c76772de7db306cab01eebb248810665547504.zip
gdx-boardgame-05c76772de7db306cab01eebb248810665547504.tar.gz
HexBoard : fix diagonal los with out of board tiles
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
index 8059362..b6e342c 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
@@ -368,6 +368,7 @@ public class HexBoard implements Board
boolean contact = false;
boolean losBlocked = false;
while ((x != x1) || (y != y1)) {
+ int idx = 4;
if (flat)
y += dy; // up left
@@ -381,6 +382,7 @@ public class HexBoard implements Board
blocked |= 0x01;
} else {
blocked |= 0x01;
+ idx = 3;
}
if (flat)
@@ -397,6 +399,7 @@ public class HexBoard implements Board
blocked |= 0x02;
} else {
blocked |= 0x02;
+ idx = 3;
}
if (flat)
@@ -411,7 +414,7 @@ public class HexBoard implements Board
if (!losBlocked && blocked == 0x03)
computeContact(from, to, o, t, v, false);
else
- computeContact(from, to, o.opposite(), tiles.get(tiles.size() - 4), v, false);
+ computeContact(from, to, o.opposite(), tiles.get(tiles.size() - idx), v, false);
contact = true;
}
losBlocked = (t.blocked || t.blockLos(from, to, d, distance(x0, y0, x, y, Board.Geometry.EUCLIDEAN)));