mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-17 18:51:43 -05:00
Mechanically refactor code which uses PRNG#random for booleans to use
PRNG#randomChance instead.
Take advantage of the following properties:
random(x) < y is equivalent to randomChance(y, x)
random(x) <= y is equivalent to random(x) < (y + 1), i.e. randomChance(y + 1, x)
random(x) >= y is equivalent to !(random(x) < y), i.e. !randomChance(y, x)
random(x) > y is equivalent to random(x) >= (y + 1), i.e. !randomChance(y + 1, 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)
Boolean(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.
|
||
|---|---|---|
| .. | ||
| abilities.js | ||
| aliases.js | ||
| bss-factory-sets.json | ||
| factory-sets.json | ||
| formats-data.js | ||
| gen-6-factory-sets.json | ||
| items.js | ||
| learnsets.js | ||
| moves.js | ||
| pokedex.js | ||
| random-teams.js | ||
| rulesets.js | ||
| scripts.js | ||
| statuses.js | ||
| typechart.js | ||