Commit Graph

643 Commits

Author SHA1 Message Date
Ivo Julca
ac4b94876b Sim: Refactor to use Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
Kirk Scheibelhut
03b2c92cb1 Make isNonstandard specify reason for non-standardness (#5330) 2019-03-22 01:49:22 +09:00
Kirk Scheibelhut
a8903d2563 Cleanup stat naming and types (storedStats, StatNameExceptHP) (#5274) 2019-03-09 09:53:11 -06:00
The Immortal
7653384d20 Random Battle updates
- Only give Porygon-Z Z-Conversion under the right circumstances
- Slightly reduce the rating of Download so Porygon gets Adaptability a bit more
- Improve Haxorus' movepool
- Remove unviable Genesect sets
- Allow U-turn as the only STAB on Genesect
- Improve Magearna's movepool (+Fairium Z)
- Don't reject Flash Cannon with Special setup
- Give Fairies STAB when they need it
- Set Shift Gear as a Speed setup move
- Change the Life Orb bulk requirement to match Focus Sash
- Reject Trick with Speed setup
2019-03-08 17:27:44 +04:00
urkerab
9ebaa6877b Fix Protean and Color Change (#5233) 2019-03-03 04:40:35 -06:00
Kris Johnson
c2e21d6fea Fix crash in Anticipation (#5232)
A battle has crashed: TypeError: Cannot read property 'fainted' of null
at Battle.onStart (/home/ps/showdown/data/abilities.js:150:16)
2019-03-03 03:28:03 -06:00
The Immortal
59c4965dfa Random Battle improvements 2019-02-24 06:00:24 +04:00
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
Guangcong Luo
8d57bd1b8c Remove useless param from pokemon.transformInto
Introduced in 743c85127c
2019-02-01 15:10:46 -06:00
Marty-D
891f4d202a
Update Emergency Exit and Wimp out descriptions 2019-01-16 13:56:02 -05:00
Marty-D
a0a81519ca Update Zen Mode 2019-01-16 13:42:18 -05:00
Kevin Lau
c579e4ae85 Random Battle: Lower Keen Eye rating (#5098)
Fixes Drapion, who has 3 different moves with a rating of 1. Keen Eye is
less useful than Battle Armor or Sniper because of a lack of accuracy
reduction moves in random battle, so this ensures that it is not chosen.
2019-01-13 22:16:19 +04:00
Russell Jones
09118c0937 OHKO moves are really only 150 power to Forewarn (#5058)
Also the 1-power CFZs count as 80 to Forewarn, not that that's a particularly likely interaction to come up anywhere.
2019-01-02 01:35:14 -06:00
plumberjack
4e2e4263d9 Clarifiy Unnerve's description (#5028) 2018-12-15 10:38:12 -05: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
3a8add5c4b Remove [msg] parameter of -immune
(It's unnecessary, being the default message for it.)
2018-11-10 12:31:21 -06:00
Alvin Ho
9d676aae71 Fix Mummy and Parental Bond Interaction (#4890)
Problem: Parental Bond when changed to Mummy midstrike would cause the second move to miss the .25 base power modification
Added Parental Bond check in Mummy to maintain the power modification
2018-10-12 21:20:46 -05:00
Guangcong Luo
ecb27edb4d
Introduce ActiveMove; make some types read-only (#4902)
The types Template, Move, Ability, and Item are now read-only. This
should guard against accidental writing to types that shouldn't be
written to.

A new type, ActiveMove, has been introduced. Like it sounds, it's
used for moves that are currently actively being used. A lot of
attributes that are only relevant to active moves, such as
`hasBounced`, are now only available on ActiveMove, not on Move.
ActiveMoves are mutable, unlike Moves.

getMoveCopy has been renamed getActiveMove, to better reflect its
role. `isCopy` has been deprecated, and distinguishing Moves from
ActiveMoves is now done by `typeof move.hit === 'number'` where
necessary.

ActiveMoves now internally track which hit of a multihit move
they're on, in move.hit, so move.hit doesn't need to be manually
incremented by Triple Kick and Parental Bond anymore.

move.hasParentalBond has been replaced by a more generic
move.multihitType.
2018-10-10 16:04:35 -05:00
Alvin Ho
7d0275b453 Fix Flower Veil interaction with self-inflicted status and Yawn (#4889) 2018-10-07 21:48:30 -04:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -05:00
The Immortal
fe2097dd82 Reduce Emergency Exit's rating 2018-09-18 22:28:24 +04:00
Marty-D
952ccb2d80 Correct Soul-Heart activation order 2018-09-13 11:34:30 -04:00
Marty-D
21cf8fbab0 Descriptions: Change "Ability [name]" to "[name] Ability" 2018-08-25 12:56:23 -04:00
Guangcong Luo
7b42d55a97
Clarify Synchronize hack 2018-08-14 12:50:40 +09:00
urkerab
52a214e7b9 Synchronize should trigger activations of other Abilities again (#4808) 2018-08-12 21:15:26 -04:00
Marty-D
c944f01537 Fix Parental Bond 2018-08-07 17:06:27 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
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