Closed nurkittel closed 3 months ago
Yes this is correct. Basically => If your pokemon gets enough XP - more then needed for the next lvl => it reaches the next level and xp is set to 0.
I may need to re-do the logic in the future and correctly calculate the xp.
not sure if you fixed it already and just haven't put it into the change notes for 1.27 but I looked at the function save_main_pokemon_progress
and the issue lies with the line mainpokemon_xp = 0
. It needs to be changed to:
mainpokemon_xp = int(mainpokemon_xp) - int(experience)
With just this change, you would only level up once per fight, even if you have enough exp to level up more than once. This should occur rather seldomly, but it can also be easily fixed by changing the levelup event listener (if int(experience) < int(mainpokemon_xp) and mainpokemon_level != 100
) to a while loop (the corresponding else
can be left as is):
while int(experience) < int(mainpokemon_xp) and mainpokemon_level != 100
(...)
else
msg = ""
msg += f"Your {mainpokemon_name} has gained {exp} XP.\n {experience} exp is needed for next level \n Your pokemon currently has {mainpokemon_xp}"
(...)
Tested it and it works 👍
Note that the part within else
is only executed when the while
loop terminates naturally (by its condition becoming false), but not if you at some point decided to add a break
command somewhere in the while
loop.
Hi,
I don't know if it's supposed to be like that but every time my Pokemon reached a new level my XP-Bar was 0 and the EXP from the previous fight did not transfer to the new level. See screenshots.