From 2db113544738f24969dbc0423d33b9cc8b6ef087 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 2 May 2022 13:21:31 -0400 Subject: [PATCH] Only allow unit actions if adjacent to that unit --- .../redstrate/watersymbol/screens/GameScreen.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/com/redstrate/watersymbol/screens/GameScreen.java b/core/src/com/redstrate/watersymbol/screens/GameScreen.java index c88f2a4..f0d1132 100644 --- a/core/src/com/redstrate/watersymbol/screens/GameScreen.java +++ b/core/src/com/redstrate/watersymbol/screens/GameScreen.java @@ -194,12 +194,14 @@ public class GameScreen implements Screen { for(Unit unit : units) { if(unit.positionX == x && unit.positionY == y) { - if(unit.team != currentUnit.team) { - actions.add(new AttackAction(currentUnit, unit)); - } else { - // you can't trade with yourself! - if(unit != currentUnit) { - actions.add(new TradeAction()); + if(isAdjacent(currentUnit, unit)) { + if (unit.team != currentUnit.team) { + actions.add(new AttackAction(currentUnit, unit)); + } else { + // you can't trade with yourself! + if (unit != currentUnit) { + actions.add(new TradeAction()); + } } } }