Commit Graph

369 Commits

Author SHA1 Message Date
Kevin Lau
0bbd3650b7 Normalize ModifySpe calculations with the other Modify-Stat events
The current implementation of ModifyAtk, ModifyDef, etc. is to pass the
actual stat into the event, have event handlers run battle.chainModify(),
ModifySpe passes in a modifier variable, calls battle.chain(), and then
ends with battle.modify() using the modifier variable. The way chainModify
is implemented within the event system also means that it chains together
modifiers in the same manner and finishes with battle.modify(), meaning
that there is no need for ModifySpe to use battle.chain() and
battle.modify() manually.

This also fixes the effect of BattlePokemon#getStat on stats other than
speed.
2015-07-24 12:19:42 -07:00
Guangcong Luo
5d3cd8263c More updates to Endless Battle Clause
- Gen 1 PP overflow makes a Pokemon stale
- Staleness warnings now specify the staleness source
- Half-staleness also warns, if another pokemon is already stale

Warning on half-staleness helps remind people who seem to think
they've beaten Endless Battle Clause after 5-ish turns, when it
takes 10-20 turns for some staleness verdics, especially if
there's a lot of switching going on.
2015-07-24 03:33:28 -04:00
Guangcong Luo
cab10bbdb8 Update Endless Battle Clause
Virtual (Transformed/Mimiced) self-switch (U-turn/Pass/etc) moves
now count as PP stalling.
2015-07-22 18:15:21 -04:00
Guangcong Luo
ddb8b7f7a3 Minor Endless Battle Clause update 2015-07-22 04:22:32 -04:00
Guangcong Luo
c8c03ad92d Update Endless Battle Clause
The full description is in the comments of the Endless Battle
Clause entry in rulesets.js.

This update fixes a lot of the issues with yesterday's version.

Also included: A minor refactor of deductPP, which did not need
a success variable.
2015-07-22 03:41:43 -04:00
Guangcong Luo
9bf3517f2e Implement New Endless Battle Clause
The new Endless Battle Clause attempts to ban endless battles by
detecting situations in which a battle could become endless.

This approach bans endless battles without banning Leppacycling.

The exact formulation is:

A Pokémon is considered cornered if:

- it has no available moves other than Struggle
- OR a stale Pokémon used Assist Whirlwind on it
- OR it has been hit by a Struggle from a stale Pokémon on the turn
  it switched in

(at the beginning of a turn, if you have available moves other than
Struggle, you are no longer cornered)

A Pokémon is considered stale if:

- it has gained a Leppa berry through any means besides starting
  with one (including but not limited to Harvest, Recycle, Pickup,
  Symbiosis, Bestow, Thief, Switcheroo, and Magician)
- OR it has been targeted with Fling Leppa Berry
- OR it is cornered and begins a turn with more HP than it the last
  turn it began
- OR it is cornered and begins a turn with as much HP as the last
  turn it began, and was not fully paralyzed, loafing around from
  Truant, or immobilized from Attract
- OR it uses Transform/Imposter against a stale Pokémon

(a Pokémon that becomes stale stays stale for the rest of the match)

If all active Pokémon are stale, the player whose team originally
started with a Leppa Berry loses. If both or neither team started
with a Leppa Berry, the team that had the first stale Pokémon wins.
2015-07-21 06:38:22 -04:00
Kevin Lau
58f4c1e145 Update priority of switches when a player has no actives
Switches and runSwitch were recently updated to priority 7 and 7.1, so
this part needs to be updated as well.
2015-07-20 16:58:54 -07:00
Kevin Lau
3ecb7ac301 Fix crash in BattlePokemon#getMoveTargets 2015-07-17 16:53:48 -07:00
Guangcong Luo
0eb6f4b244 Merge pull request #2006 from ascriptmaster/move-fixes-2
Fix PP deduction interactions with Pressure
2015-07-17 13:40:19 -05:00
Kevin Lau
b0e1fd5789 Fix Pressure's interaction with multi-target moves and Follow Me
Implement new function getMoveTargets to list all move targets given a
user and a move. Refactor Battle system to remove redundancies with
checking move targets. Run the RedirectTarget in this function instead of
later after TryMove, since technically single-target moves changing
targets should occur before the move is attempted.

Refactor the DeductPP event to be a singleEvent that targets the Pokemon's
ability instead of a global event. Run this event on the move's targets as
calculated by BattlePokemon#getMoveTargets.
2015-07-17 01:47:55 -07:00
Guangcong Luo
3bde6c758b Merge pull request #2050 from ascriptmaster/tests
Fix Mold Breaker interaction with Damp
2015-07-16 16:36:43 -05:00
Konrad Borowski
c0b71f03b7 Show that weather began even under Air Lock effect 2015-07-16 16:12:47 +02:00
Guangcong Luo
3f41b76059 Support forcing priority 0 in .resolvePriority 2015-07-16 02:20:35 -04:00
Kevin Lau
783d43bd93 Fix Mold Breaker interaction with Damp
Damp should be suppressed by Mold Breaker.
2015-07-15 14:48:58 -07:00
Kevin Lau
40f7e02f70 Don't let Cloud Nine suppress Residual or End events from weathers
This allows the client to remove the weather when it expires, even if
there is a Cloud Nine Pokemon on the field.
2015-07-14 14:54:31 -07:00
Guangcong Luo
975d156243 Update turn order comments 2015-07-12 04:29:22 -04:00
Guangcong Luo
2ea5907f65 Refactor battle turn order
Instead of automatically sorting the queue, the queue is now only
sorted manually when committing decisions.
2015-07-11 18:10:11 -04:00
Ivo Julca
ac41d54c64 Revert removal of scripts installation on Tools
It breaks team validation (tools.gen no longer exists).
2015-07-10 17:45:39 -05:00
Marty-D
5282b770de Gen I: Fix Mimic
- Mimic can copy any move
- Mimic can be used while Transformed
- Mimic uses its own PP for copied moves, even if its current PP is
greater than the maximum PP of the copied move
2015-07-10 14:33:43 -04:00
Ivo Julca
cee748b28d Shrink needlessly long prototype chains for battles
Properties should now be searched in this order:
- Instance
- Scripts installed
- Battle.prototype properties
- Tools properties
- Object properties
2015-07-09 00:48:53 -05:00
Ivo Julca
9cec432a99 Fix toId on numbers 2015-07-07 12:06:23 -05:00
Guangcong Luo
8c3a5cabe4 Merge pull request #2035 from ascriptmaster/move-fixes
Fix behavior with Ability activation in double-KO scenarios
2015-07-07 02:59:03 -05:00
Kevin Lau
70c8ca45ff Fix behavior with Ability activation in double-KO scenarios
Add new function battle.insertQueue that inserts a decision into the
correct position in an already-sorted queue instead of re-sorting. Also,
to prevent code reuse, add new funciton battle.resolvePriority to deal
with shared code between battle.addQueue and battle.insertQueue.
2015-07-06 20:33:40 -07:00
Kevin Lau
be03f23c78 Replace TryWeather event with battle.suppressingWeather 2015-07-06 17:00:41 -07:00
Ivo Julca
e92bb1b07f Rename globals toName|toString to Tools.[getName|getString] 2015-07-06 00:34:44 -05:00
Guangcong Luo
9d79f72418 Merge pull request #1999 from ascriptmaster/move-fixes
Fix Quash interaction with self-switching moves
2015-07-02 07:34:06 +00:00
Marty-D
6884a04951 Fix Prankster Helping Hand "outspeeding" switches
And Mega Evolution
2015-06-28 20:45:31 -04:00
Kevin Lau
fce231cc48 Various Item removal fixes
Knock Off no longer broadcasts the source so Arceus can knock off a Plate
from a non-Arceus, Genesect can knock off a Drive, etc. Updated Sticky
Hold to check for Knock Off specifically as a result.

TakeItem is no longer suppressed by Mold Breaker, fixing interaction with
Unburden. Updated Sticky Hold to check for Mold Breaker instead.

Items that prevent their own removal do not have that effect negated by
Klutz and other item-negating effects.

Thief and Covet can steal Mail.
2015-06-28 16:53:47 -07:00
Kevin Lau
99c14487d6 runSwitch decisions no longer re-sort queue when added 2015-06-27 00:10:36 -07:00
Marty-D
694fda0662 Gen V, VI: Fix Abilities and items working while inactive
- Fixes Doom Desire and Future Sight getting boosted by effects such as
Choice Specs while their user is inactive
2015-06-26 21:51:39 -04:00
Kevin Lau
f0206228cb Cut down on debug messages emitted in runEvent
This line of code was emitting a lot of debug messages that are presented
without context and can be confusing to viewers of the battle log.
2015-06-23 21:27:28 -07:00
Kevin Lau
db2aed22c3 Include use case for Belly Drum in Battle#boost 2015-06-18 15:06:51 -07:00
Kevin Lau
903853d91b Battle refactor: No longer reset negated immunity in pokemon.update()
Replace the pokemon.negateImmunity object with a new `NegateImmunity`
event that handles all the immunity negation.

Also deprecate 'IgnoreEffectiveness' in favor of having relevant moves
and items use `Effectiveness` event handlers instead.
2015-06-16 00:02:06 -07:00
Guangcong Luo
cf112d1d3c Merge pull request #1945 from Slayer95/jscs-rules
Implement custom JSCS rules to enforce code style
2015-06-13 06:18:24 +00:00
Kevin Lau
5bde84fd6d Style Change: suppressAttackEvents -> suppressingAttackEvents
The new function name makes it clear that the function doesn't actually
suppress attack events, only checks if they would be suppressed.
2015-06-12 16:22:32 -07:00
DanUgore
845b9fbea6 Revert 848992001e 2015-06-12 10:58:24 -04:00
Ivo Julca
f18eef39ca Fix Travis build 2015-06-12 03:41:22 -05:00
Guangcong Luo
83a3540886 Merge pull request #1908 from ascriptmaster/tests
Add option for Mocha tests to use event handlers
2015-06-09 23:03:37 +00:00
Guangcong Luo
a62d297b22 Merge pull request #1923 from ascriptmaster/move-fixes
Fix some Mold Breaker bugs with drag-out moves
2015-06-09 15:58:35 +00:00
Marty-D
2a8b8cfeed Gen II: Run AfterSwitchInSelf event properly 2015-06-09 10:47:22 -04:00
Kevin Lau
45e15bbd6e Add option for Mocha tests to use event handlers
Creates a new function Battle#on that allows tests and potentially formats
to add new event handlers to a battle. These handlers can then be picked
up by the battle engine for consumption.

At any rate, it's more efficient than hotpatching the getEvent function
within a Mocha test.
2015-06-09 03:42:16 -07:00
Kevin Lau
1da65efb12 Fix some Mold Breaker bugs with drag-out moves
- Process the 'runSwitch' decision directly in Battle#dragIn in gen
  5 and up. This allows the Pokemon executing the drag-out move to
  remain as battle.activePokemon for the duration of the dragging
  action. This fixes Mold Breaker's interaction when moves that drag
  out Pokemon are used.
- Add a check for battle.activePokemon.isActive in the Mold Breaker
  ability activation check to prevent glitches with Red Card.
- Remove Damage/SubDamage from Mold Breaker's check and instead add
  an additional check for the Damage event specifically to use extra
  criteria. This fixes its interaction with Magic Guard.
2015-06-09 03:09:06 -07:00
Marty-D
3f997d71dd Ensure confusion damage does not break Illusion 2015-06-06 23:43:21 -04:00
Guangcong Luo
e656c83fbc Fix Focus Sash and Confusion interaction 2015-06-06 17:56:39 -04:00
Kevin Lau
038d4e91fe Belch cannot be selected if the Pokemon has not eaten a berry
https://www.youtube.com/watch?v=paMtFIVWRkQ&t=6m33s
2015-06-03 20:04:13 -07:00
Kevin Lau
d2360a08ba Fix Mold Breaker's interaction with Unaware
It should compare this.activePokemon to "thing", which is the Pokemon that
is holding the Ability being processed, not "target".

Also fixed random typo where Mold Breaker might succeed even if the
ability were supressed.
2015-05-31 03:57:02 -07:00
Guangcong Luo
bc789f8d7f Merge pull request #1906 from ascriptmaster/tests
Battle Engine no longer sets EVs to 84 with blank EV sets
2015-05-30 02:00:09 +00:00
Kevin Lau
9979b0964e Battle Engine no longer sets EVs to 84 with blank EV sets
This system is problematic for people who enter games without having
filled out their EVs, as their stats will not reflect the stats shown
in the teambuilder and can influence damage calculations, resulting in
many erroneous bug reports.
2015-05-29 11:30:45 -07:00
Guangcong Luo
066b1d6828 Merge pull request #1865 from ascriptmaster/move-fixes
Battle refactor: No longer reset ignore in Battle#update
2015-05-27 01:11:34 +00:00
Guangcong Luo
b7aa629703 Merge pull request #1889 from ascriptmaster/move-fixes-2
Battle refactor: New function isGrounded(), bug fixes
2015-05-26 07:09:19 +00:00