Commit Graph

95 Commits

Author SHA1 Message Date
Guangcong Luo
246dfa1da3 Refactor in-object-literal to array-includes (#4079)
Previously, if we wanted to test if A was either 'B' or 'C', we would use
the pattern:

    A in {B:1, C:1}

I actually don't know how common this pattern is; I just started using
it because I was tired of typing `A === 'B' || A === 'C'` all the time.
I never really liked it, though; the `:1` part made it kind of
blatantly a hack.

I did some testing and `['B', 'C'].includes(A)` is overall faster.

(A switch statement is around 20x faster still, but who wants to type
that much code?)

Anyway, the new standard is

    ['B', 'C'].includes(A)

Something something progress!
2017-10-23 09:19:15 -05:00
Marty-D
ea05191949 Gen II: Fix Beat Up again 2017-10-08 11:56:34 -04:00
Guangcong Luo
4098383f65 Fix Gen 2 paralysis Spe 2017-10-07 23:39:56 -05:00
Marty-D
7b5bd035e9 Gen II: Hardcode Beat Up stat replacement
Fixes the `ModifyAtk` bug and brings it in line with every other effect in Gen 2, plus actually implements the level part of Beat Up.
2017-10-07 20:28:00 -04:00
urkerab
661e887415 Pass the active move when modifying stats (#4038) 2017-10-04 16:17:50 -05:00
urkerab
0aafc2ac73 Gen II: Remove bogus Illusion check (#4010) 2017-09-22 20:31:33 -04:00
Guangcong Luo
3b4d8b3ff0 Split random-teams.js out of scripts.js
Random team generation scripts are no longer in scripts.js, but instead
in a new file random-teams.js.

The scripts are now also no longer run from inside battles, but in a
new team generator object. This makes it easier for external scripts
to generate random teams by running Dex.generateTeam(format).
2017-07-25 02:59:59 -04:00
xCrystal
6782b32973 Gen 2: Fix items like Thick Club on nicknamed Pokemon (#3658) 2017-06-19 03:30:42 -07:00
xCrystal
07bbdd0ab9 Gen 2 Random Battles: General update and improvements (#3601) 2017-06-18 20:05:44 -07:00
QuiteQuiet
22a14e4442 Gen 2: Correctly calculate confusion damage (#3629)
Closes #3229

- Applies item modifiers when relevant
- GSC doesn't have a damage rolls for confusion damage
2017-06-13 21:33:52 -05:00
Marty-D
a12a01a638 Gen II: Fix Lock-On interaction with Dig/Fly
Fixes #3311
2017-03-03 22:05:07 -05:00
Guangcong Luo
ec9af0968b Fix Amnesia in Gen 2 randbat
It should not be counted as a special attacking setup move.

Fixes #3225
2017-02-10 17:11:06 -05:00
Guangcong Luo
bf4e3df3b8 Deprecate decision.targetSide/targetPosition
These are no longer used; we now only use targetLoc.
2016-12-26 17:12:40 -05:00
Marty-D
aac63d3e26 Fix various issues with Bide
Corrects all of the following
Gen 2: lasts 2-3 turns
Gen 3: can't hit Ghosts
Gen 4: can hit Ghosts, stops immediately when the user falls asleep or
becomes frozen
Gens 2-6: Stops immediately when the user is prevented from moving
2016-10-06 21:33:30 -04:00
Marty-D
71c1858168 Gen II: Fix order of drag-outs and residual damage 2016-09-16 17:13:24 -04:00
Marty-D
c74aa8dcc2 Gen II: Fix Random Battle genders 2016-07-21 19:06:52 -04:00
urkerab
be0f9d3be2 Show ability activation when it causes an immunity (#2555)
- Also improve `trySetStatus` and `moveHit` implementations
2016-05-22 18:44:54 -04:00
Marty-D
fc86e0ef0a Prevent confusion damage from being a critical hit 2016-05-05 23:44:58 -04:00
Ivo Julca
0281176fd1 Remove usage of Array|Object methods implemented by Sugar.js
Adds a dependency to shim Object.values until it's natively available.
2016-03-09 16:55:34 -05:00
Guangcong Luo
794d160eec Refactor runImmunity
BattlePokemon#runImmunity is now two functions, runImmunity and
runStatusImmunity.

The split is helpful because: 1. NegateImmunity only applies to type
immunities, and 2. Immunity only applies to status immunities and
Ground immunities.

Ground immunities are now entirely handled hardcoded in isGrounded.

This overall doesn't have a noticeable impact on performance, but
it makes certain things behave more predictably, and correctly
shows the ability activation for Levitate, so I assume that means it's
a net positive. I hope I at least improved readability...
2016-02-19 05:18:40 -06:00
Marty-D
afe31af0b4 Gen II: Fix critical hit interaction with screens 2016-02-15 23:16:07 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
The Immortal
2e85f15d51 Gen 2: Change back IVs variable 2015-12-29 22:34:59 +04:00
The Immortal
d3786b0680 Gen 2: Remove duplicate HP IVs
The gen 2 mod doesn’t need HP IVs due to 0883c65. Updated the relevant
Hidden Power checks.
2015-12-29 20:24:39 +04:00
Ivo Julca
88c9902ebe Remove unused variables in old-gen random set builders
- Gen 2: `isSetup` is not even assigned a value.
- Gen 5: unmaintained.
2015-12-03 19:55:19 -05:00
Marty-D
a0876824c1 Gen II: Fix Flail and Reversal
They can't crit and don't perform damage variance.
2015-11-23 18:42:13 -05:00
Marty-D
c5b5885709 Gen II: Implement screens properly
Watch out for rollovers!
2015-11-14 11:42:58 -05:00
Marty-D
ebf197734b Gen II: Fix stat calculation
No longer shall paralyzed Pokemon have a Speed of 1.
2015-11-14 10:41:39 -05:00
Marty-D
7bfee1b079 Gen II: Add weather modifiers to the damage formula
And put SolarBeam's rain check where it belongs.
2015-11-09 12:24:53 -05:00
Guangcong Luo
ded9f1cd5d Fix duplicate cases in random set generators 2015-11-07 23:12:19 -06:00
Ivo Julca
90973d5c0c Style fixes
- Cut down excessive spacing
- Add braces to missing conditionals
2015-11-07 17:08:09 -05:00
Ivo Julca
2c2a3bdf58 Fix misplaced cases in random sets generators 2015-11-07 16:50:51 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Ivo Julca
15b925f7e4 RBY-GSC Randbats: Fix high incidence of later gen Pokémon 2015-07-16 13:33:42 -05:00
Ivo Julca
baadd0a92f Overhaul old-gen random team builders
Mainly follow-up for 1deedc595, but also fixes a few bugs.
- BW/GSC/RBY - randomSet: fixed and renamed slot argument.
- BW - randomTeam: crashlogger relative path was set incorrectly.
- BW - randomTeam: PotD Magikarp and Delibird used outdated randomBattleMoves data format.
- RBY - randomTeam: builder was too reject-happy regarding weaknesses (counters prematurely updated).

An improvement of 130% more op/s is observed for RBY randomCCTeam,
with no significative performance regression for randomTeam in any gen.
2015-07-16 12:03:14 -05:00
Marty-D
29e56b1043 Fix confusion timing after rampage moves
- Gen 1, 2, 5, and 6 cause confusion immediately after the move on the
last turn
- Gen 3 and 4 cause confusion at the end of the turn on the last turn
2015-06-04 09:55:30 -04:00
Marty-D
099824a3fb Gen II: Fix base power modifiers 2015-05-28 19:01:15 -04:00
Marty-D
1e5b241c0d Gen I, II: Fix rampage moves
- The lock starts even if the move is blocked by Protect, misses, or the
target is immune
- The lock ends without causing confusion whenever the move cannot be
executed
- When the lock ends normally, confusion begins even if the user is
already confused, and there is no indication that confusion has started
- In Gen 1 the duration is 3-4 turns
2015-05-22 14:30:44 -04:00
Marty-D
0e2606b9b9 Fix failure message showing for self effects 2015-05-20 10:45:17 -04:00
Marty-D
c1a1ce85df Fix failure message showing for secondary effects 2015-05-19 15:49:45 -04:00
Juanma Serrano
4f246f7032 Gen 2: Remove unused code
All this code was done before the main battle-engine was reworked to have exceptions for past gens.
Furthermore, due to how inheritance works, it was messing up team preview in Stadium formats.
All what was dealt with this code is now dealt with in battle-engine.js and all future gen 2 exceptions should be there.
2015-05-12 09:50:56 +02:00
Marty-D
c53d022e4b Fix OHKO moves
- Fix Gen 1/Stadium's accuracy and immunity order
- Fix OHKO moves ignoring Phantom Force
- Add OHKO messages
2015-04-30 13:06:45 -04:00
Kevin Lau
b6808d4476 Fix ignoreImmunity crashes in earlier gens
Unlike battle-engine.js, old gens did not check if move.ignoreImmunity was
undefined/false in their getDamage functions, causing crashes when numbers
were passed in to the function.
2015-04-14 15:22:06 -07:00
Guangcong Luo
54947b665f Merge pull request #1728 from ascriptmaster/move-fixes
Move refactor: moves/items that ignore immunity/effectiveness
2015-04-14 17:05:22 +00:00
Kevin Lau
b894bbfec9 Gen 2 Random Battle: Fix Move Rejection Phase
hasMove was not tracking moves properly, instead only tracking new moves
added in the object instead of its entire moveset. Also, there was a
line of code that caused all moves to be flagged as rejected.
2015-04-12 13:59:21 -07:00
Juanma Serrano
7181ded437 Gen 2 RandBat: Update set maker slightly 2015-04-10 13:21:41 +02:00
Juanma Serrano
08aefc3535 Gen 2 RandBat: Fix issue with HP and 3-move movesets 2015-04-10 13:16:10 +02:00
Kevin Lau
2e56120ad9 Move refactor: affectedByImmunities -> ignoreImmunity
While move.affectedByImmunities was always a Boolean value to denote if
the move was affected by immunities, move.ignoreImmunity can be a Boolean
value if it ignores or is affected by all type immunities, but also can
act as an object such that !!move.ignoreImmunity[type] means it ignores
immunities of that type.
2015-04-08 00:17:12 -07:00
Juanma Serrano
b718c8605d Update Gen 2 RandBat generator
Make several changes to team and set maker.
Fix bad choice of moves.
2015-03-31 17:49:21 +02:00
Juanma Serrano
1dd546b078 Gen 2 RandBats: Fix typos 2015-03-31 16:28:42 +02:00