Skip to content

Commit

Permalink
#11 dice and auxiliar classes created
Browse files Browse the repository at this point in the history
  • Loading branch information
Artic42 committed May 10, 2024
1 parent d4e7d78 commit ce0d655
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/dice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import random

class dice:
def __init__(self, size=6):
self.size = size

def setSize(self, size):
self.size = size

def roll(self):
return random.randint(1, self.size)

class customDice(dice):
def __init__(self, faces):
self.faces = faces
self.size = len(faces)

def roll(self):
return random.choice(self.faces)

class dicePool:
def __init__(self, diceList):
self.diceList = diceList

def roll(self):
return [d.roll() for d in self.diceList]

def rollSum(self):
return sum(self.roll())

def rollSuccesses(self, target):
return sum([1 for roll in self.roll() if roll >= target])

0 comments on commit ce0d655

Please sign in to comment.