The regressions affected information handling
- Seeds used for random teams were no longer being logged.
- The seed used for generating p2's team was also used for the battle itself.
Dancer Petal Dance shouldn't lock. This is a horrible hack but it fixes
the problem. A real fix would involve refactoring basically all locking
moves. Which I guess I should do one day...
Fixes#2974
This doesn't fix the biggest issue with Dancer (Petal Dance locking),
but it does fix every other Dancer issue, by moving it from useMove
to runMove.
This also adds improved comments on runMove and useMove.
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.
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');
}
})
})
```
This removes the 'deterministic test' tools by preventing action at a
distance (namely, preventing the modification of the `init` method in
`Battle` during tests). This action at a distance is incredibly
confusing.
All this action at a distance did was discard any parameters that were
passed to `Battle` that weren't the first three (which was probably a
mistake by the original author) and also hard code `this.seed` and
`this.startingSeed` in `Battle`.
This functionality has now been moved to the `PRNG` class, so instead
users should pass a `PRNG` to `Battle` as the 5th constructor argument.
Users can also pass one as the third argument to `common.createBattle`
or use `common.createBattleWithPRNG` with the PRNG as the first
argument.
The PRNG is just an encapsulation of the pseudo-random algorithm in a
class. It is stateful, so make sure to take a `clone()` of the PRNG if
you want to re-use it.