From 465ea312216d1b81022e9229f788266b59e47c91 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 18 Apr 2021 17:15:50 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20#1=20Add=20/spell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 13 +++++++++- pyproject.toml | 1 + royalpack/__main__.py | 1 + royalpack/commands/__init__.py | 1 + royalpack/commands/spell.py | 46 ++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 royalpack/commands/spell.py diff --git a/poetry.lock b/poetry.lock index 36ba89c6..2a6dd075 100644 --- a/poetry.lock +++ b/poetry.lock @@ -342,6 +342,14 @@ click = ">=7.1.2,<8.0.0" royalnet = ">=6.4.0,<6.5.0" Telethon = ">=1.21.1,<2.0.0" +[[package]] +name = "royalspells" +version = "3.2" +description = "A package to procedurally generate useless spells!" +category = "main" +optional = false +python-versions = "~=3.6" + [[package]] name = "rsa" version = "4.7.2" @@ -504,7 +512,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "cb11116be1dc62024392fa97315da722acf0f700b8142d32047b03ee19625977" +content-hash = "83cf43c506e9d5e452c90d52620743ac27e7f40405b5bae1da20b181612879c3" [metadata.files] aiohttp = [ @@ -897,6 +905,9 @@ royalnet-telethon = [ {file = "royalnet-telethon-1.0.2.tar.gz", hash = "sha256:cf2dd0394576bbf9e3b9a9355273e898af85acbdbbe2efc20c36a697fb093d61"}, {file = "royalnet_telethon-1.0.2-py3-none-any.whl", hash = "sha256:64503dde289e71c3faa3b7b0e005b66081a6a86645d0d811d4c4b671db3267e8"}, ] +royalspells = [ + {file = "royalspells-3.2.tar.gz", hash = "sha256:2bd4a9a66514532e35c02c3907425af48c7cb292364c4843c795719a82b25dfe"}, +] rsa = [ {file = "rsa-4.7.2-py3-none-any.whl", hash = "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2"}, {file = "rsa-4.7.2.tar.gz", hash = "sha256:9d689e6ca1b3038bc82bf8d23e944b6b6037bc02301a574935b2dd946e0353b9"}, diff --git a/pyproject.toml b/pyproject.toml index e373ffed..249f55a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ steam = "^1.2.0" SQLAlchemy-Utils = "^0.37.0" arrow = "^1.0.3" colour = "^0.1.5" +royalspells = "^3.2" [tool.poetry.dev-dependencies] diff --git a/royalpack/__main__.py b/royalpack/__main__.py index ae4fe678..d83a3312 100644 --- a/royalpack/__main__.py +++ b/royalpack/__main__.py @@ -55,6 +55,7 @@ register_telegram(commands.dog_breedlist, ["dog"], "(?:list|help|aiuto)") register_telegram(commands.dog_breed, ["dog"], "(?P[A-Za-z/]+)") register_telegram(commands.fortune, ["fortune"]) register_telegram(commands.pmots, ["pmots"]) +register_telegram(commands.spell, ["spell"], "(?P.+)") pda.implementations["telethon.1"].register_conversation(r) diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index d6e7d145..3225b957 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -9,3 +9,4 @@ from .emojify import * from .dog import * from .fortune import * from .pmots import * +from .spell import * diff --git a/royalpack/commands/spell.py b/royalpack/commands/spell.py new file mode 100644 index 00000000..45d4a397 --- /dev/null +++ b/royalpack/commands/spell.py @@ -0,0 +1,46 @@ +import royalnet.engineer as engi +import royalspells + + +@engi.TeleportingConversation +async def spell(*, _msg: engi.Message, spellname: str, **__): + """ + Genera una spell casuale! + """ + spell = royalspells.Spell(spellname) + + rows: list[str] = [f"✨ {spell.name}"] + + if spell.damage_component: + dmg: royalspells.DamageComponent = spell.damage_component + constant_str: str = f"{dmg.constant:+d}" if dmg.constant != 0 else "" + rows.append(f"Danni: {dmg.dice_number}d{dmg.dice_type}{constant_str}" + f" {', '.join(dmg.damage_types)}") + rows.append(f"Precisione: {dmg.miss_chance}%") + if dmg.repeat > 1: + rows.append(f"Multiattacco: ×{dmg.repeat}") + rows.append("") + + if spell.healing_component: + heal: royalspells.HealingComponent = spell.healing_component + constant_str: str = f"{heal.constant:+d}" if heal.constant != 0 else "" + rows.append(f"Cura: {heal.dice_number}d{heal.dice_type}{constant_str} HP") + rows.append("") + + if spell.stats_component: + stats: royalspells.StatsComponent = spell.stats_component + rows.append("Il caster riceve: ") + for stat_name in stats.stat_changes: + rows.append(f"{stat_name}{stats.stat_changes[stat_name]}") + rows.append("") + + if spell.status_effect_component: + se: royalspells.StatusEffectComponent = spell.status_effect_component + rows.append("Infligge al bersaglio: ") + rows.append(f"{se.effect} ({se.chance}%)") + rows.append("") + + await _msg.reply(text="\n".join(rows)) + + +__all__ = ("spell",)