Merge pull request #261 from pimittens/vanillafixes #patch
chaos scroll fix
This commit is contained in:
@@ -344,7 +344,7 @@ server:
|
||||
USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted.
|
||||
SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default.
|
||||
CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default.
|
||||
CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls.
|
||||
CHSCROLL_STAT_RANGE: 5 #Stat upgrade range (-N, N) on chaos scrolls.
|
||||
|
||||
#Beginner Skills Configuration
|
||||
USE_ULTRA_NIMBLE_FEET: false #Massive speed & jump upgrade.
|
||||
|
||||
@@ -35,6 +35,6 @@ public class Randomizer {
|
||||
}
|
||||
|
||||
public static int rand(final int lbound, final int ubound) {
|
||||
return (int) ((rand.nextDouble() * (ubound - lbound + 1)) + lbound);
|
||||
return ((int) (rand.nextDouble() * (ubound - lbound + 1))) + lbound;
|
||||
}
|
||||
}
|
||||
37
src/test/java/tools/RandomizerTest.java
Normal file
37
src/test/java/tools/RandomizerTest.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package tools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class RandomizerTest {
|
||||
|
||||
@Test
|
||||
void randShouldIncludeEntireRange() {
|
||||
Map<Integer, Integer> rands = new HashMap<>();
|
||||
|
||||
final int rounds = 100_000;
|
||||
for (int i = 0; i < rounds; i++) {
|
||||
int randomValue = Randomizer.rand(-5, 5);
|
||||
rands.compute(randomValue, (k, v) -> v == null ? 0 : v + 1);
|
||||
}
|
||||
|
||||
assertFalse(rands.containsKey(-6));
|
||||
assertTrue(rands.containsKey(-5));
|
||||
assertTrue(rands.containsKey(-4));
|
||||
assertTrue(rands.containsKey(-3));
|
||||
assertTrue(rands.containsKey(-2));
|
||||
assertTrue(rands.containsKey(-1));
|
||||
assertTrue(rands.containsKey(0));
|
||||
assertTrue(rands.containsKey(1));
|
||||
assertTrue(rands.containsKey(2));
|
||||
assertTrue(rands.containsKey(3));
|
||||
assertTrue(rands.containsKey(4));
|
||||
assertTrue(rands.containsKey(5));
|
||||
assertFalse(rands.containsKey(6));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user