diff --git a/OGP1718-Worms/src/worms/facade/Facade.java b/OGP1718-Worms/src/worms/facade/Facade.java index 752d34e..4c8b9ed 100644 --- a/OGP1718-Worms/src/worms/facade/Facade.java +++ b/OGP1718-Worms/src/worms/facade/Facade.java @@ -120,7 +120,7 @@ public class Facade implements IFacade { */ @Override public boolean canFall(Worm worm) throws MustNotImplementException { - return false; + return worm.canFall(); } /** diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 658ecc3..b71406f 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -832,14 +832,14 @@ public class Worm extends GameObject { double[] center = {getLocation().getX(), getLocation().getY()}; Coordinate oldLocation = getLocation(); double endY = getLocation().getY(); - if (! getWorld().isAdjacent(center, minRadius)) { + if (canFall()) { for (double y = oldLocation.getY(); y <= (getWorld().getHeight() + 1); y--) { if (y >= (getWorld().getHeight() + 1)) { terminate(); } double[] newLoc = {oldLocation.getX(), y}; setLocation(newLoc); - if (getWorld().isAdjacent(center, minRadius)) { + if (! canFall()) { endY = y; break; } @@ -851,6 +851,11 @@ public class Worm extends GameObject { decreaseHitPoints(cost); } + public boolean canFall() { + double[] center = {getLocation().getX(), getLocation().getY()}; + return ! getWorld().isAdjacent(center, minRadius); + } + public void collisionFall(Worm fallingWorm, Worm... worm) { for (Worm stationaryWorm: worm) { long value = stationaryWorm.getHitPoints()/2;