Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

White Herb doubles fix #5185

Closed
wants to merge 28 commits into from
Closed

Conversation

littlefoot22
Copy link
Contributor

#2367

White Herb doesn't work with doubles.

Not sure if I have the right approach here...please comment if not,

Thanks!!

battle.destroy();
});

it('it should use white herb after both intimidate', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave off the extra “it” here; that’s what the function name is for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks !! Removed

data/items.js Outdated
@@ -5978,14 +5978,18 @@ let BattleItems = {
let activate = false;
/**@type {{[k: string]: number}} */
let boosts = {};
//doubles
if (pokemon.side.foe.pokemon.length > 1 && pokemon.side.foe.battle.abilityOrder !== 4) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (pokemon.side.foe.pokemon.length > 1 && pokemon.side.foe.battle.abilityOrder !== 4) {
if (pokemon.side.active.length > 1 && this.abilityOrder !== 4) {

@Marty-D
Copy link
Collaborator

Marty-D commented Feb 21, 2019

There are a few problems here; this kind of fix only works before Turn 1 and not when multiple Pokemon are replacing fainted ones at the end of a turn, but more importantly White Herb itself would only work while those four lead Pokemon are on the field and won't ever activate again for anything in Doubles. abilityOrder keeps counting up with every Ability change or switch in.

@littlefoot22
Copy link
Contributor Author

There are a few problems here; this kind of fix only works before Turn 1 and not when multiple Pokemon are replacing fainted ones at the end of a turn, but more importantly White Herb itself would only work while those four lead Pokemon are on the field and won't ever activate again for anything in Doubles. abilityOrder keeps counting up with every Ability change or switch in.

Thank you for the feed back!! I had a feeling I didn't fully understand the variables I was using, I will do more testing and work on this bug some more

@pyuk-bot
Copy link
Contributor

What if we made the Update event only happen after all switching is finished?

@pyuk-bot
Copy link
Contributor

If multiple Talonflames holding Sitrus Berries switch into Stealth Rock, do the berries wait until all Pokémon have switched in?

@Marty-D
Copy link
Collaborator

Marty-D commented Feb 21, 2019

If multiple Talonflames holding Sitrus Berries switch into Stealth Rock, do the berries wait until all Pokémon have switched in?

Nope, Berries activate as soon as each one takes the hazard damage, like switch-in Abilities. That's actually why Unnerve activates before hazards, so it can stop faster Pokemon from healing in those situations.

Edit: Wow, I misread your question completely. Yes they wait until all Pokemon have switched in (but so does hazard damage).

@littlefoot22
Copy link
Contributor Author

@Marty-D @Zarel @MacChaeger updated the PR with a new approach, running the update after the queue is empty to make sure it happens after all switch-ins happen. Is there a better way to do this? Is there an issue with this approach?

@littlefoot22
Copy link
Contributor Author

There are a few problems here; this kind of fix only works before Turn 1 and not when multiple Pokemon are replacing fainted ones at the end of a turn, but more importantly White Herb itself would only work while those four lead Pokemon are on the field and won't ever activate again for anything in Doubles. abilityOrder keeps counting up with every Ability change or switch in.

Hi @Marty-D, updated the PR with a new solution and tests based on your feedback.

@Marty-D
Copy link
Collaborator

Marty-D commented Feb 27, 2019

This new approach also doesn't work because the queue isn't empty during a turn, for example:

The opposing Gyarados used Sleep Talk!
But it failed!

The opposing Incineroar used Sleep Talk!
But it failed!

Clefable used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Clefable fainted!
Chansey used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Chansey fainted!

The opposing Incineroar returned its status to normal using its White Herb!

White Herb should activate before Chansey moves here.

@littlefoot22
Copy link
Contributor Author

This new approach also doesn't work because the queue isn't empty during a turn, for example:

The opposing Gyarados used Sleep Talk!
But it failed!

The opposing Incineroar used Sleep Talk!
But it failed!

Clefable used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Clefable fainted!
Chansey used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Chansey fainted!

The opposing Incineroar returned its status to normal using its White Herb!

White Herb should activate before Chansey moves here.

got it, will do more testing and work on it, appreciate you taking a look!

@littlefoot22
Copy link
Contributor Author

littlefoot22 commented Mar 4, 2019

This new approach also doesn't work because the queue isn't empty during a turn, for example:

The opposing Gyarados used Sleep Talk!
But it failed!

The opposing Incineroar used Sleep Talk!
But it failed!

Clefable used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Clefable fainted!
Chansey used Memento!
The opposing Incineroar's Attack fell harshly!
The opposing Incineroar's Special Attack fell harshly!

Chansey fainted!

The opposing Incineroar returned its status to normal using its White Herb!

White Herb should activate before Chansey moves here.

@Marty-D I updated the PR, would something like this work? onResidual runs after both intimidates activate for doubles and we can keep the update to run only after moves that decrees stats like tailwhip/growl/stringshot etc ?

EDIT

updated the PR to include this code to just check if last move had a negative boost instead of hardcoding the moves in the conditional:

let lastMoveAttackDown = false;
if (this.lastMove && this.lastMove.boosts) {
	for (let i in this.lastMove.boosts) {
		// @ts-ignore
		if (this.lastMove.boosts[i] < 0) {
			lastMoveAttackDown = true;
			break;
		}
	}
}


let battle;

describe('White Herb 5678765567', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Debugging artifact, I presume?

Suggested change
describe('White Herb 5678765567', function () {
describe('White Herb', function () {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup :D will remove

assert.false.holdsItem(holder);
assert.statStage(holder, 'atk', 0);
});
it('should use white herb after two intimidate switch in', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Switching in during a turn (one at a time) is fundamentally different from switching in at the beginning of a battle or to replace fainted Pokemon (all at once). This test you're doing here should activate White Herb before the second Pokemon even switches out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok makes sense, will update the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching in during a turn (one at a time) is fundamentally different from switching in at the beginning of a battle or to replace fainted Pokemon (all at once). This test you're doing here should activate White Herb before the second Pokemon even switches out.

@Marty-D

It seems runSwitch remains in queue when Pokemon are switching in at start or after feint. Checking for this before the update leads to White Herb being called after all Pokemon switch in after start or after feint and calls it right away after a player switches during a turn. Is this correct behavior?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should use white herb after two intimidate switch in', function () {
it('should use white herb after two Intimidate switch in', function () {

data/items.js Outdated
@@ -6009,9 +6009,17 @@ let BattleItems = {
},
},
onUpdate(pokemon) {
if ((this.gameType === "doubles")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look like a good idea to me, since it's too specific, but do you even need it any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably not I was going to add some tests for singles and test without the check

@pyuk-bot
Copy link
Contributor

I wonder if it'd work to run the SwitchIn event the way we run spread moves. Could we pass all the currently switching Pokemon to runEvent in an array?

@littlefoot22
Copy link
Contributor Author

@MacChaeger not sure I understand what your proposing, would this be to check if more Pokemon are about to be switched in ?

@AnnikaCodes
Copy link
Collaborator

Old PR from someone who's no longer contributing.

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.

6 participants