mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
replace rarity calculation due to it breaking at more than two values
This commit is contained in:
committed by
Julian Krings
parent
77842489e5
commit
81b8fb02ae
@@ -69,6 +69,32 @@ public interface IRare {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
return possibilities.getFirst();
|
||||
}
|
||||
|
||||
double total = 0;
|
||||
for (T i : possibilities) {
|
||||
total += 1d / i.getRarity();
|
||||
}
|
||||
|
||||
double threshold = total * noiseValue;
|
||||
double buffer = 0;
|
||||
for (T i : possibilities) {
|
||||
buffer += 1d / i.getRarity();
|
||||
if (buffer >= threshold) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return possibilities.getLast();
|
||||
}
|
||||
|
||||
static <T extends IRare> T pickLegacy(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user