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()
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):
if n <= 6:
return 'Miss :fire:'
return ':fire:'
elif 7 <= n and n <= 9:
return 'Partial success :person_shrugging:'
return ':person_shrugging:'
else:
return 'Total success :tada:'
return ':tada:'
def roll(mod):
values = []
rolls = []
for i in range(2):
values.append(random.randint(1,6))
values.append(mod)
result = sum(values)
message = '{}'.format(values[0])
for value in values[1:]:
message += '{:+}'.format(value)
message += ' = **{}**\n**{}**'.format(result, succ(result))
rolls.append(random.randint(1,6))
result = sum(rolls) + mod
message = '+'.join(boxed(r) for r in rolls)
message += '{:+}'.format(mod)
message += ' = **{}** {}'.format(result, succ(result))
return message