We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 666c219 commit 1bb83edCopy full SHA for 1bb83ed
1 file changed
test/dnd-character/dnd_character.py
@@ -0,0 +1,28 @@
1
+from random import choice
2
+
3
4
+class Character:
5
6
+ def __init__(self):
7
+ self.strength = self.calculate_points()
8
+ self.dexterity = self.calculate_points()
9
+ self.constitution = self.calculate_points()
10
+ self.intelligence = self.calculate_points()
11
+ self.wisdom = self.calculate_points()
12
+ self.charisma = self.calculate_points()
13
+ self.hitpoints = 10 + modifier(self.constitution)
14
15
+ def ability(self):
16
+ score = choice([item for item in vars(self).values()])
17
+ return score
18
19
+ def dice_roll(self):
20
+ return choice(range(1, 7))
21
22
+ def calculate_points(self):
23
+ rolls = sorted([self.dice_roll() for number in range(4)], reverse=True)
24
+ return sum(rolls[:2])
25
26
27
+def modifier(constitution):
28
+ return (constitution - 10) // 2
0 commit comments