From 6495a1d83bbd409930fe6b80eeb4164c6299694d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 7 Jul 2020 22:40:54 +0200 Subject: HexBoard : simplify computeOrientation() --- .../ch/asynk/gdx/boardgame/boards/HexBoard.java | 32 ++++++---------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index 7ea7bad..19a5306 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -434,30 +434,16 @@ public class HexBoard implements Board else return (dx == 1 ? Orientation.NE : Orientation.SW); } - if (vertical) { - if (dx == 1) { - if (dy == 1) - return Orientation.NE; - else - return Orientation.SE; - } else { - if (dy == 1) - return Orientation.NW; - else - return Orientation.SW; - } + if (dx == 1) { + if (dy == 1) + return (vertical ? Orientation.NE : Orientation.E); + else + return (vertical ? Orientation.SE : Orientation.SE); } else { - if (dx == 1) { - if (dy == 1) - return Orientation.E; - else - return Orientation.SE; - } else { - if (dy == 1) - return Orientation.NW; - else - return Orientation.W; - } + if (dy == 1) + return (vertical ? Orientation.NW : Orientation.NW); + else + return (vertical ? Orientation.SW : Orientation.W); } } -- cgit v1.1-2-g2b99