From a358b2e37b2a8de83b6366138e60f7c5e36e3f6e Mon Sep 17 00:00:00 2001 From: TrustyJAID Date: Sat, 1 Jul 2023 10:18:38 -0600 Subject: [PATCH] Fix equipping two-handed weapons Fix `[p]setinfo` Fix `[p]cbackpack` commands Don't reset the cooldown of negaverse when no arguments are provided allowing users to indefinitely play the negaverse. --- adventure/backpack.py | 5 +++-- adventure/character.py | 8 ++++++-- adventure/constants.py | 22 ++++++++++++++-------- adventure/converters.py | 2 +- adventure/negaverse.py | 1 - 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/adventure/backpack.py b/adventure/backpack.py index 619cef7e..c3e52a72 100644 --- a/adventure/backpack.py +++ b/adventure/backpack.py @@ -266,7 +266,7 @@ async def backpack_equip(self, ctx: commands.Context, *, equip_item: EquipableIt equip = c.backpack.get(equip_item.name) if equip: slot = equip.slot - if not getattr(c, equip.slot.name): + if not getattr(c, equip.slot.char_slot): equip_msg = box( _("{author} equipped {item} ({slot} slot).").format( author=escape(ctx.author.display_name), item=str(equip), slot=slot.get_name() @@ -283,9 +283,10 @@ async def backpack_equip(self, ctx: commands.Context, *, equip_item: EquipableIt ), lang="ansi", ) - await ctx.send(equip_msg) + c = await c.equip_item(equip, True, is_dev(ctx.author)) # FIXME: await self.config.user(ctx.author).set(await c.to_json(ctx, self.config)) + await ctx.send(equip_msg) @_backpack.command(name="eset", cooldown_after_parsing=True) @commands.cooldown(rate=1, per=600, type=commands.BucketType.user) diff --git a/adventure/character.py b/adventure/character.py index 50691592..0369b842 100644 --- a/adventure/character.py +++ b/adventure/character.py @@ -327,7 +327,7 @@ async def stats(self, ctx: commands.Context, *, user: Union[discord.Member, disc ).start(ctx=ctx) async def _build_loadout_display( - self, ctx: commands.Context, userdata, loadout=True, rebirths: int = None, index: int = None + self, ctx: commands.Context, userdata: dict, loadout=True, rebirths: int = None, index: int = None ): table = BeautifulTable(default_alignment=ALIGN_LEFT, maxwidth=500) table.set_style(BeautifulTable.STYLE_RST) @@ -350,7 +350,11 @@ async def _build_loadout_display( dex = 0 luck = 0 - def get_slot_index(slot: Slot): + def get_slot_index(slot: Union[Slot, tuple, list]): + if isinstance(slot, str): + slot = Slot.from_list([slot]) + elif isinstance(slot, (tuple, list)): + slot = Slot.from_list(slot) return slot.order() data_sorted = sorted(userdata["items"].items(), key=get_slot_index) diff --git a/adventure/constants.py b/adventure/constants.py index 16a10901..e61d6622 100644 --- a/adventure/constants.py +++ b/adventure/constants.py @@ -42,6 +42,12 @@ def from_list(cls, data: List[str]) -> Slot: def __str__(self): return self.names()[self] + @property + def char_slot(self): + if self is Slot.two_handed: + return "right" + return self.name + @classmethod def get_from_name(cls, name: str) -> Slot: for i in cls: @@ -136,14 +142,14 @@ def get_from_name(cls, name: str) -> Rarities: @staticmethod def names(): return { - "normal": _("Normal"), - "rare": _("Rare"), - "epic": _("Epic"), - "legendary": _("Legendary"), - "ascended": _("Ascended"), - "set": _("Set"), - "forged": _("Forged"), - "event": _("Event"), + Rarities.normal: _("Normal"), + Rarities.rare: _("Rare"), + Rarities.epic: _("Epic"), + Rarities.legendary: _("Legendary"), + Rarities.ascended: _("Ascended"), + Rarities.set: _("Set"), + Rarities.forged: _("Forged"), + Rarities.event: _("Event"), } def prefix_chance(self) -> Optional[float]: diff --git a/adventure/converters.py b/adventure/converters.py index b25418fc..58dd5132 100644 --- a/adventure/converters.py +++ b/adventure/converters.py @@ -811,7 +811,7 @@ def __init__(self, **kwargs): # Generate choices from the Enum options = tuple( - set(list(i.lower() for i in enum_type.names().keys()) + list(i.lower() for i in enum_type.names().values())) + set(list(i.name.lower() for i in enum_type.names().keys()) + list(i.lower() for i in enum_type.names().values())) ) kwargs.setdefault("choices", options) diff --git a/adventure/negaverse.py b/adventure/negaverse.py index a6a273fc..5c9ab366 100644 --- a/adventure/negaverse.py +++ b/adventure/negaverse.py @@ -380,7 +380,6 @@ async def _negaverse( @_negaverse_command.error async def negaverse_error(self, ctx: commands.Context, error: Exception): if isinstance(error, (commands.MissingRequiredArgument, commands.BadArgument)): - ctx.command.reset_cooldown(ctx) currency_name = await bank.get_currency_name( ctx.guild, )