mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-27 03:06:54 -05:00
Fix other crash from #8195
This commit is contained in:
parent
f6ed9e9ca5
commit
9985da5501
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type {Learnset} from "../../../sim/dex-species";
|
||||||
|
|
||||||
export const Rulesets: {[k: string]: ModdedFormatData} = {
|
export const Rulesets: {[k: string]: ModdedFormatData} = {
|
||||||
obtainablemoves: {
|
obtainablemoves: {
|
||||||
inherit: true,
|
inherit: true,
|
||||||
|
|
@ -74,34 +76,31 @@ export const Rulesets: {[k: string]: ModdedFormatData} = {
|
||||||
magneton: {triattack: 'L'},
|
magneton: {triattack: 'L'},
|
||||||
cloyster: {spikes: 'L'},
|
cloyster: {spikes: 'L'},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const moveSources: NonNullable<Learnset['learnset']> = Object.fromEntries(
|
||||||
|
set.moves.map(move => [this.toID(move), []])
|
||||||
|
);
|
||||||
|
|
||||||
|
const species = this.dex.species.get(set.species);
|
||||||
|
for (const {learnset} of this.dex.species.getFullLearnset(species.id)) {
|
||||||
|
for (const moveid in moveSources) {
|
||||||
|
moveSources[moveid].push(...(learnset[moveid] || []));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const notUsableAsTM = ['icebeam', 'flamethrower', 'thunderbolt'];
|
const notUsableAsTM = ['icebeam', 'flamethrower', 'thunderbolt'];
|
||||||
const species = this.dex.species.get(set.species || set.name);
|
|
||||||
const learnsetData = {...(this.dex.data.Learnsets[species.id]?.learnset || {})};
|
|
||||||
const legalityList = illegalCombos[species.id];
|
const legalityList = illegalCombos[species.id];
|
||||||
const problems = [];
|
const problems = [];
|
||||||
let prevo = species.prevo;
|
|
||||||
while (prevo) {
|
|
||||||
const prevoSpecies = this.dex.species.get(prevo);
|
|
||||||
const prevoLsetData = this.dex.data.Learnsets[prevoSpecies.id]?.learnset || {};
|
|
||||||
for (const moveid in prevoLsetData) {
|
|
||||||
if (!(moveid in learnsetData)) {
|
|
||||||
learnsetData[moveid] = prevoLsetData[moveid];
|
|
||||||
} else {
|
|
||||||
learnsetData[moveid].push(...prevoLsetData[moveid]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prevo = prevoSpecies.prevo;
|
|
||||||
}
|
|
||||||
for (const moveid of set.moves.map(this.toID)) {
|
for (const moveid of set.moves.map(this.toID)) {
|
||||||
// Diglett Magnemite Shellder
|
// Diglett Magnemite Shellder
|
||||||
if (!learnsetData[moveid]) continue;
|
if (!moveSources[moveid]) continue;
|
||||||
if (legalityList) {
|
if (legalityList) {
|
||||||
const list = learnsetData[moveid].filter(x => !x.includes(legalityList[moveid]));
|
const list = moveSources[moveid].filter(x => !x.includes(legalityList[moveid]));
|
||||||
if (!list.length) {
|
if (!list.length) {
|
||||||
switch (legalityList[moveid]) {
|
switch (legalityList[moveid]) {
|
||||||
case 'L':
|
case 'L':
|
||||||
// Converted to a set to remove duplicate entries
|
// Converted to a set to remove duplicate entries
|
||||||
const levels = new Set(learnsetData[moveid].filter(x => x.includes(legalityList[moveid])).map(x => x.slice(2)));
|
const levels = new Set(moveSources[moveid].filter(x => x.includes(legalityList[moveid])).map(x => x.slice(2)));
|
||||||
problems.push(
|
problems.push(
|
||||||
`${species.name} can't learn ${this.dex.moves.get(moveid).name}.`,
|
`${species.name} can't learn ${this.dex.moves.get(moveid).name}.`,
|
||||||
`(It learns ${this.dex.moves.get(moveid).name} in Pok\u00e9mon Crystal at the following levels: ${[...levels].join(', ')})`
|
`(It learns ${this.dex.moves.get(moveid).name} in Pok\u00e9mon Crystal at the following levels: ${[...levels].join(', ')})`
|
||||||
|
|
@ -123,7 +122,7 @@ export const Rulesets: {[k: string]: ModdedFormatData} = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const id of notUsableAsTM) {
|
for (const id of notUsableAsTM) {
|
||||||
if (moveid === id && learnsetData[id] && !learnsetData[id].filter(x => !x.includes('2T')).length) {
|
if (moveid === id && moveSources[id] && !moveSources[id].filter(x => !x.includes('2T')).length) {
|
||||||
problems.push(`${species.name} can't learn ${this.dex.moves.get(id).name}.`);
|
problems.push(`${species.name} can't learn ${this.dex.moves.get(id).name}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user