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

publish: 5.4

This commit is contained in:
Steffo 2020-03-16 20:03:49 +01:00
parent 6fdf787992
commit 3a596805e7
6 changed files with 61 additions and 15 deletions

View file

@ -2,7 +2,7 @@
[tool.poetry]
name = "rpgpack"
version = "5.3.2"
version = "5.4"
description = "A Royalnet Pack to play role-playing-games"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+"

View file

@ -19,6 +19,9 @@ class DndactiveCommand(Command):
author = await data.get_author(error_if_none=True)
active_character = await get_active_character(data)
DndCharacterT = self.alchemy.get(DndCharacter)
DndActiveCharacterT = self.alchemy.get(DndActiveCharacter)
# Display the active character
if identifier is None:
if active_character is None:
@ -31,7 +34,7 @@ class DndactiveCommand(Command):
try:
identifier = int(identifier)
except ValueError:
chars = await asyncify(data.session.query(self.alchemy.get(DndCharacter)).filter_by(name=identifier).all)
chars = await asyncify(data.session.query(DndCharacterT).filter_by(name=identifier).all)
if len(chars) >= 2:
char_string = "\n".join([f"[c]{char.character_id}[/c] (LV {char.level}) by {char.creator})" for char in chars])
raise CommandError(f"Multiple characters share the name {identifier}, "
@ -42,7 +45,7 @@ class DndactiveCommand(Command):
char = None
else:
# Find the character by id
char = await asyncify(data.session.query(self.alchemy.get(DndCharacter))
char = await asyncify(data.session.query(DndCharacterT)
.filter_by(character_id=identifier)
.one_or_none)
if char is None:
@ -50,7 +53,7 @@ class DndactiveCommand(Command):
# Check if the player already has an active character
if active_character is None:
# Create a new active character
achar = self.alchemy.get(DndActiveCharacter)(
achar = DndActiveCharacterT(
character=char,
user=author,
interface_name=self.interface.name,

View file

@ -15,14 +15,15 @@ class DndeditCommand(DndnewCommand):
async def run(self, args: CommandArgs, data: CommandData) -> None:
character_sheet = args.joined()
if character_sheet == "":
await data.reply(self._syntax())
return
active_character = await get_active_character(data)
if active_character is None:
raise CommandError("You don't have an active character.")
char = active_character.character
char: DndCharacter = active_character.character
if character_sheet == "":
await data.reply(char.to_edit_string())
return
arguments = self._parse(character_sheet)
for key in arguments:

View file

@ -12,10 +12,52 @@ class DndinfoCommand(Command):
tables = {DndCharacter, DndActiveCharacter}
_p_emoji = {
0: "🌑",
0.5: "🌗",
1: "🌕",
2: "⭐️",
}
async def run(self, args: CommandArgs, data: CommandData) -> None:
active_character = await get_active_character(data)
char = active_character.character
if char is None:
if active_character is None:
raise CommandError("You don't have an active character.")
await data.reply(char.character_sheet())
c: DndCharacter = active_character.character
r = f"[b]{c.name}[/b]\n" \
f"🔰 Lv. {c.level}\n" \
f"\n" \
f"❤️ {c.current_hp}/{c.max_hp}\n" \
f"🛡 {c.armor_class}\n" \
f"\n" \
f"{self._p_emoji[c.strength_save_proficiency.value]} Strength: [b]{c.strength:+d}[/b] ({c.strength_score})\n" \
f"{self._p_emoji[c.dexterity_save_proficiency.value]} Dexterity: [b]{c.dexterity:+d}[/b] ({c.dexterity_score})\n" \
f"{self._p_emoji[c.constitution_save_proficiency.value]} Constitution: [b]{c.constitution:+d}[/b] ({c.constitution_score})\n" \
f"{self._p_emoji[c.intelligence_save_proficiency.value]} Intelligence: [b]{c.intelligence:+d}[/b] ({c.intelligence_score})\n" \
f"{self._p_emoji[c.wisdom_save_proficiency.value]} Wisdom: [b]{c.wisdom:+d}[/b] ({c.wisdom_score})\n" \
f"{self._p_emoji[c.charisma_save_proficiency.value]} Charisma: [b]{c.charisma:+d}[/b] ({c.charisma_score})\n" \
f"\n" \
f"{self._p_emoji[c.acrobatics_proficiency.value]} Acrobatics: [b]{c.acrobatics:+d}[/b]\n" \
f"{self._p_emoji[c.animal_handling_proficiency.value]} Animal Handling: [b]{c.animal_handling:+d}[/b]\n" \
f"{self._p_emoji[c.arcana_proficiency.value]} Arcana: [b]{c.arcana:+d}[/b]\n" \
f"{self._p_emoji[c.athletics_proficiency.value]} Athletics: [b]{c.athletics:+d}[/b]\n" \
f"{self._p_emoji[c.deception_proficiency.value]} Deception: [b]{c.deception:+d}[/b]\n" \
f"{self._p_emoji[c.history_proficiency.value]} History: [b]{c.history:+d}[/b]\n" \
f"{self._p_emoji[c.insight_proficiency.value]} Insight: [b]{c.insight:+d}[/b]\n" \
f"{self._p_emoji[c.intimidation_proficiency.value]} Intimidation: [b]{c.intimidation:+d}[/b]\n" \
f"{self._p_emoji[c.investigation_proficiency.value]} Investigation: [b]{c.investigation:+d}[/b]\n" \
f"{self._p_emoji[c.medicine_proficiency.value]} Medicine: [b]{c.medicine:+d}[/b]\n" \
f"{self._p_emoji[c.nature_proficiency.value]} Nature: [b]{c.nature:+d}[/b]\n" \
f"{self._p_emoji[c.perception_proficiency.value]} Perception: [b]{c.perception:+d}[/b]\n" \
f"{self._p_emoji[c.performance_proficiency.value]} Performance: [b]{c.performance:+d}[/b]\n" \
f"{self._p_emoji[c.persuasion_proficiency.value]} Persuasion: [b]{c.persuasion:+d}[/b]\n" \
f"{self._p_emoji[c.religion_proficiency.value]} Religion: [b]{c.religion:+d}[/b]\n" \
f"{self._p_emoji[c.sleight_of_hand_proficiency.value]} Sleight of Hand: [b]{c.sleight_of_hand:+d}[/b]\n" \
f"{self._p_emoji[c.stealth_proficiency.value]} Stealth: [b]{c.stealth:+d}[/b]\n" \
f"{self._p_emoji[c.survival_proficiency.value]} Survival: [b]{c.survival:+d}[/b]\n" \
f"\n" \
f"{self._p_emoji[c.initiative_proficiency.value]} Initiative: [b]{c.initiative:+d}[/b]\n"
await data.reply(r)

View file

@ -23,7 +23,7 @@ class DndCharacter:
@declared_attr
def name(self):
return Column(String, nullable=False)
return Column(String, nullable=False, unique=True)
@declared_attr
def strength_score(self):
@ -299,7 +299,7 @@ class DndCharacter:
def __str__(self):
return f"{self.name}"
def character_sheet(self) -> str:
def to_edit_string(self) -> str:
columns = list(self.__class__.__table__.columns)
column_names = [column.name for column in columns if (not column.primary_key and
not column.foreign_keys and

View file

@ -1 +1 @@
semantic = "5.3.2"
semantic = "5.4"