Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

Commit

Permalink
**v1.1.0**
Browse files Browse the repository at this point in the history
* Added lock picks to unlock locked chests
* Added locked chests
* Added ability to open chests
* Added two new item categories, `Key` and `Utility`
* Fixed a bug where it looked like your turn was skipped
- in reality, it was just that you missed but i never sent the message
* Added HP and SP to the status menu
* Moved inventory related commands to their own cog
* Fixed issue where disabled commands were shown in help
* Got sick of the new help command, went back to the original
* Removed LRU dict of players for the time being
* Added ability to craft items.
- Currently can only craft `Lockpick` with `1x Aluminum Sheet`
* Can now obtain some materials from treasures
* Can now open your inventory during battle
- You will lose control of battle while this is open
* Refactored how healing items work via using a TargetSession during battle
* Fix circular import bug by moving sessions to its own file
  • Loading branch information
XuaTheGrate committed Oct 18, 2019
1 parent 0a03af1 commit ba10c6b
Show file tree
Hide file tree
Showing 25 changed files with 1,014 additions and 757 deletions.
2 changes: 1 addition & 1 deletion bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def on_command_error(self, *__, **_):
def description(self):
return random.choice([
"> ~~Stuck? Try using `$story` to progress.~~",
"> Confused? Try `$help` for more information.",
"> Confused? Try `$faq` for more information.",
"> ~~Bored? Try your hand at an online battle.~~",
"> If you have spare stat points, you can still use `$levelup` to use them.",
"> Join the support server for updates and announcements: <https://discord.gg/hkweDCD>",
Expand Down
28 changes: 24 additions & 4 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
**v0.1.3 Alpha**
**v1.1.0**
* Added lock picks to unlock locked chests
* Added locked chests
* Added ability to open chests
* Added two new item categories, `Key` and `Utility`
* Fixed a bug where it looked like your turn was skipped
- in reality, it was just that you missed but i never sent the message
* Added HP and SP to the status menu
* Moved inventory related commands to their own cog
* Fixed issue where disabled commands were shown in help
* Got sick of the new help command, went back to the original
* Removed LRU dict of players for the time being
* Added ability to craft items.
- Currently can only craft `Lockpick` with `1x Aluminum Sheet`
* Can now obtain some materials from treasures
* Can now open your inventory during battle
- You will lose control of battle while this is open
* Refactored how healing items work via using a TargetSession during battle
* Fix circular import bug by moving sessions to its own file
--------------------
**v1.0.3**
* Actually added the status screen page
* Fixed home battle page displaying wrong emote for Help
* Fixed `Healing` type skills displaying a ridiculuous decimal
--------------------
**v0.1.2 Alpha**
**v1.0.2**
* Fixed spelling error in Queen's Neckla(n)ce
* Added changelog sheet
* Added changelog command to view recent updates
Expand All @@ -17,7 +37,7 @@
* Added DBL cog task for internal use
* Added DBL command to go to my page
--------------------
**v0.1.1 Alpha**
**v1.0.1**
* added foul breath and stagnant air to invalid skills
* fixed bug where two battles could not occur at once
* properly select a treasure demon based on the players level
Expand All @@ -28,5 +48,5 @@
* changed base ailment message
* fixed item pool to only select items with weight
--------------------
**v0.1.0 Alpha**
**v1.0.0**
* Started tracking changes
4 changes: 2 additions & 2 deletions cogs/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ async def encounter(self, ctx, *, ___=None, force=False):
weights = [50, 50, 50]
weights[0] += fastest.agility - ctx.player.agility
weights[2] -= fastest.agility - ctx.player.agility
self.bot.log.debug(
f"encounter weights: {weights}, {random.choices([False, None, True], k=10, weights=weights)}")
# self.bot.log.debug(
# f"encounter weights: {weights}, {random.choices([False, None, True], k=10, weights=weights)}")
ambush = random.choices([False, # Enemy advantage
None, # Regular batle
True], # Player advantage
Expand Down
51 changes: 50 additions & 1 deletion cogs/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import textwrap
import time
from pprint import pformat
from typing import Union

import discord
import import_expression
Expand Down Expand Up @@ -322,6 +323,42 @@ async def reset(self, ctx):
await ctx.message.add_reaction(self.bot.tick_yes)
await self.bot.logout()

@dev.command(name='try')
async def try_(self, ctx, *, command):
nmsg = copy.copy(ctx.message)
nmsg.content = ctx.prefix+command
nctx = await self.bot.get_context(nmsg)
try:
await self.bot.invoke(nctx)
except Exception as e:
await ctx.send_as_paginator(format_exc(e), codeblock=True)

@dev.command(name='as')
async def as_(self, ctx, user: Union[discord.Member, discord.User], *, command):
nmsg = copy.copy(ctx.message)
nmsg.author = user
nmsg.content = ctx.prefix+command
nctx = await self.bot.get_context(nmsg)
await self.bot.invoke(nctx)

@dev.command(name='in')
async def in_(self, ctx, channel: discord.TextChannel, *, command):
nmsg = copy.copy(ctx.message)
nmsg.channel = channel
nmsg.content = ctx.prefix+command
nctx = await self.bot.get_context(nmsg)
await self.bot.invoke(nctx)

@dev.command()
async def at(self, ctx, guild_id: int, *, command):
if not (g := self.bot.get_guild(guild_id)):
return await ctx.send('no guild found')
nmsg = copy.copy(ctx.message)
nmsg.guild = g
nmsg.content = ctx.prefix+command
nctx = await self.bot.get_context(nmsg)
await self.bot.invoke(nctx)

@dev.command()
async def timeit(self, ctx, *, command):
nmsg = copy.copy(ctx.message)
Expand Down Expand Up @@ -416,7 +453,7 @@ async def src(self, ctx, *, command):
await PaginationHandler(self.bot, pg, no_help=True).start(ctx)

@dev.command()
async def giveitem(self, ctx, user: discord.Member, item, count=1):
async def giveitem(self, ctx, user: Union[discord.Member, discord.User], item, count=1):
if user.id not in self.bot.players.players:
return await ctx.send("User has no (cached) player.")
player = self.bot.players.players[user.id]
Expand All @@ -427,6 +464,18 @@ async def giveitem(self, ctx, user: discord.Member, item, count=1):
player.inventory.add_item(item)
await ctx.send(self.bot.tick_yes)

@dev.command()
async def removeitem(self, ctx, user: Union[discord.Member, discord.User], item, count=1):
if user.id not in self.bot.players.players:
return await ctx.send('User has no (cached) player.')
player = self.bot.players.players[user.id]
item = self.bot.item_cache.get_item(item)
if not item:
return await ctx.send('No item found.')
for a in range(count):
player.inventory.remove_item(item)
await ctx.send(self.bot.tick_yes)

@dev.command()
async def update(self, ctx):
"""
Expand Down
2 changes: 1 addition & 1 deletion cogs/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def on_command_error(self, ctx, exc, *, force=False):
if isinstance(exc, commands.CommandInvokeError):
ctx.command.reset_cooldown(ctx)
exc = exc.original
await ctx.send("An internal error occured.")
await ctx.send("An error occured during the execution of this command and has been reported.")
self.bot.send_error(f""">>> Error during execution of command
`{ctx.message.clean_content}`
User: {ctx.author}
Expand Down
73 changes: 22 additions & 51 deletions cogs/help_override.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import os

from discord.ext import commands


class I18nHelpCommand(commands.MinimalHelpCommand):
class I18nHelpCommand(commands.DefaultHelpCommand):
def __init__(self, **options):
super().__init__(**options)
self.commands_heading = "Commands"
self.aliases_heading = "Aliases:"
self.no_category = "No Category"
self.command_attrs = {
'description': "Provides help for various commands.",
'cooldown': commands.Cooldown(3, 5, commands.BucketType.channel),
'cooldown': commands.Cooldown(3, 10, commands.BucketType.channel),
'name': 'help'
}

Expand All @@ -29,53 +27,26 @@ def get_opening_note(self):
async def send_cog_help(self, cog): # no cog specific help
return await self.send_bot_help(self.get_bot_mapping())

async def send_group_help(self, command):
self.paginator.add_line(self.get_command_signature(command), empty=True)
locale = await self.context.bot.redis.get(f"locale:{self.context.author.id}")
if not locale:
locale = 'en_US'
else:
locale = locale.decode()
if not os.path.isfile(f"cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}"):
cmdhelp = command.help
self.context.bot.log.warning(
f"no such file: cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}")
else:
with open(f"cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}") as f:
cmdhelp = f.read().strip()
if not cmdhelp:
cmdhelp = ""
for line in cmdhelp.split('\n'):
self.paginator.add_line(line)
self.paginator.add_line()
self.paginator.add_line(self.get_opening_note(), empty=True)
self.paginator.add_line("**Commands**")
for cmd in sorted(set(command.commands), key=lambda m: m.name):
self.paginator.add_line(f"{self.clean_prefix}{command.qualified_name} {cmd.name}")
await self.send_pages()

async def send_command_help(self, command):
self.paginator.add_line(self.get_command_signature(command), empty=True)
locale = await self.context.bot.redis.get(f"locale:{self.context.author.id}")
if not locale:
locale = 'en_US'
else:
locale = locale.decode()
if not os.path.isfile(f"cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}.scr"):
cmdhelp = command.help
if locale != 'en_US':
self.context.bot.log.warning(
f"no such file: cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}.scr")
else:
with open(f"cogs/help/{locale}/{command.qualified_name.replace(' ', '_')}.scr") as f:
cmdhelp = f.read().strip()
if not cmdhelp:
cmdhelp = ""
for line in cmdhelp.split('\n'):
self.paginator.add_line(line)
self.paginator.add_line()
self.paginator.add_line(self.get_opening_note())
await self.send_pages()
async def filter_commands(self, commands, *, sort=False, key=None):
if sort and key is None:
key = lambda c: c.name
it = filter(lambda c: not c.hidden and c.enabled, commands)
if not self.verify_checks:
return sorted(it, key=key) if sort else list(it)

async def p(cmd):
try:
return await cmd.can_run(self.context)
except commands.CommandError:
return False

fin = []
for cmd in it:
if await p(cmd):
fin.append(cmd)
if sort:
fin.sort(key=key)
return fin


def setup(bot):
Expand Down
Loading

0 comments on commit ba10c6b

Please sign in to comment.