Add duplicate patterns rather than replacing them

This commit is contained in:
Jesse Boyd 2018-01-19 14:36:01 +11:00
parent 17d3e574fb
commit 6ee7f47129
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -44,6 +44,8 @@ public class RandomPattern extends AbstractPattern {
*/
public void add(Pattern pattern, double chance) {
checkNotNull(pattern);
Double existingWeight = weights.get(pattern);
if (existingWeight != null) chance += existingWeight;
weights.put(pattern, chance);
collection = RandomCollection.of(weights, random);
this.patterns.add(pattern);