Skip to content

Commit

Permalink
TrashChannel fixes for Update Dex API smogon#8181
Browse files Browse the repository at this point in the history
  • Loading branch information
WeWuzNidokangz committed May 17, 2021
1 parent baee245 commit 6686ad9
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 178 deletions.
80 changes: 40 additions & 40 deletions config/custom-formats.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions data/mods/bitchandbeggar/scripts.ts
Expand Up @@ -13,7 +13,7 @@ export const Scripts: ModdedBattleScriptsData = {
canMegaEvo(pokemon) {
if (pokemon.species.isMega || pokemon.species.isPrimal) return null;

let bitchSpecies = this.dex.getSpecies(pokemon.item);
let bitchSpecies = this.Dex.species.get(pokemon.item);
if (bitchSpecies.exists) { // Bitch and beggar
return bitchSpecies.id;
}
Expand All @@ -34,7 +34,7 @@ export const Scripts: ModdedBattleScriptsData = {
}
}

// Take care of regular megaevo case first (this.dex.getSpecies(pokemon.canMegaEvo).exists is true on Mega Stones!)
// Take care of regular megaevo case first (this.Dex.species.get(pokemon.canMegaEvo).exists is true on Mega Stones!)
let item = pokemon.getItem();
let isBeggarEvo = !pokemon.getItem().exists;

Expand Down Expand Up @@ -74,7 +74,7 @@ export const Scripts: ModdedBattleScriptsData = {
const species = this.getMixedSpecies(pokemon.m.originalSpecies, bitchSpecies);

// Update ability for slot
let oSpecies = this.dex.getSpecies(pokemon.species);
let oSpecies = this.Dex.species.get(pokemon.species);
let oAbilitySlot = pokemon.calcActiveAbilitySlot();
// @ts-ignore
species.abilities = {'0': species.abilities[oAbilitySlot]};
Expand Down
8 changes: 4 additions & 4 deletions data/mods/gen7bitchandbeggar/scripts.js
Expand Up @@ -16,13 +16,13 @@ let Scripts = {
},
canMegaEvo(pokemon) {
if (pokemon.species.isMega || pokemon.species.isPrimal) return null;
let bitchSpecies = this.dex.getSpecies(pokemon.item);
let bitchSpecies = this.Dex.species.get(pokemon.item);
if (bitchSpecies.exists) { // Bitch and beggar
return bitchSpecies.id;
}

// Regular mega evo case: have to copy and paste code from data/scripts.js for now
let altForme = pokemon.baseSpecies.otherFormes && this.dex.getSpecies(pokemon.baseSpecies.otherFormes[0]);
let altForme = pokemon.baseSpecies.otherFormes && this.Dex.species.get(pokemon.baseSpecies.otherFormes[0]);
let item = pokemon.getItem();
if (altForme && altForme.isMega && altForme.requiredMove && pokemon.baseMoves.includes(toID(altForme.requiredMove)) && !item.zMove) return altForme.species;
if (item.megaEvolves !== pokemon.baseSpecies.baseSpecies || item.megaStone === pokemon.species) {
Expand All @@ -43,7 +43,7 @@ let Scripts = {
}
}

// Take care of regular megaevo case first (this.dex.getSpecies(pokemon.canMegaEvo).exists is true on Mega Stones!)
// Take care of regular megaevo case first (this.Dex.species.get(pokemon.canMegaEvo).exists is true on Mega Stones!)
let item = pokemon.getItem();
let isBeggarEvo = !pokemon.getItem().exists;

Expand Down Expand Up @@ -83,7 +83,7 @@ let Scripts = {
const species = this.getMixedSpecies(pokemon.m.originalSpecies, bitchSpecies);

// Update ability for slot
let oSpecies = this.dex.getSpecies(pokemon.species);
let oSpecies = this.Dex.species.get(pokemon.species);
let oAbilitySlot = pokemon.calcActiveAbilitySlot();
// @ts-ignore
species.abilities = {'0': species.abilities[oAbilitySlot]};
Expand Down
14 changes: 7 additions & 7 deletions data/mods/gen7megaandmega/scripts.js
Expand Up @@ -42,12 +42,12 @@ let Scripts = {

// Do we have a proper sprite for it?
// @ts-ignore assert non-null pokemon.canMegaEvo
if (isUltraBurst || this.dex.getSpecies(pokemon.canMegaEvo).baseSpecies === pokemon.m.originalSpecies) {
if (isUltraBurst || this.Dex.species.get(pokemon.canMegaEvo).baseSpecies === pokemon.m.originalSpecies) {
pokemon.formeChange(species, pokemon.getItem(), true);
} else {
let oSpecies = this.dex.getSpecies(pokemon.m.originalSpecies);
let oSpecies = this.Dex.species.get(pokemon.m.originalSpecies);
// @ts-ignore
let oMegaSpecies = this.dex.getSpecies(species.originalMega);
let oMegaSpecies = this.Dex.species.get(species.originalMega);
pokemon.formeChange(species, pokemon.getItem(), true);
this.add('-start', pokemon, oMegaSpecies.requiredItem || oMegaSpecies.requiredMove, '[silent]');
if (oSpecies.types.length !== pokemon.species.types.length || oSpecies.types[1] !== pokemon.species.types[1]) {
Expand All @@ -60,8 +60,8 @@ let Scripts = {
return true;
},
getMixedSpecies(originalSpecies, megaSpecies) {
let originalSpecies = this.dex.getSpecies(originalSpecies);
let megaSpecies = this.dex.getSpecies(megaSpecies);
let originalSpecies = this.Dex.species.get(originalSpecies);
let megaSpecies = this.Dex.species.get(megaSpecies);

// Mega and Mega: Ignore regular quick return for post-mega formes
// @ts-ignore
Expand All @@ -71,7 +71,7 @@ let Scripts = {
return species;
},
getMegaDeltas(megaSpecies) {
let baseSpecies = this.dex.getSpecies(megaSpecies.baseSpecies);
let baseSpecies = this.Dex.species.get(megaSpecies.baseSpecies);
/**@type {{ability: string, baseStats: {[k: string]: number}, weightkg: number, originalMega: string, requiredItem: string | undefined, type?: string, isMega?: boolean, isPrimal?: boolean}} */
let deltas = {
ability: megaSpecies.abilities['0'],
Expand All @@ -97,7 +97,7 @@ let Scripts = {
},
doGetMixedSpecies(speciesOrSpeciesName, deltas) {
if (!deltas) throw new TypeError("Must specify deltas!");
let species = this.dex.deepClone(this.dex.getSpecies(speciesOrSpeciesName));
let species = this.dex.deepClone(this.Dex.species.get(speciesOrSpeciesName));
species.abilities = {'0': deltas.ability};
if (species.types[0] === deltas.type) {
species.types = [deltas.type];
Expand Down
6 changes: 3 additions & 3 deletions data/mods/gen7mixandmeta/mixedmetacollection.js
Expand Up @@ -26,8 +26,8 @@ let MixedMetaCollection = {
}*/

// Check item-based mega evos
let species = global.Dex.getSpecies(set.species || set.name);
let item = global.Dex.getItem(set.item);
let species = global.Dex.species.get(set.species || set.name);
let item = global.Dex.items.get(set.item);
if (!item.megaEvolves && !['blueorb', 'redorb', 'ultranecroziumz'].includes(item.id)) return undefined; // Native mega-evos
if (species.baseSpecies === item.megaEvolves ||
(species.baseSpecies === 'Groudon' && item.id === 'redorb') ||
Expand All @@ -52,7 +52,7 @@ let MixedMetaCollection = {
let sCustomRulesString = '@@@' + customRules.join(',');
//console.log("sCustomRulesString: " + sCustomRulesString);

let metaFormat = global.Dex.getFormat('[Gen 7] OU' + sCustomRulesString, true);
let metaFormat = global.Dex.formats.get('[Gen 7] OU' + sCustomRulesString, true);
let metaRuleTable = global.Dex.getRuleTable(metaFormat);

let validatorProblems = validator.validateSetInternal(set, undefined, metaFormat, metaRuleTable, true) || [];
Expand Down
4 changes: 2 additions & 2 deletions data/mods/gen7pic/moves.js
Expand Up @@ -5,8 +5,8 @@ exports.Moves = {
"skillswap": {
inherit: true,
onHit(target, source, move) {
let targetAbility = this.dex.getAbility(target.ability);
let sourceAbility = this.dex.getAbility(source.ability);
let targetAbility = this.Dex.abilities.get(target.ability);
let sourceAbility = this.Dex.abilities.get(source.ability);
if (target.side === source.side) {
this.add('-activate', source, 'move: Skill Swap', '', '', '[of] ' + target);
} else {
Expand Down
4 changes: 2 additions & 2 deletions data/mods/gen7pic/scripts.js
Expand Up @@ -14,13 +14,13 @@ exports.Scripts = {
pokemon: {
setAbility(ability, source, isFromFormechange) {
if (!this.hp) return false;
ability = this.battle.dex.getAbility(ability);
ability = this.battle.Dex.abilities.get(ability);
let oldAbility = this.ability;
if (!isFromFormechange) {
if (['illusion', 'battlebond', 'comatose', 'disguise', 'multitype', 'powerconstruct', 'rkssystem', 'schooling', 'shieldsdown', 'stancechange'].includes(ability.id)) return false;
if (['battlebond', 'comatose', 'disguise', 'multitype', 'powerconstruct', 'rkssystem', 'schooling', 'shieldsdown', 'stancechange'].includes(oldAbility)) return false;
}
this.battle.singleEvent('End', this.battle.dex.getAbility(oldAbility), this.abilityData, this, source);
this.battle.singleEvent('End', this.battle.Dex.abilities.get(oldAbility), this.abilityData, this, source);
let ally = this.side.active.find(ally => ally && ally !== this && !ally.fainted);
if (ally && ally.m.innate) {
ally.removeVolatile(ally.m.innate);
Expand Down
6 changes: 3 additions & 3 deletions data/mods/gen7pokebilities/abilities.js
Expand Up @@ -17,7 +17,7 @@ exports.Abilities = {
if (pokemon.innates) bannedAbilities = bannedAbilities.concat(pokemon.innates);
possibleAbilities = possibleAbilities.filter(val => !bannedAbilities.includes(val));
if (!possibleAbilities.length) return;
let ability = this.dex.getAbility(possibleAbilities[this.random(possibleAbilities.length)]);
let ability = this.Dex.abilities.get(possibleAbilities[this.random(possibleAbilities.length)]);
this.add('-ability', pokemon, ability, '[from] ability: Power of Alchemy', '[of] ' + ally);
if (isAbility) {
pokemon.setAbility(ability);
Expand All @@ -42,7 +42,7 @@ exports.Abilities = {
if (pokemon.innates) bannedAbilities = bannedAbilities.concat(pokemon.innates);
possibleAbilities = possibleAbilities.filter(val => !bannedAbilities.includes(val));
if (!possibleAbilities.length) return;
let ability = this.dex.getAbility(possibleAbilities[this.random(possibleAbilities.length)]);
let ability = this.Dex.abilities.get(possibleAbilities[this.random(possibleAbilities.length)]);
this.add('-ability', pokemon, ability, '[from] ability: Receiver', '[of] ' + ally);
if (isAbility) {
pokemon.setAbility(ability);
Expand Down Expand Up @@ -80,7 +80,7 @@ exports.Abilities = {
possibleTargets.splice(rand, 1);
continue;
}
let ability = this.dex.getAbility(this.sample(possibleAbilities));
let ability = this.Dex.abilities.get(this.sample(possibleAbilities));
this.add('-ability', pokemon, ability, '[from] ability: Trace', '[of] ' + target);
if (isAbility) {
pokemon.setAbility(ability);
Expand Down
2 changes: 1 addition & 1 deletion data/mods/gen7pokebilities/moves.js
Expand Up @@ -8,7 +8,7 @@ exports.Moves = {
// Ability suppression implemented in Pokemon.ignoringAbility() within sim/pokemon.js
onStart(pokemon) {
this.add('-endability', pokemon);
this.singleEvent('End', this.dex.getAbility(pokemon.ability), pokemon.abilityData, pokemon, pokemon, 'gastroacid');
this.singleEvent('End', this.Dex.abilities.get(pokemon.ability), pokemon.abilityData, pokemon, pokemon, 'gastroacid');
// @ts-ignore
if (pokemon.innates) pokemon.innates.forEach(innate => pokemon.removeVolatile("ability" + innate));
},
Expand Down
4 changes: 2 additions & 2 deletions data/mods/pic/moves.ts
Expand Up @@ -2,8 +2,8 @@ export const Moves: {[k: string]: ModdedMoveData} = {
skillswap: {
inherit: true,
onHit(target, source, move) {
let targetAbility = this.dex.getAbility(target.ability);
let sourceAbility = this.dex.getAbility(source.ability);
let targetAbility = this.Dex.abilities.get(target.ability);
let sourceAbility = this.Dex.abilities.get(source.ability);
if (target.side === source.side) {
this.add('-activate', source, 'move: Skill Swap', '', '', '[of] ' + target);
} else {
Expand Down
4 changes: 2 additions & 2 deletions data/mods/pic/scripts.ts
Expand Up @@ -12,13 +12,13 @@ export const Scripts: ModdedBattleScriptsData = {
pokemon: {
setAbility(ability, source, isFromFormechange) {
if (!this.hp) return false;
ability = this.battle.dex.getAbility(ability);
ability = this.battle.Dex.abilities.get(ability);
let oldAbility = this.ability;
if (!isFromFormechange) {
if (['illusion', 'battlebond', 'comatose', 'disguise', 'multitype', 'powerconstruct', 'rkssystem', 'schooling', 'shieldsdown', 'stancechange', 'gulpmissile', 'hungerswitch', 'iceface'].includes(ability.id)) return false;
if (['battlebond', 'comatose', 'disguise', 'multitype', 'powerconstruct', 'rkssystem', 'schooling', 'shieldsdown', 'stancechange', 'gulpmissile', 'hungerswitch', 'iceface'].includes(oldAbility)) return false;
}
this.battle.singleEvent('End', this.battle.dex.getAbility(oldAbility), this.abilityData, this, source);
this.battle.singleEvent('End', this.battle.Dex.abilities.get(oldAbility), this.abilityData, this, source);
let ally = this.side.active.find(ally => ally && ally !== this && !ally.fainted);
if (ally && ally.m.innate) {
ally.removeVolatile(ally.m.innate);
Expand Down
6 changes: 3 additions & 3 deletions data/mods/pokebilities/abilities.ts
Expand Up @@ -13,7 +13,7 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
if (pokemon.m.innates) bannedAbilities = bannedAbilities.concat(pokemon.m.innates);
possibleAbilities = possibleAbilities.filter(val => !bannedAbilities.includes(val));
if (!possibleAbilities.length) return;
let ability = this.dex.getAbility(possibleAbilities[this.random(possibleAbilities.length)]);
let ability = this.Dex.abilities.get(possibleAbilities[this.random(possibleAbilities.length)]);
this.add('-ability', pokemon, ability, '[from] ability: Power of Alchemy', '[of] ' + ally);
if (isAbility) {
pokemon.setAbility(ability);
Expand All @@ -37,7 +37,7 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
if (pokemon.m.innates) bannedAbilities = bannedAbilities.concat(pokemon.m.innates);
possibleAbilities = possibleAbilities.filter(val => !bannedAbilities.includes(val));
if (!possibleAbilities.length) return;
let ability = this.dex.getAbility(possibleAbilities[this.random(possibleAbilities.length)]);
let ability = this.Dex.abilities.get(possibleAbilities[this.random(possibleAbilities.length)]);
this.add('-ability', pokemon, ability, '[from] ability: Receiver', '[of] ' + ally);
if (isAbility) {
pokemon.setAbility(ability);
Expand Down Expand Up @@ -73,7 +73,7 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
possibleTargets.splice(rand, 1);
continue;
}
let ability = this.dex.getAbility(this.sample(possibleAbilities));
let ability = this.Dex.abilities.get(this.sample(possibleAbilities));
this.add('-ability', pokemon, ability, '[from] ability: Trace', '[of] ' + target);
if (isAbility) {
pokemon.setAbility(ability);
Expand Down
2 changes: 1 addition & 1 deletion data/mods/pokebilities/moves.ts
Expand Up @@ -5,7 +5,7 @@ export const Moves: {[k: string]: ModdedMoveData} = {
// Ability suppression implemented in Pokemon.ignoringAbility() within sim/pokemon.js
onStart(pokemon) {
this.add('-endability', pokemon);
this.singleEvent('End', this.dex.getAbility(pokemon.ability), pokemon.abilityData, pokemon, pokemon, 'gastroacid');
this.singleEvent('End', this.Dex.abilities.get(pokemon.ability), pokemon.abilityData, pokemon, pokemon, 'gastroacid');
// @ts-ignore
if (pokemon.m.innates) pokemon.m.innates.forEach(innate => pokemon.removeVolatile("ability:" + innate));
},
Expand Down
24 changes: 12 additions & 12 deletions data/random-teams.ts
Expand Up @@ -2480,7 +2480,7 @@ export class RandomTeams {

let trademarkPool = [];
for (const moveid of movePool) {
let move = this.dex.getMove(moveid);
let move = this.Dex.moves.get(moveid);
if (move.category !== 'Status') continue;
trademarkPool.push(moveid);
}
Expand All @@ -2496,8 +2496,8 @@ export class RandomTeams {
}

suicideCupRandomSet(species: string | Species, teamDetails: RandomTeamsTypes.TeamDetails = {}, isLead = false, isDoubles = false): RandomTeamsTypes.RandomSet {
species = this.dex.getSpecies(species);
let baseSpecies = this.dex.getSpecies(species.baseSpecies);
species = this.Dex.species.get(species);
let baseSpecies = this.Dex.species.get(species.baseSpecies);
let forme = species.name;
const lsetData = this.dex.getLearnsetData(species.id);

Expand Down Expand Up @@ -2632,10 +2632,10 @@ export class RandomTeams {
/**@type {[string, string | undefined, string | undefined]} */
// @ts-ignore
let abilities = Object.values(baseSpecies.abilities);
abilities.sort((a, b) => this.dex.getAbility(b).rating - this.dex.getAbility(a).rating);
let ability0 = this.dex.getAbility(abilities[0]);
let ability1 = this.dex.getAbility(abilities[1]);
let ability2 = this.dex.getAbility(abilities[2]);
abilities.sort((a, b) => this.Dex.abilities.get(b).rating - this.Dex.abilities.get(a).rating);
let ability0 = this.Dex.abilities.get(abilities[0]);
let ability1 = this.Dex.abilities.get(abilities[1]);
let ability2 = this.Dex.abilities.get(abilities[2]);
if (abilities[1]) {
if (abilities[2] && ability1.rating <= ability2.rating && this.randomChance(1, 2)) {
[ability1, ability2] = [ability2, ability1];
Expand Down Expand Up @@ -2878,10 +2878,10 @@ export class RandomTeams {

let pokemonPool = [];
for (let id in this.dex.data.FormatsData) {
let species = this.dex.getSpecies(id);
let species = this.Dex.species.get(id);
if (isMonotype) {
let types = species.types;
if (species.battleOnly) types = this.dex.getSpecies(species.baseSpecies).types;
if (species.battleOnly) types = this.Dex.species.get(species.baseSpecies).types;
if (types.indexOf(type) < 0) continue;
}
if (species.gen <= this.gen && !species.isMega && !species.isPrimal && !species.isNonstandard && species.randomBattleMoves) {
Expand All @@ -2892,7 +2892,7 @@ export class RandomTeams {
// PotD stuff
let potd: Species | false = false;
if (global.Config && Config.potd && ruleTable.has('potd')) {
potd = this.dex.getSpecies(Config.potd);
potd = this.Dex.species.get(Config.potd);
}

/**@type {{[k: string]: number}} */
Expand All @@ -2907,7 +2907,7 @@ export class RandomTeams {
let teamDetails = {};

while (pokemonPool.length && pokemon.length < 6) {
let species = this.dex.getSpecies(this.sampleNoReplace(pokemonPool));
let species = this.Dex.species.get(this.sampleNoReplace(pokemonPool));
if (!species.exists) continue;

// Limit to one of each species (Species Clause)
Expand Down Expand Up @@ -2976,7 +2976,7 @@ export class RandomTeams {
if (typeComboCount[typeCombo] >= (isMonotype ? 2 : 1)) continue;
}

let item = this.dex.getItem(set.item);
let item = this.Dex.items.get(set.item);

// Limit 1 Z-Move per team
if (teamDetails['zMove'] && item.zMove) continue;
Expand Down

0 comments on commit 6686ad9

Please sign in to comment.