mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-19 05:31:16 -05:00
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.
|
||
|---|---|---|
| .. | ||
| application | ||
| chat-plugins | ||
| simulator | ||
| .eslintrc | ||
| assert.js | ||
| common.js | ||
| main.js | ||
| mocha.opts | ||