Skip to content

Commit 42c1670

Browse files
committed
Added snippets for the 4 new approaches.
1 parent ed6e2fd commit 42c1670

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
...
2+
def __init__(self):
3+
for ability_type in self.ABILITIES:
4+
setattr(self, ability_type, self.ability())
5+
6+
def ability(self):
7+
values = sample(range(1, 7), 4)
8+
return sum(values) - min(values)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
...
2+
def ability(self):
3+
return choice([*vars(self).values()])
4+
5+
@staticmethod
6+
def dice_roll():
7+
values = sample(range(1, 7), 4)
8+
return sum(sorted(values, reverse=True)[:-1])
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Character:
2+
ABILITIES = ('strength', 'dexterity', 'constitution', 'intelligence', 'wisdom', 'charisma')
3+
4+
def __init__(self):
5+
for ability_type in self.ABILITIES:
6+
setattr(self, ability_type, self.ability())
7+
self.hitpoints = 10 + modifier(self.constitution)
8+
...
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Character:
2+
...
3+
def ability(self):
4+
return choice([*vars(self).values()])
5+
6+
def dice_roll():
7+
values = sample(range(1, 7), 4)
8+
return sum(sorted(values)[1:])

0 commit comments

Comments
 (0)