Earlier today, I tried to remove the hardcode for Smeargle without
realizing what it was for (Smeargle gets Spore as an event move, which
shouldn't override its ability to Sketch Spore).
It turns out, 7 years ago when I added the Smeargle hardcode, I wrote
a TODO to fix it which I never got around to:
2e1ab04eb6
Anyway, this commit fixes it properly.
`checkLearnset` has been renamed `checkCanLearn`.
`reconcileLearnset` has been replaced with `validateMoves`, which
bundles the actual `checkCanLearn` calls with the old
`reconcileLearnset`, making for a better name.
It turns out `sentLogPos` isn't incremented in unit tests (no actual
use-case was affected). This is the simplest fix, although at some point
we should revisit how battles send and receive data.
* Split up dex-data over individual files
This commit introduces:
- `dex-abilities.ts`
- `dex-conditions.ts`
- `dex-formats.ts`
- `dex-items.ts`
- `dex-moves.ts`
- `dex-species.ts`
These files centralize definitions from `dex-data` and `global-types`.
* Inherit ItemData from Item etc
Previously, Condition inherited from ConditionData. Now, ConditionData
inherits from Condition. The advantage of the new approach is that now,
Condition and DataCondition no longer need to be separate types, and
there should be much less duplication of type definitions in general.
This has also been done for
- ItemData/Item/DataItem
- AbilityData/Ability/DataAbility
- FormatData/Format/DataFormat
Species and DataSpecies was already merged, but this also reverses
their inheritance (saving a lot of duplicated definitions in the
process!)
The only one left is MoveData, which is just super complicated and
will need its own commit.
It turns out 001f98b4f2 was wrong.
When urkerab asked why it `peek` wasn't awaited:
e91c4c5260 (commitcomment-41364837)
The answer was because clearing the buffer after peeking needed to
happen synchronous: if the buffer is written to after peeking but
before the buffer is cleared, that write is lost forever.
This just goes to show, if you do something subtle enough to require
type assertions, you should probably add a comment about what's going
on.
Fixes#7605
This also removes `BattleStream#start()` which is completely useless
API complication. A better implementation would properly forward
crashes between streams (maybe `pipeTo` should do this) but as it
stands, it's not doing anything.