Commit Graph

354 Commits

Author SHA1 Message Date
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
Russell Jones
e4923a08d5 Use more accurate multiplier for Big Root (#5120) 2019-01-25 10:39:58 -05:00
Marty-D
5d06968819 Release Custap, Enigma, Jaboca, Micle, and Rowap Berries 2019-01-08 08:25:57 -05:00
Alexander B
eecde00ed3 Fix Leppa Berry (#5025) 2018-12-14 01:12:41 -06:00
Guangcong Luo
877c9feeeb Fix onEffectiveness event signature
I fixed `onAfterSubDamage` in the previous commit, but this one I left
for later.
2018-12-08 22:52:59 -06:00
Guangcong Luo
c752b327ca Fix no-target charge moves 2018-11-27 23:25:29 -06:00
Guangcong Luo
37a5cf25cc Fix Power Herb animation 2018-11-19 17:20:55 -06:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -05:00
Guangcong Luo
2c15a1663a
BrightPowder -> Bright Powder
Fixes https://github.com/Zarel/Pokemon-Showdown-Client/issues/1142
2018-09-01 04:09:35 -05:00
Marty-D
21cf8fbab0 Descriptions: Change "Ability [name]" to "[name] Ability" 2018-08-25 12:56:23 -04:00
Marty-D
ac71237de1 Gen II-III: Fix Berry usage timing 2018-08-21 16:36:23 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
Marty-D
8a6ef0d792 Implement Metronome item slightly less incorrectly
This is still wrong because spamming a Fire attack in Primordial Sea
should not boost damage, but then you run into the problem of boosting
multiple times against multiple targets.
TODO: fix this
2018-05-14 09:50:27 -04:00
Marty-D
d110807efd
Fix Mystery Berry message 2018-05-14 13:31:48 +00:00
Marty-D
f79a889e84
Fix crash in Mystery Berry 2018-05-14 13:24:57 +00:00
Marty-D
2d40904573 Fix some item sprites 2018-04-25 08:50:55 -04:00
Marty-D
e453a772fb Add some miscellaneous items 2018-04-23 21:13:15 -04:00
asgdf
b4a51985d9 Fix Protective Pads throwing errors in valid situations (#4527) 2018-03-29 15:06:21 -04:00
Quinton Lee
c799393710 Typescript data/ and config/formats (#4513)
Also removes Battle Factory methods accidentally re-added in d0a4a689a7
2018-03-26 09:50:51 -05:00
KrisXV
d0a4a689a7 Refactor data/ and mafia.js to for...of (#4490) 2018-03-23 18:51:52 -07:00
Matthew Glazar
6c2350f5b6 Refactor random indexes into sample function
Often, you just need a random item in an array. Throughout Pokemon
Showdown's code, there are many instances of the following pattern:

    let randomThing = things[this.random(things.length)];

Make this code easier to read by factoring the indexing into the
PRNG#sample function:

    let randomThing = this.sample(things);

Run the following sed script to refactor lots of code to use sample:

    s/\([a-zA-Z0-9.]\{1,\}\)\[this\.random(\1\.length)\]/this.sample(\1)/

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-12 05:53:33 +09:00
Matthew Glazar
45a876917d Refactor random booleans into randomChance function
Often, you just need a random boolean. Throughout Pokemon Showdown's
code, there are many creative ways of requesting random booleans. For
example:

    if (this.random(10) < 3) {
    if (this.isWeather(['sunnyday', 'desolateland']) || this.random(2) === 0) {
    let shiny = !this.random(1024);
    if (uberCount > 1 && this.random(5) >= 1) continue;
    if (!this.random(3)) ability = ability1.name;
    } else if ((ability === 'Iron Barbs' || ability === 'Rough Skin') && this.random(2)) {
    if (typeof secondary.chance === 'undefined' || this.random(256) <= effectChance) {
    if (accuracy !== true && this.random(256) > accuracy) {

Enable these methods to converge by introducing the PRNG#randomChance
function. It accepts a probability and returns true with that
probability.

Run the following sed script to refactor many common patterns to use
randomChance:

    s/this\.random(\([0-9]\{1,\}\)) >= \([0-9]\{1,\}\)/!this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) < \([0-9]\{1,\}\)/this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) === 0/this.randomChance(1, \1)/g
    s/!this\.random(\([0-9]\{1,\}\))/this.randomChance(1, \1)/g

The sed script takes advantage of the following properties:

    random(x) < y     is equivalent to   randomChance(y, x)
    random(x) >= y    is equivalent to   !(random(x) < y), i.e. !randomChance(y, 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)

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
42b3846c6c
Fix Jaboca/Rowap Berry activation 2018-03-08 01:45:47 +00:00
Marty-D
ad27420a1e Update Life Orb's interaction with OHKO moves 2018-01-29 19:46:11 -05:00
urkerab
f0c93655c4 Fix Protective Pads mechanics (#4362) 2018-01-23 11:19:07 -05:00
urkerab
99d682ca26 Change lastMove from a string to a Move (#4298) 2018-01-03 11:54:35 -06:00
urkerab
94efee424d Indicate when an item activates after it is consumed (#3979) 2018-01-01 14:15:32 -06:00
urkerab
2873bd8366 Remove an unused parameter from eatItem and useItem (#4210) 2017-12-23 21:36:51 -06:00
Marty-D
63bec7bf32 Fix source of status for Flame/Toxic Orb
Relevant for Corrosion
2017-12-19 09:53:53 -05:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
urkerab
2336bd7573 Make Leftovers/Black Sludge recovery happen during Grassy Terrain recovery (#3970) 2017-12-09 23:27:35 -06:00
Guangcong Luo
c0da44c482 Refactor moveset -> moveSlots
pokemon.moveset is now pokemon.moveSlots, which is at least slightly
clearer about what it's doing (tracking move state, mainly PP).

Mostly, this gives a consistent naming scheme for `move` (a Move
object) vs `moveSlot` (a MoveSlot object).

This also refactors a lot of existing `moveSlot` accesses to be modern,
including using `for...of`.
2017-12-05 11:12:44 -06:00
Guangcong Luo
f4e535bbd6 Enforce consistent key spacing
This was previously not enforced because we used `:1` in too many
places, but those places seem to all be refactored out at this point.
2017-12-01 08:16:23 -06:00
Kris Johnson
3a01ece652 Add Totem Pokemon (#4165) 2017-11-24 01:09:22 -06:00
Marty-D
ebb274ed86 Update descriptions 2017-11-17 21:09:37 -05:00
Marty-D
7dfca478fe
Fix Kommonium Z sprite 2017-11-17 17:35:53 -05:00
Marty-D
620cf04f27 Update Partner Cap Pikachu 2017-11-17 13:12:10 -05:00
Kris Johnson
f2caefba9b Ultra Sun and Ultra Moon update (#4151) 2017-11-16 20:34:43 -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
312f93c47c Revert "Fix confusion interaction with HP-checking items (#4045)"
This reverts commit
6651c5dadb.
2017-10-20 21:05:49 -04:00
QuiteQuiet
6651c5dadb Fix confusion interaction with HP-checking items (#4045) 2017-10-17 09:26:27 -04:00
Marty-D
1f83604882 Update item descriptions
And remove redundant inheritance
2017-08-24 18:11:12 -04:00
Archit Date
f6a3b41084 Release Diancite (#3874) 2017-08-10 15:32:45 +04:00
Marty-D
03eef2604b Release Altarianite, Ampharosite, Latiasite, and Latiosite 2017-08-07 22:44:32 -04:00
urkerab
1f6e1e8d45 Weakness Policy should activate before Thief or Magician (#3867) 2017-08-07 20:40:57 -05:00
urkerab
ce58237a15 Fix Unburden/Symbiosis interaction with Air Balloon behind Substitute (#3854) 2017-08-04 23:54:41 -05:00
Marty-D
1f983407e4 Release Aggronite 2017-07-21 08:29:53 -04:00
Marty-D
db88d65b2a Revert "Revert "Release Galladite, Gardevoirite, and Lopunnite (#3697)""
This reverts commit ff60a973e8.
2017-07-04 08:01:35 -04:00
Marty-D
b51e138768 Add event Marshadow
Closes #3718
2017-07-03 09:33:48 -04:00