From 6aa12c7a1ed16603dbfa650084682133111be41b Mon Sep 17 00:00:00 2001 From: Koen Yskout Date: Wed, 7 Mar 2018 15:25:58 +0100 Subject: [PATCH] Release v1.1 --- .../worms/internal/gui/game/commands/Turn.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/Turn.java b/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/Turn.java index e5c21fd..cb9dcb9 100644 --- a/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/Turn.java +++ b/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/Turn.java @@ -5,6 +5,7 @@ import worms.internal.gui.GUIUtils; import worms.internal.gui.game.PlayGameScreen; import worms.internal.gui.messages.MessageType; import worms.model.Worm; +import worms.util.ModelException; public class Turn extends InstantaneousCommand { private final Worm worm; @@ -20,17 +21,20 @@ public class Turn extends InstantaneousCommand { protected boolean canStart() { return worm != null; } - + @Override protected void afterExecutionCancelled() { - getScreen().addMessage("This worm cannot perform that turn :(", - MessageType.ERROR); + getScreen().addMessage("This worm cannot perform that turn :(", MessageType.ERROR); } - + @Override protected void doStartExecution() { - double direction = getFacade().getOrientation(worm); - double angleToTurn = GUIUtils.restrictDirection(direction + angle) - direction; - getFacade().turn(worm, angleToTurn); + try { + double direction = getFacade().getOrientation(worm); + double angleToTurn = GUIUtils.restrictDirection(direction + angle) - direction; + getFacade().turn(worm, angleToTurn); + } catch (ModelException e) { + cancelExecution(); + } } } \ No newline at end of file