Commit Graph

111 Commits

Author SHA1 Message Date
MacChaeger
8eb5caa103 Gens 1 & 2: Support Inverse mod (#4617) 2018-04-22 14:00:41 -05:00
MacChaeger
711a0d4ce4 Check semi-invulnerability before immunities (#4574) 2018-04-14 10:27:45 -04:00
Quinton Lee
acd812c71e Typescript gens 1-4 (#4556) 2018-04-11 22:11:25 -05:00
Marty-D
45e4f198da Gen II: Fix Destiny Bond 2018-04-02 12:45:36 -04:00
Matthew Glazar
81208685d1 Refactor some code to use sample
Mechanically refactor code which uses PRNG#random to calculate a random
array index to use PRNG#sample instead.
2018-03-12 05:53:33 +09:00
Matthew Glazar
df5988bacf Refactor some code to use randomChance
Mechanically refactor code which uses PRNG#random for booleans to use
PRNG#randomChance instead.

Take advantage of the following properties:

    random(x) < y        is equivalent to   randomChance(y, x)
    random(x) <= y       is equivalent to   random(x) < (y + 1), i.e. randomChance(y + 1, x)
    random(x) >= y       is equivalent to   !(random(x) < y), i.e. !randomChance(y, x)
    random(x) > y        is equivalent to   random(x) >= (y + 1), i.e. !randomChance(y + 1, x)
    random(x) === 0      is equivalent to   random(x) < 1, i.e. randomChance(1, x)
    !random(x)           is equivalent to   random(x) === 0, i.e. randomChance(1, x)
    Boolean(random(x))   is equivalent to   random(x) > 0, i.e. !randomChance(1, x)

This commit should not change behaviour. In particular, PRNG#next is
called the same number of times with the same number of parameter as
before this commit, and PRNG#next's results are interpreted in the same
way as before this commit.
2018-03-08 20:11:33 +09:00
Marty-D
8c13f7e872 Gen II: Fix Thief and secondary chances 2018-02-13 10:19:52 -05:00
Kris Johnson
238ac1fdd7 Refactor old gens to for...of (#4274) 2017-12-23 21:46:04 -06:00
Marty-D
5916bcb865 Gen II: Fix Destiny Bond 2017-12-05 17:34:21 -05:00
Marty-D
85d62abfdc
Gen II: Fix Baton Passing volatiles 2017-12-05 09:31:53 -05:00
Guangcong Luo
f3dbfbe685 Refactor Decision -> Action
"Decision" and "Choice" were always kind of unclear, so Decision is now
Action. It should now be a lot clearer.

Actions are also now strongly typed.
2017-12-02 11:34:55 -06:00
Marty-D
da3c9fef0d
Gen II: Fix Protect and Future Sight 2017-12-01 08:53:18 -05:00
Guangcong Luo
a26edc29c0 Fix crash in tryMoveHit 2017-12-01 07:50:31 -06:00
XnadrojX
024c2ce7ac Gen I-II: Fix accuracy calculations and BrightPowder (#3926) 2017-11-30 21:12:59 -05:00
Guangcong Luo
9b04903ec4
Fix Gen 2 Present 2017-11-29 09:06:52 -06:00
Enigami
993e036d14 Fix Gen 2 Present (#4192) 2017-11-29 08:05:40 -06:00
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