added time limits to pkmn feed and pkmn hug
This commit is contained in:
parent
bed2d75b03
commit
0bda0fd390
1 changed files with 61 additions and 21 deletions
|
|
@ -1722,14 +1722,32 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
return json_data
|
return json_data
|
||||||
|
|
||||||
async def give_buddy_food(pkmn_data): #for now this will do the same as affection
|
async def give_buddy_food(pkmn_data): #for now this will do the same as affection
|
||||||
return await give_buddy_affection(pkmn_data)
|
try:
|
||||||
|
last_food = pkmn_data['last_food']
|
||||||
|
except:
|
||||||
|
last_food = 0
|
||||||
|
this_food = time.time()
|
||||||
|
if (this_food - last_food) >= 1800:
|
||||||
|
pkmn_data['last_food'] = this_food
|
||||||
|
level = await calc_pkmn_buddy_level(pkmn_data)
|
||||||
|
pkmn_data['buddy_xp'] += (4*level)
|
||||||
|
return pkmn_data, True
|
||||||
|
else:
|
||||||
|
return pkmn_data, False
|
||||||
|
|
||||||
async def give_buddy_affection(pkmn_data):
|
async def give_buddy_affection(pkmn_data):
|
||||||
print(pkmn_data['buddy_xp'])
|
try:
|
||||||
xp = pkmn_data['buddy_xp']
|
last_hug = pkmn_data['last_hug']
|
||||||
level = await calc_pkmn_buddy_level(pkmn_data)
|
except:
|
||||||
pkmn_data['buddy_xp'] += (3*level)
|
last_hug = 0
|
||||||
return pkmn_data
|
this_hug = time.time()
|
||||||
|
if (this_hug - last_hug) >= 600:
|
||||||
|
pkmn_data['last_hug'] = this_hug
|
||||||
|
level = await calc_pkmn_buddy_level(pkmn_data)
|
||||||
|
pkmn_data['buddy_xp'] += (3*level)
|
||||||
|
return pkmn_data, True
|
||||||
|
else:
|
||||||
|
return pkmn_data, False
|
||||||
|
|
||||||
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']
|
||||||
|
|
@ -1758,12 +1776,6 @@ 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):
|
|
||||||
await message.add_reaction('🥰')
|
|
||||||
await message.add_reaction('🍙')
|
|
||||||
|
|
||||||
if arg1=='start':
|
if arg1=='start':
|
||||||
if not os.path.isdir("databases/pokemon/"):
|
if not os.path.isdir("databases/pokemon/"):
|
||||||
os.makedirs("databases/pokemon/")
|
os.makedirs("databases/pokemon/")
|
||||||
|
|
@ -1781,6 +1793,8 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
json_data['nature'] = nature
|
json_data['nature'] = nature
|
||||||
json_data['buddy_level'] = 1
|
json_data['buddy_level'] = 1
|
||||||
json_data['buddy_xp'] = 0
|
json_data['buddy_xp'] = 0
|
||||||
|
json_data['last_food'] = 0
|
||||||
|
json_data['last_hug'] = 0
|
||||||
await save_pokemon(ctx.author.id, json_data)
|
await save_pokemon(ctx.author.id, json_data)
|
||||||
embed = await make_pmkn_embed(json_data)
|
embed = await make_pmkn_embed(json_data)
|
||||||
await ctx.channel.send(embed=embed)
|
await ctx.channel.send(embed=embed)
|
||||||
|
|
@ -1798,16 +1812,43 @@ 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':
|
elif arg1 == 'feed':
|
||||||
json_data = await load_pokemon(ctx.author.id)
|
json_data = await load_pokemon(ctx.author.id)
|
||||||
json_data = await give_buddy_affection(json_data)
|
json_data, fed = await give_buddy_food(json_data)
|
||||||
await save_pokemon(ctx.author.id, json_data)
|
if fed:
|
||||||
if json_data['nickname']:
|
await save_pokemon(ctx.author.id, json_data)
|
||||||
message = "You " + arg1 + ' ' + json_data['nickname']
|
if json_data['nickname']:
|
||||||
|
message = "You " + arg1 + ' ' + json_data['nickname']
|
||||||
|
else:
|
||||||
|
message = "You " + arg1 + ' ' + json_data['name']
|
||||||
|
await ctx.channel.send(message)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
message = "You " + arg1 + ' ' + json_data['name']
|
if json_data['nickname']:
|
||||||
await ctx.channel.send(message)
|
message = "Your " + json_data['nickname'] + " isn't hungry!"
|
||||||
return
|
else:
|
||||||
|
message = "Your " + json_data['name'] + " isn't hungry!"
|
||||||
|
await ctx.channel.send(message)
|
||||||
|
return
|
||||||
|
|
||||||
|
elif arg1 == 'hug':
|
||||||
|
json_data = await load_pokemon(ctx.author.id)
|
||||||
|
json_data, hugged = await give_buddy_affection(json_data)
|
||||||
|
if hugged:
|
||||||
|
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
|
||||||
|
else:
|
||||||
|
if json_data['nickname']:
|
||||||
|
message = "You hugged " + json_data['nickname'] + " but " + json_data['nickname'] + " has been hugged recently."
|
||||||
|
else:
|
||||||
|
message = "You hugged " + json_data['name'] + " but " + json_data['name'] + " has been hugged recently."
|
||||||
|
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
|
||||||
|
|
@ -1817,7 +1858,6 @@ async def pokemon(ctx, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||||
else:
|
else:
|
||||||
embed = await make_pmkn_embed(buddy_json)
|
embed = await make_pmkn_embed(buddy_json)
|
||||||
message = await ctx.channel.send(embed=embed)
|
message = await ctx.channel.send(embed=embed)
|
||||||
await add_pkmn_reacts(message)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@bot.command(
|
@bot.command(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue