diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index f98d246..0890761 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -22,27 +22,29 @@ public class Game { private Game() {} public void playerBaseDestroyed(PlayerBase caller) { - Field field = new Field(); - Tile callertile = caller.getCurrentTile(); + if (caller.getCurrentTile().isGap()) { + Field field = new Field(); + Tile callertile = caller.getCurrentTile(); - field.setX(callertile.getX()); - field.setY(callertile.getY()); + field.setX(callertile.getX()); + field.setY(callertile.getY()); - field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.NORTH), Direction.NORTH); - callertile.getAdjacentTile(Direction.NORTH).setAdajacentTile(field, Direction.SOUTH); + field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.NORTH), Direction.NORTH); + callertile.getAdjacentTile(Direction.NORTH).setAdajacentTile(field, Direction.SOUTH); - field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.SOUTH), Direction.SOUTH); - callertile.getAdjacentTile(Direction.SOUTH).setAdajacentTile(field, Direction.NORTH); + field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.SOUTH), Direction.SOUTH); + callertile.getAdjacentTile(Direction.SOUTH).setAdajacentTile(field, Direction.NORTH); - field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.WEST), Direction.WEST); - callertile.getAdjacentTile(Direction.WEST).setAdajacentTile(field, Direction.EAST); + field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.WEST), Direction.WEST); + callertile.getAdjacentTile(Direction.WEST).setAdajacentTile(field, Direction.EAST); - field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.EAST), Direction.EAST); - callertile.getAdjacentTile(Direction.EAST).setAdajacentTile(field, Direction.WEST); + field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.EAST), Direction.EAST); + callertile.getAdjacentTile(Direction.EAST).setAdajacentTile(field, Direction.WEST); - display.gapMagic((Gap)callertile, field, dungeon.getMapWidth()); + display.gapMagic((Gap) callertile, field, dungeon.getMapWidth()); - Game.instance.updateDisplay(); + Game.instance.updateDisplay(); + } } public void playerDestroyed(Player caller) { diff --git a/cicaprojekt/Gap.java b/cicaprojekt/Gap.java index 9e3e4b2..6df4004 100644 --- a/cicaprojekt/Gap.java +++ b/cicaprojekt/Gap.java @@ -11,6 +11,12 @@ public class Gap extends cicaprojekt.Tile { return true; } + @Override + public boolean isGap() + { + return true; + } + @Override public void onEntry(PlayerBase playerBase) { super.onEntry(playerBase); diff --git a/cicaprojekt/Tile.java b/cicaprojekt/Tile.java index ebf301e..49ba604 100644 --- a/cicaprojekt/Tile.java +++ b/cicaprojekt/Tile.java @@ -65,6 +65,10 @@ public abstract class Tile { return zpm; } + public boolean isGap() { + return false; + } + public void putABox(Box box) { if (box == null) return;