Skip to content

Commit

Permalink
Some fixes (#441)
Browse files Browse the repository at this point in the history
* 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.

* black
  • Loading branch information
TrustyJAID authored Jul 1, 2023
1 parent d3cb2a0 commit d59a077
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions adventure/backpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions adventure/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
22 changes: 14 additions & 8 deletions adventure/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]:
Expand Down
5 changes: 4 additions & 1 deletion adventure/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,10 @@ 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)

Expand Down
1 change: 0 additions & 1 deletion adventure/negaverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit d59a077

Please sign in to comment.