Package dev.sefiraat.sefilib.misc
Class Chance
java.lang.Object
dev.sefiraat.sefilib.misc.Chance
This class contains basic utility methods for chance and rolls.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleroll(double upper) Rolls a number starting from 1 to upperstatic doubleroll(double upper, boolean upLimit) Rolls a number starting from 1 to upperstatic introll(int upper) Rolls a number starting from 0 to upperstatic introll(int upper, boolean upLimit) Rolls a number starting from 1 to upperstatic booleantestChance(double chance) Tests a chance roll starting from 1 to upperstatic booleantestChance(double chance, double upper) Tests a chance roll starting from 1 tostatic booleantestChance(int chance, int upper) Tests a chance roll starting from 1 to upper
-
Method Details
-
testChance
public static boolean testChance(double chance) Tests a chance roll starting from 1 to upper- Parameters:
chance- The chance to succeed between 0-1- Returns:
- true if roll passes
-
testChance
public static boolean testChance(int chance, int upper) Tests a chance roll starting from 1 to upper- Parameters:
chance- The number the roll must be lower thanupper- The highest possible number that could roll (inclusive)- Returns:
- true if roll passes
-
roll
public static int roll(int upper, boolean upLimit) Rolls a number starting from 1 to upper- Parameters:
upper- The highest possible number that could roll (inclusive)upLimit- If true, the bound will be increased for 1 for inclusivity while maintaining readability for manually typed numbers (i.e. Upper 50 converts to 51 returning a max of 50 still). Set false when using 0 based indexes (list.size())- Returns:
- rolled int
-
testChance
public static boolean testChance(double chance, double upper) Tests a chance roll starting from 1 to- Parameters:
chance- The number the roll must be lower thanupper- The highest possible number that could roll (inclusive)- Returns:
- true if roll passes
-
roll
public static int roll(int upper) Rolls a number starting from 0 to upper- Parameters:
upper- The highest possible number that could roll (inclusive)- Returns:
- rolled int
-
roll
public static double roll(double upper) Rolls a number starting from 1 to upper- Parameters:
upper- The highest possible number that could roll (inclusive)- Returns:
- rolled int
-
roll
public static double roll(double upper, boolean upLimit) Rolls a number starting from 1 to upper- Parameters:
upper- The highest possible number that could roll (inclusive)upLimit- If true, the bound will be increased for 1 for inclusivity while maintaining readability for manually typed numbers (i.e. Upper 50 converts to 51 returning a max of 50 still). Set false when using 0 based indexes (list.size())- Returns:
- rolled int
-