From 05c76772de7db306cab01eebb248810665547504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jul 2020 16:16:28 +0200 Subject: HexBoard : fix diagonal los with out of board tiles --- core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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))); -- cgit v1.1-2-g2b99