Add fixed setting for default waves.
This commit is contained in:
@@ -154,6 +154,13 @@ public class WaveParser
|
|||||||
// Create the wave.
|
// Create the wave.
|
||||||
DefaultWave result = new DefaultWave(monsters);
|
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
|
// Grab the WaveGrowth
|
||||||
String grw = config.getString("growth");
|
String grw = config.getString("growth");
|
||||||
WaveGrowth growth = WaveGrowth.fromString(grw);
|
WaveGrowth growth = WaveGrowth.fromString(grw);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class DefaultWave extends AbstractWave
|
|||||||
{
|
{
|
||||||
private SortedMap<Integer,MACreature> monsterMap;
|
private SortedMap<Integer,MACreature> monsterMap;
|
||||||
private WaveGrowth growth;
|
private WaveGrowth growth;
|
||||||
|
private boolean fixed;
|
||||||
|
|
||||||
public DefaultWave(SortedMap<Integer,MACreature> monsterMap) {
|
public DefaultWave(SortedMap<Integer,MACreature> monsterMap) {
|
||||||
this.monsterMap = monsterMap;
|
this.monsterMap = monsterMap;
|
||||||
@@ -20,6 +21,8 @@ public class DefaultWave extends AbstractWave
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena) {
|
public Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena) {
|
||||||
|
if (fixed) return getFixed();
|
||||||
|
|
||||||
// Get the amount of monsters to spawn.
|
// Get the amount of monsters to spawn.
|
||||||
int toSpawn = (int) Math.max(1D, growth.getAmount(wave, playerCount) * super.getAmountMultiplier());
|
int toSpawn = (int) Math.max(1D, growth.getAmount(wave, playerCount) * super.getAmountMultiplier());
|
||||||
|
|
||||||
@@ -51,11 +54,34 @@ public class DefaultWave extends AbstractWave
|
|||||||
return monsters;
|
return monsters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<MACreature,Integer> getFixed() {
|
||||||
|
Map<MACreature,Integer> result = new HashMap<MACreature,Integer>();
|
||||||
|
|
||||||
|
// For fixed waves, we just convert the accumulated map
|
||||||
|
int acc = 0;
|
||||||
|
for (Map.Entry<Integer,MACreature> entry : monsterMap.entrySet()) {
|
||||||
|
int prob = entry.getKey();
|
||||||
|
result.put(entry.getValue(), prob - acc);
|
||||||
|
acc += prob;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public WaveGrowth getGrowth() {
|
public WaveGrowth getGrowth() {
|
||||||
return growth;
|
return growth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGrowth(WaveGrowth growth) {
|
public void setGrowth(WaveGrowth growth) {
|
||||||
this.growth = growth;
|
this.growth = growth;
|
||||||
|
this.fixed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFixed() {
|
||||||
|
return fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFixed(boolean fixed) {
|
||||||
|
this.fixed = fixed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user