From 243d0b00fb229a99b277bb1163de9052c4118e4e Mon Sep 17 00:00:00 2001 From: garbagemule Date: Thu, 27 Jun 2013 00:29:23 +0200 Subject: [PATCH] Add fixed setting for default waves. --- .../MobArena/waves/WaveParser.java | 7 +++++ .../MobArena/waves/types/DefaultWave.java | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/com/garbagemule/MobArena/waves/WaveParser.java b/src/com/garbagemule/MobArena/waves/WaveParser.java index 03c9a0c..7e435ad 100644 --- a/src/com/garbagemule/MobArena/waves/WaveParser.java +++ b/src/com/garbagemule/MobArena/waves/WaveParser.java @@ -153,6 +153,13 @@ public class WaveParser // Create the wave. DefaultWave result = new DefaultWave(monsters); + + // Check if this is a fixed wave + boolean fixed = config.getBoolean("fixed", false); + if (fixed) { + result.setFixed(true); + return result; + } // Grab the WaveGrowth String grw = config.getString("growth"); diff --git a/src/com/garbagemule/MobArena/waves/types/DefaultWave.java b/src/com/garbagemule/MobArena/waves/types/DefaultWave.java index 802f77c..f0db8e1 100644 --- a/src/com/garbagemule/MobArena/waves/types/DefaultWave.java +++ b/src/com/garbagemule/MobArena/waves/types/DefaultWave.java @@ -11,6 +11,7 @@ public class DefaultWave extends AbstractWave { private SortedMap monsterMap; private WaveGrowth growth; + private boolean fixed; public DefaultWave(SortedMap monsterMap) { this.monsterMap = monsterMap; @@ -20,6 +21,8 @@ public class DefaultWave extends AbstractWave @Override public Map getMonstersToSpawn(int wave, int playerCount, Arena arena) { + if (fixed) return getFixed(); + // Get the amount of monsters to spawn. int toSpawn = (int) Math.max(1D, growth.getAmount(wave, playerCount) * super.getAmountMultiplier()); @@ -50,6 +53,20 @@ public class DefaultWave extends AbstractWave // Return the map. return monsters; } + + private Map getFixed() { + Map result = new HashMap(); + + // For fixed waves, we just convert the accumulated map + int acc = 0; + for (Map.Entry entry : monsterMap.entrySet()) { + int prob = entry.getKey(); + result.put(entry.getValue(), prob - acc); + acc += prob; + } + + return result; + } public WaveGrowth getGrowth() { return growth; @@ -57,5 +74,14 @@ public class DefaultWave extends AbstractWave public void setGrowth(WaveGrowth growth) { this.growth = growth; + this.fixed = false; + } + + public boolean isFixed() { + return fixed; + } + + public void setFixed(boolean fixed) { + this.fixed = fixed; } }