PS's rule table has been renamed from banlistTable, and works a bit
differently now. It's a Map instead of an object now, and the keys
work a bit differently.
The original banlistTable was designed to store bans, and later
additions shoved rules and then unbans in there. The new table is
designed to support all of these.
- spawning and setting up child processes is now handled by
ProcessManager#constructor rather than needing to be done manually for
each module that uses ProcessManager
- direct references to ProcessManager in ProcessWrapper were removed to
prevent dead ProcessWrapper instances from being leaked when hotpatching
- process-manager.js and verifier.js now use Typescript
Bringing no item caused the validator to break (which, of course,
made it nearly impossible to play gen 1).
I really wish full TypeScript coverage could come ASAP, so these
sorts of bugs would come less often.
- `Config.repl` enables/disables using REPL sockets since it doesn't
make as much sense to configure whether or not it's enabled with the
REPL_ENABLED const
- exports.start takes a filename parametre rather than a prefix and a
suffix one to avoid having to mutate parametres
- dead REPL sockets are removed from the sockets list when the server
emits an error, and the server closes on error now before respawning
the server
- made the file ready for Typescript
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.
In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`
In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
In VGC and Battle Spot, the validator wouldn't do any validation at all
if you didn't bring the minimum number of Pokemon. Now, it still gives
other error messages in addition to "You need at least X Pokemon".
This is mostly nice for validating a single Pokemon for VGC etc without
needing to fill the rest of the team with junk.
The old code tried to validate by changing incorrect values to correct
values, but had lots of bugs. Even if it didn't have bugs, it would have
various flaws like stats being different from what you would expect from
the teambuilder, so the new code just tells you when your HP DV,
shininess, gender, and Hidden Power type are inconsistent with your
other DVs.
(The one exception is SD Thick Club Marowak, which still automatically
fixes its Atk IV, since we still don't have teambuilder UI for that.)
Because of the way fastUnpackTeam works, it's currently a reasonable
assumption that all the values in a `set` are IDs, and various parts
of the code have started to rely on that assumption.
Removing some old code to try to guarantee that the values in a `set`
are names allow us to work towards a new guarantee that `set` values
are IDs.
Closes#2553
This is a huge refactor that consolidates many different places event,
DW, and VC moves are validated, so that they're now validated in the
single place Validator#validateEvent. DW and VC moves are now treated
as special cases of events.
Validator#checkLearnset now does zero validation of event, DW, and VC
moves; it now simply passes the list of possible sources back to
Validator#validateSet, and it's validateSet's job to determine if the
Pokemon meets the requirements for any of those sources.
(In addition to simplifying checkLearnset, this also means more
useful error messages if you fail to meet the requirements for an
event move or DW move.)
validateSet should also be a decent margin simpler, due to a lot of
its code being folded into validateEvent.
Virtual Console validation wasn't happening for Pokemon who learn a
move from Virtual Console from multiple Pokemon in its evo family.
This is most relevant for No Guard Fissure Machamp, which shouldn't
be legal.
This adds validator support for Gen 1 Virtual Console moves.
Fixes#3208
If anyone wants the quick-and-dirty eval script I used to update
Learnsets:
```
Object.entries(Tools.mod('gen1').data.Learnsets).forEach(([speciesid, lset]) => {
Object.entries(lset.learnset).forEach(([moveid, sources]) => {
if (sources.some(s => s.startsWith('1L') || s.startsWith('1M'))) {
let newLset = Tools.data.Learnsets[speciesid].learnset;
if (!newLset[moveid]) newLset[moveid] = [];
let i = 0;
while (i < newLset[moveid].length && newLset[moveid][i].startsWith('7')) i++;
newLset[moveid].splice(i, 0, '7V');
}
})
})
```
Now that we now store Hidden Power type separately from IVs, we can
make some major changes to how Hidden Power is validated.
Instead of Hidden Power type being calculated from the IVs, it's now
sent separately as part of the set. This allows us to warn in the
validator if the Hidden Power type specified by the moveset is
different from the one calculated from the IVs, and give a validation
error if so.
This also allows us to validate the Hidden Power type (pre-bottle-cap
IVs) separately from the set IVs (post-bottle-cap IVs) when doing
event validation, which fixes some validation issues relating to
Hidden Power.
Previously, "requirePentagon" meant "only allow current-gen Pokemon".
Now, "requirePentagon" means "allow Gen 6 Pokemon and later", and
"requirePlus" means "allow Gen 7 Pokemon and later".
The last 7 commits to team-validator take the code in the wrong
direction. While it's possible that the latest one fixes the validation
issues for VGC, they misuse variable names and in general need to be
redone from scratch.