mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
start work on dnd commands
This commit is contained in:
parent
38d98684f5
commit
d31b6e4100
5 changed files with 173 additions and 2 deletions
12
royalnet/packs/rpg/commands/dndactive.py
Normal file
12
royalnet/packs/rpg/commands/dndactive.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from royalnet.commands import *
|
||||
|
||||
|
||||
class DndactiveCommand(Command):
|
||||
name: str = "dndactive"
|
||||
|
||||
description: str = "Set the active D&D character."
|
||||
|
||||
aliases = ["da", "dnda", "active"]
|
||||
|
||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||
...
|
29
royalnet/packs/rpg/commands/dndnew.py
Normal file
29
royalnet/packs/rpg/commands/dndnew.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from royalnet.commands import *
|
||||
from ..tables import DndCharacter
|
||||
|
||||
|
||||
class DndnewCommand(Command):
|
||||
name: str = "dndnew"
|
||||
|
||||
description: str = "Create a new D&D character."
|
||||
|
||||
aliases = ["dn", "dndn", "new"]
|
||||
|
||||
syntax = "{name}\n" \
|
||||
"LV {level}\n" \
|
||||
"\n" \
|
||||
"STR {strength}\n" \
|
||||
"DEX {dexterity}\n" \
|
||||
"CON {constitution}\n" \
|
||||
"INT {intelligence}\n" \
|
||||
"WIS {wisdom}\n" \
|
||||
"CHA {charisma}\n" \
|
||||
"\n" \
|
||||
"MAXHP {maxhp}\n" \
|
||||
"AC {armorclass}"
|
||||
|
||||
tables = {}
|
||||
|
||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||
name = args[0]
|
||||
...
|
|
@ -1,9 +1,11 @@
|
|||
# Imports go here!
|
||||
|
||||
from .dndactivecharacters import DndActiveCharacter
|
||||
from .dndcharacters import DndCharacter
|
||||
|
||||
# Enter the tables of your Pack here!
|
||||
available_tables = [
|
||||
|
||||
DndActiveCharacter,
|
||||
DndCharacter,
|
||||
]
|
||||
|
||||
# Don't change this, it should automatically generate __all__
|
||||
|
|
26
royalnet/packs/rpg/tables/dndactivecharacters.py
Normal file
26
royalnet/packs/rpg/tables/dndactivecharacters.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import *
|
||||
from sqlalchemy.ext.declarative import *
|
||||
|
||||
|
||||
class DndActiveCharacter:
|
||||
__tablename__ = "dndactivecharacters"
|
||||
|
||||
@declared_attr
|
||||
def character_id(self):
|
||||
return Column(Integer, ForeignKey("dndcharacters.character_id"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def user_id(self):
|
||||
return Column(Integer, ForeignKey("users.uid"), primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def character(self):
|
||||
return relationship("DndCharacter", foreign_keys=self.character_id, backref="activations", use_scalar=True)
|
||||
|
||||
@declared_attr
|
||||
def user(self):
|
||||
return relationship("User", foreign_keys=self.user_id, backref="active_dnd_character", use_scalar=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__qualname__} for {self.user_id}: {self.character_id}>"
|
102
royalnet/packs/rpg/tables/dndcharacters.py
Normal file
102
royalnet/packs/rpg/tables/dndcharacters.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import *
|
||||
from sqlalchemy.ext.declarative import *
|
||||
|
||||
|
||||
class DndCharacter:
|
||||
__tablename__ = "dndcharacters"
|
||||
|
||||
@declared_attr
|
||||
def character_id(self):
|
||||
return Column(Integer, primary_key=True)
|
||||
|
||||
@declared_attr
|
||||
def creator_id(self):
|
||||
return Column(Integer, ForeignKey("users.uid"))
|
||||
|
||||
@declared_attr
|
||||
def creator(self):
|
||||
return relationship("User", foreign_keys=self.creator_id, backref="dndcharacters_created")
|
||||
|
||||
@declared_attr
|
||||
def name(self):
|
||||
return Column(String)
|
||||
|
||||
@declared_attr
|
||||
def strength(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def strength_mod(self):
|
||||
return (self.strength - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def dexterity(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def dexterity_mod(self):
|
||||
return (self.dexterity - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def constitution(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def constitution_mod(self):
|
||||
return (self.constitution - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def intelligence(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def intelligence_mod(self):
|
||||
return (self.intelligence - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def wisdom(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def wisdom_mod(self):
|
||||
return (self.wisdom - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def charisma(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def charisma_mod(self):
|
||||
return (self.charisma - 10) // 2
|
||||
|
||||
@declared_attr
|
||||
def level(self):
|
||||
return Column(Integer)
|
||||
|
||||
@property
|
||||
def proficiency_bonus(self):
|
||||
return ((self.level - 1) // 4) + 2
|
||||
|
||||
@declared_attr
|
||||
def max_hp(self):
|
||||
return Column(Integer)
|
||||
|
||||
@declared_attr
|
||||
def armor_class(self):
|
||||
return Column(Integer)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__qualname__} {self.name}>"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}\n" \
|
||||
f"LV {self.level}\n\n" \
|
||||
f"STR {self.strength}\n" \
|
||||
f"DEX {self.dexterity}\n" \
|
||||
f"CON {self.constitution}\n" \
|
||||
f"INT {self.intelligence}\n" \
|
||||
f"WIS {self.wisdom}\n" \
|
||||
f"CHA {self.charisma}\n\n" \
|
||||
f"MAXHP {self.max_hp}\n" \
|
||||
f"AC {self.armor_class}\n" \
|
Loading…
Reference in a new issue