pokemon-showdown/test/simulator
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
..
abilities Tests: Refactor more tests to use makeChoices() (#4325) 2018-01-24 14:56:58 -06:00
items Extend Protective Pads unit tests (#4467) 2018-03-08 04:11:37 +09:00
misc Refactor random indexes into sample function 2018-03-12 05:53:33 +09:00
moves Tests: Refactor more tests to use makeChoices() (#4325) 2018-01-24 14:56:58 -06:00