Commit Graph

615 Commits

Author SHA1 Message Date
asgdf
6e7cec1c83 Send enditem message on Pickpocket steal (#4752) 2018-07-13 18:28:30 +09:00
urkerab
89e33bc649 Fix Bestow, Covet, Symbiosis and Thief with a required item (#4715) 2018-07-02 17:36:37 -04:00
Marty-D
9109f110bc Fix Sheer Force interaction with Clangorous Soulblaze 2018-06-24 09:38:56 -04:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
Marty-D
8ae3399f00
Improve Persistent descriptions 2018-05-23 01:16:14 +00:00
MacChaeger
a4a3d31b7c Properly support Pokemon with no ability (#4678) 2018-05-20 22:13:24 -05:00
Marty-D
17f6292b61
Improve Truant check 2018-05-18 03:39:31 +00:00
Marty-D
2ab375f3cc Implement Truant correctly 2018-05-17 20:31:19 -04:00
The Immortal
016a908358 Random Battle updates 2018-05-16 04:03:14 +08:00
SkyPhoenix (FlareonBlitz)
14d19eb991 Update Mummy description (#4626) 2018-04-26 16:31:11 -04:00
Marty-D
7ea4f499b9
Fix Neuroforce 2018-04-22 16:23:44 +00:00
Marty-D
ce38fe5c03 Fix Auras boosting only one hit of a spread move 2018-04-05 10:12:32 -04:00
MacChaeger
054c545c05 Fix Prankster interaction with bounced/encored moves (#4533) 2018-04-01 22:23:43 -04:00
asgdf
913d126e17 Fix Rock Head throwing errors in valid situations 2018-03-29 02:24:51 -05: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
asgdf
e01d849440 Set source of ability change on Mummy activation (#4447) 2018-03-02 09:26:50 -05:00
Marty-D
eea3d29161 Fix Weak Armor interaction with Mist effects 2018-02-20 09:39:29 -05:00
Marty-D
d582cf2aad Make sure moves change category before Hustle 2018-02-16 22:06:25 -05:00
Marty-D
f553290890
Shared Power: Fix Sheer Force and Stench interaction 2018-02-08 14:52:37 +00:00
KrisXV
554213bddb Fix Battle Bond + Skill Link in Shared Power (#4407) 2018-02-06 22:13:56 -05:00
urkerab
2e05c876c8 Other Metagames of the Month February 2018 (#4395) 2018-02-01 22:08:53 -05:00
urkerab
cdb12bd696 Fix last item handling (#4383) 2018-01-28 20:05:44 -06:00
urkerab
f0c93655c4 Fix Protective Pads mechanics (#4362) 2018-01-23 11:19:07 -05:00
urkerab
fba65229cf Add Mind Blown to Damp's description (#4305) 2018-01-02 16:22:08 -06:00
urkerab
25fe89f45a Make Contrary Competitive/Defiant self-inflicted (#4276) 2017-12-24 23:29:59 -06:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
Guangcong Luo
6d3c78fca6 Fix typoes 2017-12-06 14:57:22 -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
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
dc7c46b427 Update Ability-changing effects
Fixes #3230, closes #3245
2017-12-02 11:37:36 -05:00
Guangcong Luo
1ac2745c3e Refactor Pursuit hack
Pursuit no longer uses `moveThisTurn`, but rather `willMove`, which
involves significantly fewer Pursuit hacks.
2017-12-01 15:59:13 -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
Guangcong Luo
9bdf674d5f Refactor more tables to arrays
See #4079

Now we're just missing oldgens.
2017-11-30 19:40:16 -06:00
Marty-D
4c6b71f656 Gen III-IV: Fix Overgrow and friends 2017-11-24 12:40:26 -05:00
Kris Johnson
3a01ece652 Add Totem Pokemon (#4165) 2017-11-24 01:09:22 -06:00
The Immortal
40c49cc5c5 Random Battle updates 2017-11-20 19:18:13 +08:00
Marty-D
ebb274ed86 Update descriptions 2017-11-17 21:09:37 -05:00
Kris Johnson
f2caefba9b Ultra Sun and Ultra Moon update (#4151) 2017-11-16 20:34:43 -06:00
urkerab
e9303b1d1a Use this when it's a Dex (#4152) 2017-11-16 16:57:08 -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
The Immortal
792f7e0162 Random Battle updates 2017-10-20 13:29:40 +04:00
QuiteQuiet
6651c5dadb Fix confusion interaction with HP-checking items (#4045) 2017-10-17 09:26:27 -04:00
Kris Johnson
5d13b92bc8 Fix -ate Abilities' interaction with type-changing moves (#4023) 2017-09-27 22:01:37 -04:00
Marty-D
9a35ee28e5 Clarify Stakeout description 2017-09-27 13:50:17 -04:00
Marty-D
c33dff68a0 Fix new Ability modifiers 2017-09-27 10:24:27 -04:00
MacChaeger
05cdd33542 Fix Dancer activation order (#4009) 2017-09-23 20:17:00 -04:00