Progress on Implementing Dungeon Packs
1. Integrated support for dungeon pack config options into the code (i.e. we actually DO what the settings specify) 2. Added random transitions from one dungeon type to another. Dungeons might also begin with a non-default pack. 3. Fixed a config reading bug that caused settings to be ignored and some invalid settings wouldn't trigger exceptions. Also fixed other dungeon pack bugs.
This commit is contained in:
@@ -11,9 +11,32 @@ public class DungeonChainRule
|
||||
private final ArrayList<WeightedContainer<DungeonType>> products;
|
||||
|
||||
public DungeonChainRule(DungeonChainRuleDefinition source, HashMap<String, DungeonType> nameToTypeMapping)
|
||||
{
|
||||
{
|
||||
ArrayList<String> conditionNames = source.getCondition();
|
||||
ArrayList<WeightedContainer<String>> productNames = source.getProducts();
|
||||
|
||||
//Validate the data, just in case
|
||||
if (conditionNames == null)
|
||||
{
|
||||
throw new NullPointerException("source cannot have null conditions");
|
||||
}
|
||||
if (productNames == null)
|
||||
{
|
||||
throw new NullPointerException("source cannot have null products");
|
||||
}
|
||||
if (productNames.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("products cannot be an empty list");
|
||||
}
|
||||
for (WeightedContainer<String> product : productNames)
|
||||
{
|
||||
//Check for weights less than 1. Those could cause Minecraft's random selection algorithm to throw an exception.
|
||||
//At the very least, they're useless values.
|
||||
if (product.itemWeight < 1)
|
||||
{
|
||||
throw new IllegalArgumentException("products cannot contain items with weights less than 1");
|
||||
}
|
||||
}
|
||||
|
||||
//Obtain the IDs of dungeon types in reverse order. Reverse order makes comparing against chain histories easy.
|
||||
condition = new int[conditionNames.size()];
|
||||
|
||||
Reference in New Issue
Block a user