| 3 | |
| 4 | # Class that that holds dice-functions. You can set the amount of sides and roll with each dice object. |
| 5 | class Dice: |
| 6 | def __init__(self): |
| 7 | self.sideCount = 6 |
| 8 | |
| 9 | def setSides(self, sides): |
| 10 | if sides > 3: |
| 11 | self.sides = sides |
| 12 | else: |
| 13 | print( |
| 14 | "This absolutely shouldn't ever happen. The programmer sucks or someone " |
| 15 | "has tweaked with code they weren't supposed to touch!" |
| 16 | ) |
| 17 | |
| 18 | def roll(self): |
| 19 | return random.randint(1, self.sides) |
| 20 | |
| 21 | |
| 22 | # ===================================================================== |