rollcake: fate dice
This commit is contained in:
parent
86e4c583b4
commit
d9c2ae4068
|
@ -16,14 +16,34 @@ USAGE = '''@ me to roll RPG dice. Examples:
|
|||
|
||||
@**Rollcake** void 3
|
||||
*(Voidheart Symphony city roll, stress gauge 3: 2d6, check if either/both are above 3)*
|
||||
|
||||
@**Rollcake** fate 1
|
||||
*(Fate, rating +1: 4 fate dice, add +1 to total)*
|
||||
'''
|
||||
|
||||
PBTA_RE = re.compile(r'(pbta|apoc(alypse)?|void(heart)? castle)\s+(?P<mod>[-+]?[0-9])(\s+(?P<adv>adv|dis))?')
|
||||
FITD_RE = re.compile(r'(fitd|forged)\s+(?P<rating>[0-9])\b')
|
||||
SBR_RE = re.compile(r'(sbr|res(istance)?)\s+(?P<pool>[0-9])(\s+(?P<risk>risk|dang))?')
|
||||
VOID_RE = re.compile(r'(void(heart)?( city)?)\s+(?P<stress>[0-6])(\s+(?P<adv>adv|dis))?')
|
||||
FATE_RE = re.compile(r'fate\s+(?P<rating>[-+]?[0-9])')
|
||||
DICE_RE = re.compile(r'\b(?P<count>[0-9]*)d(?P<sides>[0-9]+)\s*(?P<mod>[-+][0-9]+)?')
|
||||
|
||||
FATE_LADDER = [
|
||||
'Horrifying',
|
||||
'Catastrophic',
|
||||
'Terrible',
|
||||
'Poor',
|
||||
'Mediocre',
|
||||
'Average',
|
||||
'Fair',
|
||||
'Good',
|
||||
'Great',
|
||||
'Superb',
|
||||
'Fantastic',
|
||||
'Epic',
|
||||
'Legendary',
|
||||
]
|
||||
|
||||
def roll(count, sides):
|
||||
return [random.randint(1, sides) for i in range(count)]
|
||||
|
||||
|
@ -154,6 +174,25 @@ def handle_roll(content):
|
|||
)
|
||||
)
|
||||
|
||||
fate = FATE_RE.search(content)
|
||||
if fate:
|
||||
rating = int(fate.group('rating') or '0')
|
||||
results = [random.randint(-1, 1) for i in range(4)]
|
||||
total = sum(results) + rating
|
||||
ladder_entry = total + 4
|
||||
if ladder_entry >= 0 and ladder_entry < len(FATE_LADDER):
|
||||
effort = FATE_LADDER[ladder_entry]
|
||||
else:
|
||||
effort = ''
|
||||
return '**{:+d}{}**\nRolls: {}'.format(
|
||||
total,
|
||||
' ' + effort if effort else '',
|
||||
', '.join(
|
||||
'`{}`'.format('+' if d == 1 else '-' if d == -1 else ' ')
|
||||
for d in results
|
||||
)
|
||||
)
|
||||
|
||||
return USAGE
|
||||
|
||||
class RollcakeHandler(object):
|
||||
|
|
Loading…
Reference in a new issue