1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add dndrolladv and dndrolldis

This commit is contained in:
Steffo 2019-10-23 11:54:45 +02:00
parent ccf6f4c110
commit c0bb9c45c0
4 changed files with 64 additions and 2 deletions

View file

@ -6,6 +6,8 @@ from .dndinfo import DndinfoCommand
from .dndnew import DndnewCommand
from .dndedit import DndeditCommand
from .dndroll import DndrollCommand
from .dndrolladv import DndrolladvCommand
from .dndrolldis import DndrolldisCommand
# Enter the commands of your Pack here!
available_commands = [
@ -16,6 +18,8 @@ available_commands = [
DndnewCommand,
DndeditCommand,
DndrollCommand,
DndrolladvCommand,
DndrolldisCommand,
]
# Don't change this, it should automatically generate __all__

View file

@ -16,6 +16,12 @@ class DndrollCommand(Command):
tables = {DndCharacter, DndActiveCharacter}
@staticmethod
def _roll():
return random.randrange(1, 21)
_roll_string = "1d20"
async def run(self, args: CommandArgs, data: CommandData) -> None:
author = await data.get_author(error_if_none=True)
if author.dnd_active_character is None:
@ -73,12 +79,12 @@ class DndrollCommand(Command):
total_mod = stat_mod + proficiency_mod + extra_mod
roll = random.randrange(1, 21)
roll = self._roll()
result = roll + total_mod
await data.reply(f"🎲 Rolling {stat_name}{proficiency_name}{plusformat(extra_mod, empty_if_zero=True)}:\n"
f"1d20"
f"{self._roll_string}"
f"{plusformat(stat_mod, empty_if_zero=True)}"
f"{plusformat(proficiency_mod, empty_if_zero=True)}"
f"{plusformat(extra_mod, empty_if_zero=True)}"

View file

@ -0,0 +1,26 @@
import typing
import random
from royalnet.commands import *
from royalnet.utils import plusformat
from .dndroll import DndrollCommand
from ..tables import DndCharacter, DndActiveCharacter
class DndrolladvCommand(DndrollCommand):
name: str = "dndrolladv"
description: str = "Roll with advantage as the active DnD character."
aliases = ["dra", "dndra", "drolladv"]
syntax = "{stat} [proficiency] [modifier]"
tables = {DndCharacter, DndActiveCharacter}
@staticmethod
def _roll():
first = random.randrange(1, 21)
second = random.randrange(1, 21)
return max(first, second)
_roll_string = "2d20h1"

View file

@ -0,0 +1,26 @@
import typing
import random
from royalnet.commands import *
from royalnet.utils import plusformat
from .dndroll import DndrollCommand
from ..tables import DndCharacter, DndActiveCharacter
class DndrolldisCommand(DndrollCommand):
name: str = "dndrolldis"
description: str = "Roll with disadvantage as the active DnD character."
aliases = ["drd", "dndrd", "drolldis"]
syntax = "{stat} [proficiency] [modifier]"
tables = {DndCharacter, DndActiveCharacter}
@staticmethod
def _roll():
first = random.randrange(1, 21)
second = random.randrange(1, 21)
return min(first, second)
_roll_string = "2d20l1"