gamble.models.dice

die and dice submodule

Classes

Dice([init_string, rigged_factor])

a group of die objects

Die([sides])

a single die object

RiggedDie([sides, rigged_factor])

a die with a modifier to roll in the top 3 per the percentage passed in

class gamble.models.dice.Dice(init_string: str = '2d6', rigged_factor: int = -1)[source]

Bases: object

a group of die objects

Parameters:
  • init_string (str) – a d-notation string representing a set of dice

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

__repr__() str[source]

dunder repr method

Returns:

the repr representation of this set of dice

Return type:

str

__str__() str[source]

dunder str method

Returns:

the string representation of this set of dice

Return type:

str

create_die(sides: int, rigged_factor: int = -1) gamble.models.dice.Die | gamble.models.dice.RiggedDie[source]

helper to create dice

Parameters:
  • sides (int) – the number of sides on a die

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

Returns:

A Die object that can be rigged

Return type:

gamble.models.dice.Die | gamble.models.dice.RiggedDie

property max: int

the max value these dice can roll

Returns:

the max for these dice + bonuses

max_of(num_rolls: int = 2) tuple[int, list[int]][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

a tuple with the max value rolled by the dice, and the dice rolls

Return type:

tuple[int, list[int]]

property min: int

the min value these dice can roll

Returns:

the min for these dice + bonuses

min_of(num_rolls: int = 2) tuple[int, list[int]][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

a tuple with the min value rolled by the dice, and the dice rolls

Return type:

tuple[int, list[int]]

property parts: list[gamble.models.dice.Die | int]

listing of the parts of this roll + bonuses

Returns:

a list of the parts of this dice calculation

roll() int[source]

roll the dice

Returns:

the value rolled by this dice

Return type:

int

roll_many(num_rolls: int = 2) list[int][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

list of values rolled by these dice

Return type:

list[int]

class gamble.models.dice.Die(sides: int = 6)[source]

Bases: object

a single die object

Parameters:

sides (int) – the number of sides to this die

__ge__(other: gamble.models.dice.Die) bool[source]

dunder greater than or equal to method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is bigger than or equal to the other die

Return type:

bool

__gt__(other: gamble.models.dice.Die) bool[source]

dunder greater than method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is bigger than the other die

Return type:

bool

__le__(other: gamble.models.dice.Die) bool[source]

dunder less than or equal to method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is smaller than or equal to the other die

Return type:

bool

__lt__(other: gamble.models.dice.Die) bool[source]

dunder less than method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is smaller than the other die

Return type:

bool

__repr__() str[source]

dunder repr method

Returns:

the repr representation of this die

Return type:

str

__str__() str[source]

dunder str method

Returns:

the string representation of this die

Return type:

str

property max: int

the max value this die can roll

Returns:

the max for this die

property min: int

the min value this die can roll

Returns:

the min for this die

property net_sides: int

the raw max sides * multiplier

Returns:

the non-absolute value of this die’s sides

roll() int[source]

roll the die

Returns:

the value rolled by this die

Return type:

int

class gamble.models.dice.RiggedDie(sides: int = 6, rigged_factor: int = 50)[source]

Bases: gamble.models.dice.Die

a die with a modifier to roll in the top 3 per the percentage passed in

Parameters:
  • sides (int) – the number of sides to this die

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

roll() int[source]

sometime override supers die roll depending on the rigged_factor

Returns:

the value rolled by this die

Return type:

int