diff --git a/cicaprojekt/Dungeon.java b/cicaprojekt/Dungeon.java index 8e4e7ab..4bff975 100644 --- a/cicaprojekt/Dungeon.java +++ b/cicaprojekt/Dungeon.java @@ -193,6 +193,10 @@ public class Dungeon { return ZPMsToWin; } + public void setZPMsToWin(int newvalue) { + this.ZPMsToWin = newvalue; + } + public long getTimeLimit() { return timeLimit; } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index dfa21bc..b0da708 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -21,6 +21,30 @@ public class Game { private Game() {} + public void playerBaseDestroyed(PlayerBase caller) { + Field field = new Field(); + Tile callertile = caller.getCurrentTile(); + + 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.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); + + Game.instance.updateDisplay(); + } + + public void playerDestroyed(Player caller) { + dungeon.setZPMsToWin(dungeon.getZPMsToWin() - caller.getZPMCount()); + Game.instance.updateDisplay(); + } + public void setDungeon(Dungeon dungeon) { this.dungeon = dungeon; } diff --git a/cicaprojekt/Player.java b/cicaprojekt/Player.java index a135002..8218ecf 100644 --- a/cicaprojekt/Player.java +++ b/cicaprojekt/Player.java @@ -12,6 +12,7 @@ public class Player extends PlayerBase { destroyed = true; if(hasBox()) boxLifted.destroy(); + Game.instance.playerDestroyed(this); } public Player(String name, Tile startTile, Direction startDirection) { diff --git a/cicaprojekt/PlayerBase.java b/cicaprojekt/PlayerBase.java index 892a2cf..0d1cd49 100644 --- a/cicaprojekt/PlayerBase.java +++ b/cicaprojekt/PlayerBase.java @@ -20,6 +20,7 @@ public class PlayerBase implements Destroyable { public void destroy() { destroyed = true; + Game.instance.playerBaseDestroyed(this); } public Tile getCurrentTile() { diff --git a/mastertest.dungeon b/mastertest.dungeon index 81f2c28..4cb11ad 100644 --- a/mastertest.dungeon +++ b/mastertest.dungeon @@ -2,8 +2,8 @@ 150 W W W W W -W F F F W -W F O F W +W R W F W +W X O F W W F F Z W W W W W W