Skip to content

Comments

fix:Status healing berries preventing from healing-by-rest#77

Open
gikouw wants to merge 3 commits intoFlame442:masterfrom
gikouw:rest-berry-heal-fix
Open

fix:Status healing berries preventing from healing-by-rest#77
gikouw wants to merge 3 commits intoFlame442:masterfrom
gikouw:rest-berry-heal-fix

Conversation

@gikouw
Copy link
Contributor

@gikouw gikouw commented Nov 7, 2024

Previously
The eat_berry function was called before healing and healing was bounded with the condition of sleep which can be already cured by lum berry or chesto berry therefore the pokemon never gets healed

Changes
Moved the healing block of code into the apply status function itself.
healing the pokemon(move user) if the status being applied is sleep(by self) and the pokemon is successfully induced to sleep and the last move used is rest
now, eat_berry function is called after healing.

the only way this could break is if the (last move stays rest(of the user) AND the sleep status is applied by some other behavior by the user)
which is not possible as of my understanding

self.current = status
self.sleep_timer.set_turns(turns)
msg += f"{self.pokemon.name} fell asleep{source}!\n"
if self.pokemon.last_move.effect == 38:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to #76, the more correct way to check for the move is the use the move argument to apply_status. That ensures the move is being used to apply the status, rather than just hoping the last move is the correct one.

@@ -700,9 +700,6 @@ def use(self, attacker, defender, battle, *, use_pp=True, override_sleep=False,
msg += defender.nv.apply_status("sleep", battle, attacker=attacker, move=self)
if self.effect == 38:
msg += attacker.nv.apply_status("sleep", battle, attacker=attacker, move=self, turns=3, force=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment here that the healing logic is handled in apply_status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants