From 68253e7a5b3395883d61f8c0d8743114d661ce7a Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 14 May 2016 22:37:43 +0200 Subject: [PATCH] A ZPM is generated after every 2 picked up ZPMs. --- cicaprojekt/Field.java | 5 +++++ cicaprojekt/Game.java | 24 ++++++++++++++++++++++++ cicaprojekt/Player.java | 1 + cicaprojekt/Tile.java | 4 ++++ 4 files changed, 34 insertions(+) diff --git a/cicaprojekt/Field.java b/cicaprojekt/Field.java index 4c85364..18a1100 100644 --- a/cicaprojekt/Field.java +++ b/cicaprojekt/Field.java @@ -22,4 +22,9 @@ public class Field extends cicaprojekt.Tile { @Override public void onExit(PlayerBase playerBase) {} + + @Override + public boolean canHazZPM() { + return true; + } } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 11b3087..443c583 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -195,4 +195,28 @@ public class Game { stopGame(GameoverCause.JAFFAWON); } } + + public void generateZPM() { + int temp = jaffa.getZPMCount() + oneill.getZPMCount(); + System.out.println(temp); + if(((jaffa.getZPMCount() + oneill.getZPMCount()) % 2) == 0) { + System.out.println("cica"); + Tile source = oneill.getCurrentTile(); + Tile compare; + for (int i = 0; i < dungeon.getMapHeight() * dungeon.getMapWidth(); i++) { + compare = source.getAdjacentTile(Direction.getRandom()); + if (compare != null) + source = compare; + } + + while (!source.canHazZPM() && !source.hasZPM() && (source.playerBaseOnTile != null)) { + compare = source.getAdjacentTile(Direction.getRandom()); + if (compare != null) + source = compare; + } + System.out.println(source.getX() + " " + source.getY()); + + source.setZPMOnTile(new ZPM()); + } + } } diff --git a/cicaprojekt/Player.java b/cicaprojekt/Player.java index 355e9f0..e6e5d86 100644 --- a/cicaprojekt/Player.java +++ b/cicaprojekt/Player.java @@ -42,6 +42,7 @@ public class Player extends PlayerBase { @Override public void pickZPM(Tile tile) { zpmContainer.add(tile.getZPMFromTile()); + Game.instance.generateZPM(); } public void shootStargate(Stargate stargate) { diff --git a/cicaprojekt/Tile.java b/cicaprojekt/Tile.java index 05c5c71..e990348 100644 --- a/cicaprojekt/Tile.java +++ b/cicaprojekt/Tile.java @@ -97,4 +97,8 @@ public abstract class Tile { public boolean boxPermission() { return true; } + + public boolean canHazZPM() { + return false; + } }