|
| 1 | +# Work with Python 3.6 |
| 2 | +import numpy as np |
| 3 | +from discord.ext.commands import Bot |
| 4 | + |
| 5 | +BOT_PREFIX = ("?", "!") |
| 6 | +TOKEN = "" # Get at discordapp.com/developers/applications/me |
| 7 | + |
| 8 | +bot = Bot(command_prefix=BOT_PREFIX) |
| 9 | + |
| 10 | +# bot = discord.bot() |
| 11 | + |
| 12 | +@bot.command( |
| 13 | + name='Degene6', |
| 14 | + description="Rolls a Degenesis dice pool.", |
| 15 | + brief="Sacrifice everything", |
| 16 | + aliases=['D6', '6pool','roll'], |
| 17 | + pass_context=True) |
| 18 | +async def degenesix(context,actionNumber:int,difficulty=0): |
| 19 | + autos = 0 if actionNumber < 13 else actionNumber-12 |
| 20 | + actionNumber = 12 if actionNumber > 13 else actionNumber |
| 21 | + roll = np.random.choice([1,2,3,4,5,6],actionNumber) |
| 22 | + successes = (roll > 3).sum() |
| 23 | + successes += autos |
| 24 | + triggers = (roll == 6).sum() |
| 25 | + ones = (roll == 1).sum() |
| 26 | + |
| 27 | + if difficulty: |
| 28 | + result = ('Success!\n' if successes >= difficulty else "Failure!\n") if ones < successes else 'It\'s a botch!\n' |
| 29 | + msg = "%s needs %d successes and rolls:" % (context.author.mention,difficulty) |
| 30 | + else: |
| 31 | + result = '' if ones < successes else 'It\'s a botch!\n' |
| 32 | + msg = "%s rolls:" % (context.author.mention) |
| 33 | + msg+= " \n %s \n %d successes, %d triggers \n %s" % (', '.join(map(str,roll)), |
| 34 | + successes, |
| 35 | + triggers, |
| 36 | + result) |
| 37 | + await context.send(msg) |
| 38 | + |
| 39 | +@bot.event |
| 40 | +async def on_ready(): |
| 41 | + print("Logged in as " + bot.user.name) |
| 42 | + |
| 43 | +bot.run(TOKEN) |
0 commit comments