diff --git a/OGP1718-Worms/src/worms/facade/Facade.java b/OGP1718-Worms/src/worms/facade/Facade.java index 13d63c7..48a8898 100644 --- a/OGP1718-Worms/src/worms/facade/Facade.java +++ b/OGP1718-Worms/src/worms/facade/Facade.java @@ -2,10 +2,12 @@ package worms.facade; import worms.model.Food; import worms.model.Team; +import worms.model.World; import worms.model.Worm; import worms.util.IllegalNameException; import worms.util.ModelException; import worms.util.Coordinate; +import worms.util.MustNotImplementException; import java.math.BigInteger; import java.util.Collection; @@ -794,4 +796,86 @@ public class Facade implements IFacade { public double getMass(Worm worm) throws ModelException { return worm.getMass(); } + + /** + * Create a new team for the given world with given name and with no members yet. + */ + @Override + public Team createTeam(World world, String name) throws ModelException, MustNotImplementException { + return null; + } + + /** + * Terminate the given team. + */ + @Override + public void terminate(Team team) throws ModelException, MustNotImplementException { + + } + + /** + * Check whether the given portion of food is terminated. + */ + @Override + public boolean isTerminated(Team team) throws ModelException, MustNotImplementException { + return false; + } + + /** + * Return the name of the given team. + */ + @Override + public String getName(Team team) throws ModelException, MustNotImplementException { + return null; + } + + /** + * Return the team to which this worm belongs. + */ + @Override + public Team getTeam(Worm worm) throws ModelException { + return null; + } + + /** + * Return the number of worms in the given team. + */ + @Override + public int getNbWormsOfTeam(Team team) throws ModelException, MustNotImplementException { + return 0; + } + + /** + * Return a list of all the worms in the given team, sorted alphabetically. + * This method must run in linear time. + */ + @Override + public List getAllWormsOfTeam(Team team) throws ModelException, MustNotImplementException { + return null; + } + + /** + * Add the given worms to the given team.] + */ + @Override + public void addWormsToTeam(Team team, Worm... worms) throws ModelException, MustNotImplementException { + + } + + /** + * Remove the given worms from the given team. + */ + @Override + public void removeWormsFromTeam(Team team, Worm... worms) throws ModelException, MustNotImplementException { + + } + + /** + * Merge the given teams. + * - All the worms of the supplying team are transferred to the receiving team. + */ + @Override + public void mergeTeams(Team recevingTeam, Team supplyingTeam) throws ModelException, MustNotImplementException { + + } } diff --git a/OGP1718-Worms/src/worms/facade/World.java b/OGP1718-Worms/src/worms/facade/World.java deleted file mode 100644 index 40a587d..0000000 --- a/OGP1718-Worms/src/worms/facade/World.java +++ /dev/null @@ -1,4 +0,0 @@ -package worms.facade; - -public class World { -} diff --git a/OGP1718-Worms/src/worms/model/World.java b/OGP1718-Worms/src/worms/model/World.java new file mode 100644 index 0000000..d56a08f --- /dev/null +++ b/OGP1718-Worms/src/worms/model/World.java @@ -0,0 +1,76 @@ +package worms.model; + +import java.util.ArrayList; + +public class World { + + private boolean terminated = false; + + + public World(double width, double height, boolean[][] map) { + + if (!isValidDimension(width) || !isValidDimension(height)) throw new IllegalArgumentException(); + + this.width = width; + this.height = height; + this.map = map; + } + + + + // region Dimensions + //=================================================================================== + + public static boolean isValidDimension(double dimension) { + return dimension >= 0.0 && dimension <= Double.MAX_VALUE; + } + + public double getWidth() { + return width; + } + public double getHeight() { + return height; + } + private final double width; + private final double height; + + // =================================================================================== + // endregion + + // region map + //=================================================================================== + + public boolean[][] getMap() { + return map; + } + + public boolean isPassable(double[] location) { + + if (location[0] >= getMap()[0].length || location[0] < 0.0 || + location[1] >= getMap().length || location[1] < 0.0) { + return true; + } + return this.map[(int) Math.round(location[0])][(int) Math.round(location[1])]; + } + + public boolean isPassable(double[] center, double radius) { + return false; + } + + public boolean isTerminated() { + return terminated; + } + + public void terminate() { + setTerminated(true); + } + + private final boolean[][] map; + + private void setTerminated(boolean terminated) { + this.terminated = terminated; + } + + // =================================================================================== + // endregion +} diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 56b3971..5d794f6 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -597,8 +597,8 @@ public class Worm { long total = 1 + (new Random().nextLong() * (10 - 1)); long loseSmallest = (long) (total / (largestWorm.getOrientation() / (smallestWorm.getOrientation() + largestWorm.getOrientation()))); long loseLargest = total - loseSmallest; - smallestWorm.decreaseHitPoints(loseSmallest); - largestWorm.decreaseHitPoints(loseLargest); + smallestWorm.incrementHitPoints(loseSmallest); + largestWorm.incrementHitPoints(loseLargest); } //=================================================================================== @@ -771,7 +771,7 @@ public class Worm { // region hitPoints //=================================================================================== - + @Basic @Raw public long getHitPoints() { return this.hitPoints; @@ -780,13 +780,13 @@ public class Worm { @Raw private void setHitPoints(long hitPoints) { if (hitPoints <= 0) - //TODO worm sterft + weghalen van gamewereld + // TODO worm sterft + weghalen van gamewereld this.hitPoints = hitPoints; } private long hitPoints; - public void decreaseHitPoints(long value) { + public void incrementHitPoints(long value) { setHitPoints(getHitPoints() - value); }