Release v1.1

This commit is contained in:
Koen Yskout
2018-03-07 15:25:58 +01:00
parent 91bd11d444
commit 6aa12c7a1e

View File

@@ -5,6 +5,7 @@ import worms.internal.gui.GUIUtils;
import worms.internal.gui.game.PlayGameScreen; import worms.internal.gui.game.PlayGameScreen;
import worms.internal.gui.messages.MessageType; import worms.internal.gui.messages.MessageType;
import worms.model.Worm; import worms.model.Worm;
import worms.util.ModelException;
public class Turn extends InstantaneousCommand { public class Turn extends InstantaneousCommand {
private final Worm worm; private final Worm worm;
@@ -20,17 +21,20 @@ public class Turn extends InstantaneousCommand {
protected boolean canStart() { protected boolean canStart() {
return worm != null; return worm != null;
} }
@Override @Override
protected void afterExecutionCancelled() { protected void afterExecutionCancelled() {
getScreen().addMessage("This worm cannot perform that turn :(", getScreen().addMessage("This worm cannot perform that turn :(", MessageType.ERROR);
MessageType.ERROR);
} }
@Override @Override
protected void doStartExecution() { protected void doStartExecution() {
double direction = getFacade().getOrientation(worm); try {
double angleToTurn = GUIUtils.restrictDirection(direction + angle) - direction; double direction = getFacade().getOrientation(worm);
getFacade().turn(worm, angleToTurn); double angleToTurn = GUIUtils.restrictDirection(direction + angle) - direction;
getFacade().turn(worm, angleToTurn);
} catch (ModelException e) {
cancelExecution();
}
} }
} }