added pokemon xp gain on message, and added level calc
This commit is contained in:
parent
1e6f1019f1
commit
906e58bdb5
1 changed files with 22 additions and 8 deletions
|
|
@ -1721,6 +1721,10 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
json_data = await get_json(url)
|
json_data = await get_json(url)
|
||||||
return json_data
|
return json_data
|
||||||
|
|
||||||
|
async def calc_pkmn_buddy_level(pkmn_json): #this uses the 'fast' xp rate
|
||||||
|
buddy_xp = pkmn_json['buddy_xp']
|
||||||
|
return math.floor(((5*buddy_xp)/4)**(1/3))
|
||||||
|
|
||||||
async def make_pmkn_embed(pkmn_dict):
|
async def make_pmkn_embed(pkmn_dict):
|
||||||
if pkmn_dict['nickname']:
|
if pkmn_dict['nickname']:
|
||||||
title = pkmn_dict['nickname'] + ' (' + pkmn_dict['name'].capitalize() + ')'
|
title = pkmn_dict['nickname'] + ' (' + pkmn_dict['name'].capitalize() + ')'
|
||||||
|
|
@ -1732,7 +1736,7 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
else:
|
else:
|
||||||
embed.set_image(url=pkmn_dict['sprites']['front_default'])
|
embed.set_image(url=pkmn_dict['sprites']['front_default'])
|
||||||
nature = pkmn_dict['nature']
|
nature = pkmn_dict['nature']
|
||||||
buddy_level = pkmn_dict['buddy_level']
|
buddy_level = await calc_pkmn_buddy_level(pkmn_dict)
|
||||||
buddy_xp = pkmn_dict['buddy_xp']
|
buddy_xp = pkmn_dict['buddy_xp']
|
||||||
types = []
|
types = []
|
||||||
for key in pkmn_dict['types']:
|
for key in pkmn_dict['types']:
|
||||||
|
|
@ -1744,6 +1748,8 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
embed.add_field(name="Types", value=type_str, inline=False)
|
embed.add_field(name="Types", value=type_str, inline=False)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def add_pkmn_reacts(message):
|
async def add_pkmn_reacts(message):
|
||||||
await message.add_reaction('🥰')
|
await message.add_reaction('🥰')
|
||||||
await message.add_reaction('🍙')
|
await message.add_reaction('🍙')
|
||||||
|
|
@ -1773,9 +1779,6 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
await ctx.channel.send("You already have a pokemon!")
|
await ctx.channel.send("You already have a pokemon!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if arg1 == 'nick' or arg1 == 'nickname':
|
if arg1 == 'nick' or arg1 == 'nickname':
|
||||||
nickname = arg2
|
nickname = arg2
|
||||||
json_data = await load_pokemon(ctx.author.id)
|
json_data = await load_pokemon(ctx.author.id)
|
||||||
|
|
@ -1796,9 +1799,6 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
await add_pkmn_reacts(message)
|
await add_pkmn_reacts(message)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bot.command(
|
@bot.command(
|
||||||
description="Pokedex",
|
description="Pokedex",
|
||||||
help="Get information on pokemon",
|
help="Get information on pokemon",
|
||||||
|
|
@ -1890,6 +1890,17 @@ async def on_reaction_add(reaction, user):
|
||||||
await message.add_reaction(emoji)
|
await message.add_reaction(emoji)
|
||||||
|
|
||||||
|
|
||||||
|
async def pkmn_msg(discord_id):
|
||||||
|
path = "databases/pokemon/"+str(discord_id)+'.json'
|
||||||
|
if os.path.isfile(path):
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
json_data = json.loads(f.readline())
|
||||||
|
json_data['buddy_xp'] += random.randint(1,5)
|
||||||
|
json_data = json.dumps(json_data)
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.writelines(json_data)
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_message(ctx):
|
async def on_message(ctx):
|
||||||
|
|
||||||
|
|
@ -1898,6 +1909,9 @@ async def on_message(ctx):
|
||||||
channel_vars = await get_channel_config(ctx.channel.id)
|
channel_vars = await get_channel_config(ctx.channel.id)
|
||||||
chat_history_string = await log_chat_and_get_history(ctx, logfile, channel_vars)
|
chat_history_string = await log_chat_and_get_history(ctx, logfile, channel_vars)
|
||||||
|
|
||||||
|
#add pokemon xp
|
||||||
|
await pkmn_msg(ctx.author.id)
|
||||||
|
|
||||||
#handle non-text channels (dms, etc)
|
#handle non-text channels (dms, etc)
|
||||||
if ctx.channel.type.value != 0 and ctx.author.id != 242018983241318410:
|
if ctx.channel.type.value != 0 and ctx.author.id != 242018983241318410:
|
||||||
#This used to notify the user it cannot respond in this channel, but that spammed threads
|
#This used to notify the user it cannot respond in this channel, but that spammed threads
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue