added feed and affection commands, they need to be limited in the future

This commit is contained in:
phixxy 2024-01-09 12:34:10 -08:00
parent 3bb66909e2
commit bed2d75b03

View file

@ -1721,6 +1721,16 @@ 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 give_buddy_food(pkmn_data): #for now this will do the same as affection
return await give_buddy_affection(pkmn_data)
async def give_buddy_affection(pkmn_data):
print(pkmn_data['buddy_xp'])
xp = pkmn_data['buddy_xp']
level = await calc_pkmn_buddy_level(pkmn_data)
pkmn_data['buddy_xp'] += (3*level)
return pkmn_data
async def calc_pkmn_buddy_level(pkmn_json): #this uses the 'fast' xp rate async def calc_pkmn_buddy_level(pkmn_json): #this uses the 'fast' xp rate
buddy_xp = pkmn_json['buddy_xp'] buddy_xp = pkmn_json['buddy_xp']
return min(math.floor(((5*buddy_xp)/4)**(1/3)),100) return min(math.floor(((5*buddy_xp)/4)**(1/3)),100)
@ -1779,7 +1789,7 @@ 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': elif 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)
json_data['nickname'] = nickname json_data['nickname'] = nickname
@ -1788,6 +1798,17 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
await ctx.channel.send(message) await ctx.channel.send(message)
return return
elif arg1 == 'feed' or arg1 == 'hug':
json_data = await load_pokemon(ctx.author.id)
json_data = await give_buddy_affection(json_data)
await save_pokemon(ctx.author.id, json_data)
if json_data['nickname']:
message = "You " + arg1 + ' ' + json_data['nickname']
else:
message = "You " + arg1 + ' ' + json_data['name']
await ctx.channel.send(message)
return
#Default !pokemon behavior (Load and show pokemon embed) #Default !pokemon behavior (Load and show pokemon embed)
discord_id = ctx.author.id discord_id = ctx.author.id
buddy_json = await load_pokemon(discord_id) buddy_json = await load_pokemon(discord_id)