pymasep.dices
Module to launch many dices, any types, with modifiers.
Functions
|
Roll one or many dices of one type and return the total and all the values |
|
Roll many dices and sum/substract all terms. No parenthesis is allowed. |
|
get the min and max values of dice |
|
get the min and max of dices expression. |
Module Contents
- pymasep.dices.roll_dice(dice, random_seed=None)
Roll one or many dices of one type and return the total and all the values
- Parameters:
dice (str) – String format xDy with 0<x<inf and 0<y<inf.
random_seed (int) – Random seed for testing only (or cheating but, hum, what’s the point ? it’s just a game.).
- Returns:
(result, details). result is the result of the dice and details is list of all details for all launches.
- Example::
>>> roll_dice('2D6') (4, [1, 3])
- Return type:
Tuple[int, List[int]]
- pymasep.dices.roll_dices(dices, random_seed=None)
Roll many dices and sum/substract all terms. No parenthesis is allowed.
- Parameters:
dices (str) – Expression with format
((\d+)?D(\d+)|([\+\-]\d+))+?(not totally sure of the regexp, see tests)random_seed (int) – seed used in tests. Should not be used in a real scenario except for reproductible scenarios
- Returns:
(result, details). Result is the sum of all dices and modifiers and details is list of all details, including modifiers
- Example::
>>> roll_dices('2D6+1D4+3') (13, [5, 4, 1, 3])
- Return type:
Tuple[int, List[int]]
- pymasep.dices.min_max_dice(dice)
get the min and max values of dice
- Parameters:
dice (str) – string format xDy with 0<x<inf and 0<y<inf.
- Returns:
min and max values of dice
- pymasep.dices.min_max_dices(dices)
get the min and max of dices expression.
- Parameters:
dices (str) – expression with format
((\d+)?D(\d+)|([\+\-]\d+))+?(not totally sure of the regexp, see tests) No parenthesis is allowed.- Returns:
(min, max).
- Example::
>>> min_max_dices('2D6+1D4+3') (6, 19)