- All functions and classes documented: https://github.com/ViciousSquid/diceroll/tree/main/Docs
- Please refer to
Example1.py
,Example2.py
, andExample3_gui.py
for quick feature demos
The dicerollAPI
class provides a high-level interface for rolling dice, performing animations, and managing roll history.
Here's a summary of the functions exposed by the API:
Initializes the dicerollAPI instance with optional parameters to enable saving rolls and logging to the console.
save_rolls
(bool): Optional parameter to enable saving rolls. Default is False.log_console
(bool): Optional parameter to enable logging to the console. Default is None.
Initializes the dicerollAPI instance with optional parameters to enable saving rolls and logging to the console.
width
(int): Width of the animation window. Default is 300.height
(int): Height of the animation window. Default is 300.
Initializes the dicerollAPI instance with optional parameters to enable saving rolls and logging to the console.
save_rolls
(bool): Optional parameter to enable saving rolls. Default is False.log_console
(bool): Optional parameter to enable logging to the console. Default is None.
dice_notation
(str): The dice notation specifying the number and type of dice to roll (e.g., "2d6").dice_color
(DiceColor): The color of the dice. Default is DiceColor.WHITE.target_value
(int): Optional target value for the roll. Default is None.animate
(bool): Flag to enable or disable animation. Default is True.
- dice_type (str): The type of dice to roll (e.g., "d6", "d20").
- dice_color (DiceColor): The color of the dice. Default is DiceColor.WHITE.
- animate (bool): Flag to enable or disable animation. Default is True.
roll_multiple_dice_of_same_type(self, dice_type, num_dice, dice_color=DiceColor.WHITE, animate=True)
dice_type
(str): The type of dice to roll (e.g., "d6", "d20").num_dice
(int): The number of dice to roll.dice_color
(DiceColor): The color of the dice. Default is DiceColor.WHITE.animate
(bool): Flag to enable or disable animation. Default is True.
- dice_notations (list): A list of dice notations specifying the number and type of dice to roll for each set.
- dice_colors (list): Optional list of dice colors corresponding to each set of dice. Default is None.
- target_values (list): Optional list of target values for each set of dice. Default is None.
- animate (bool): Flag to enable or disable animation. Default is True.
roll_result
(dict): The result of a dice roll.
roll_result
(dict): The result of a dice roll.
roll_result
(dict): The result of a dice roll.
roll_result
(dict): The result of a dice roll.
dice_notation
(str): The dice notation specifying the number and type of dice to roll.num_rolls
(int): The number of rolls to perform for calculating statistics.
file_path
(str): The path to the file where the roll history will be saved.
file_path
(str): The path to the file from which the roll history will be loaded.v
- No arguments.
- No arguments.
- No arguments.
- No arguments.
- No arguments.
- No arguments.
style
(AnimationStyle): The animation style to set. Default isAnimationStyle.SHAKE
roll_saving_throw(self, dice_type=DiceType.D20, dice_color=DiceColor.WHITE, target_value=None, success_threshold=None, animate=True)
dice_type
(DiceType): The type of dice to roll for the saving throw. Default isDiceType.D20
.dice_color
(DiceColor): The color of the dice. Default isDiceColor.WHITE
target_value
(int): Optional target value for the saving throw. Default isNone
success_threshold
(int): Optional success threshold for the saving throw. Default isNone
animate
(bool): Flag to enable or disable animation. Default isTrue
roll_multiple_saving_throws(self, num_throws, dice_type=DiceType.D20, dice_color=DiceColor.WHITE, target_values=None, success_thresholds=None, animate=True)
num_throws
(int): The number of saving throws to roll.dice_type
(DiceType): The type of dice to roll for each saving throw. Default isDiceType.D20
dice_color
(DiceColor): The color of the dice. Default isDiceColor.WHITE
target_values
(list): Optional list of target values for each saving throw. Default isNone
success_thresholds
(list): Optional list of success thresholds for each saving throw. Default isNone
animate
(bool): Flag to enable or disable animation. Default isTrue
-
No arguments.
- No arguments.
dice_notation
(str): The dice notation specifying the number and type of dice to roll.