mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Add dndrolladv and dndrolldis
This commit is contained in:
parent
ccf6f4c110
commit
c0bb9c45c0
4 changed files with 64 additions and 2 deletions
|
@ -6,6 +6,8 @@ from .dndinfo import DndinfoCommand
|
||||||
from .dndnew import DndnewCommand
|
from .dndnew import DndnewCommand
|
||||||
from .dndedit import DndeditCommand
|
from .dndedit import DndeditCommand
|
||||||
from .dndroll import DndrollCommand
|
from .dndroll import DndrollCommand
|
||||||
|
from .dndrolladv import DndrolladvCommand
|
||||||
|
from .dndrolldis import DndrolldisCommand
|
||||||
|
|
||||||
# Enter the commands of your Pack here!
|
# Enter the commands of your Pack here!
|
||||||
available_commands = [
|
available_commands = [
|
||||||
|
@ -16,6 +18,8 @@ available_commands = [
|
||||||
DndnewCommand,
|
DndnewCommand,
|
||||||
DndeditCommand,
|
DndeditCommand,
|
||||||
DndrollCommand,
|
DndrollCommand,
|
||||||
|
DndrolladvCommand,
|
||||||
|
DndrolldisCommand,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# Don't change this, it should automatically generate __all__
|
||||||
|
|
|
@ -16,6 +16,12 @@ class DndrollCommand(Command):
|
||||||
|
|
||||||
tables = {DndCharacter, DndActiveCharacter}
|
tables = {DndCharacter, DndActiveCharacter}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _roll():
|
||||||
|
return random.randrange(1, 21)
|
||||||
|
|
||||||
|
_roll_string = "1d20"
|
||||||
|
|
||||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||||
author = await data.get_author(error_if_none=True)
|
author = await data.get_author(error_if_none=True)
|
||||||
if author.dnd_active_character is None:
|
if author.dnd_active_character is None:
|
||||||
|
@ -73,12 +79,12 @@ class DndrollCommand(Command):
|
||||||
|
|
||||||
total_mod = stat_mod + proficiency_mod + extra_mod
|
total_mod = stat_mod + proficiency_mod + extra_mod
|
||||||
|
|
||||||
roll = random.randrange(1, 21)
|
roll = self._roll()
|
||||||
|
|
||||||
result = roll + total_mod
|
result = roll + total_mod
|
||||||
|
|
||||||
await data.reply(f"🎲 Rolling {stat_name}{proficiency_name}{plusformat(extra_mod, empty_if_zero=True)}:\n"
|
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(stat_mod, empty_if_zero=True)}"
|
||||||
f"{plusformat(proficiency_mod, empty_if_zero=True)}"
|
f"{plusformat(proficiency_mod, empty_if_zero=True)}"
|
||||||
f"{plusformat(extra_mod, empty_if_zero=True)}"
|
f"{plusformat(extra_mod, empty_if_zero=True)}"
|
||||||
|
|
26
royalnet/packs/rpg/commands/dndrolladv.py
Normal file
26
royalnet/packs/rpg/commands/dndrolladv.py
Normal 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"
|
26
royalnet/packs/rpg/commands/dndrolldis.py
Normal file
26
royalnet/packs/rpg/commands/dndrolldis.py
Normal 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"
|
Loading…
Reference in a new issue