nicer formatting

This commit is contained in:
xenofem 2021-06-23 14:43:59 -04:00
parent 9a04d80067
commit c49b0679d6

40
bot.py
View file

@ -4,24 +4,42 @@ import sys
client = discord.Client() client = discord.Client()
BOXED_NUMBERS = [
":zero:",
":one:",
":two:",
":three:",
":four:",
":five:",
":six:",
":seven:",
":eight:",
":nine:",
":keycap_ten:",
]
def boxed(n):
if 0 <= n and n < len(BOXED_NUMBERS):
return BOXED_NUMBERS[n]
else:
return "[{}]".format(n)
def succ(n): def succ(n):
if n <= 6: if n <= 6:
return 'Miss :fire:' return ':fire:'
elif 7 <= n and n <= 9: elif 7 <= n and n <= 9:
return 'Partial success :person_shrugging:' return ':person_shrugging:'
else: else:
return 'Total success :tada:' return ':tada:'
def roll(mod): def roll(mod):
values = [] rolls = []
for i in range(2): for i in range(2):
values.append(random.randint(1,6)) rolls.append(random.randint(1,6))
values.append(mod) result = sum(rolls) + mod
result = sum(values) message = '+'.join(boxed(r) for r in rolls)
message = '{}'.format(values[0]) message += '{:+}'.format(mod)
for value in values[1:]: message += ' = **{}** {}'.format(result, succ(result))
message += '{:+}'.format(value)
message += ' = **{}**\n**{}**'.format(result, succ(result))
return message return message