LTDV10/packet/showdown/data/mods/mixandmega/random-teams.js
2026-04-14 18:20:56 +08:00

146 lines
5.5 KiB
JavaScript

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var random_teams_exports = {};
__export(random_teams_exports, {
RandomMnMTeams: () => RandomMnMTeams,
default: () => random_teams_default
});
module.exports = __toCommonJS(random_teams_exports);
var import_random_teams = require("./../../random-teams");
var import_dex = require("../../../sim/dex");
const mnmItems = [
"blueorb",
"redorb",
"rustedshield",
"rustedsword"
];
class RandomMnMTeams extends import_random_teams.RandomTeams {
randomCCTeam() {
this.enforceNoDirectCustomBanlistChanges();
const dex = this.dex;
const team = [];
const natures = this.dex.natures.all();
const items = this.dex.items.all().filter((item) => item.megaStone || mnmItems.includes(item.id));
const randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, void 0, void 0, true);
for (let forme of randomN) {
let species = dex.species.get(forme);
if (species.isNonstandard)
species = dex.species.get(species.baseSpecies);
let item = "";
let isIllegalItem;
if (this.gen >= 2) {
do {
item = this.sample(items).name;
isIllegalItem = this.dex.items.get(item).gen > this.gen || this.dex.items.get(item).isNonstandard;
} while (isIllegalItem);
}
if (species.battleOnly) {
if (typeof species.battleOnly === "string") {
species = dex.species.get(species.battleOnly);
} else {
species = dex.species.get(this.sample(species.battleOnly));
}
forme = species.name;
} else if (species.requiredItems && !species.requiredItems.some((req) => (0, import_dex.toID)(req) === item)) {
if (!species.changesFrom)
throw new Error(`${species.name} needs a changesFrom value`);
species = dex.species.get(species.changesFrom);
forme = species.name;
}
const abilities = Object.values(species.abilities).filter((a) => this.dex.abilities.get(a).gen <= this.gen);
const ability = this.gen <= 2 ? "No Ability" : this.sample(abilities);
let pool = ["struggle"];
if (forme === "Smeargle") {
pool = this.dex.moves.all().filter((move) => !(move.isNonstandard || move.isZ || move.isMax || move.realMove)).map((m) => m.id);
} else {
pool = [...this.dex.species.getMovePool(species.id)];
}
const moves = this.multipleSamplesNoReplace(pool, this.maxMoveCount);
const evs = { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0 };
const s = ["hp", "atk", "def", "spa", "spd", "spe"];
let evpool = 510;
do {
const x = this.sample(s);
const y = this.random(Math.min(256 - evs[x], evpool + 1));
evs[x] += y;
evpool -= y;
} while (evpool > 0);
const ivs = {
hp: this.random(32),
atk: this.random(32),
def: this.random(32),
spa: this.random(32),
spd: this.random(32),
spe: this.random(32)
};
const nature = this.sample(natures).name;
const mbstmin = 1307;
let stats = species.baseStats;
if (species.baseSpecies === "Wishiwashi")
stats = Dex.species.get("wishiwashischool").baseStats;
let mbst = stats["hp"] * 2 + 31 + 21 + 100 + 10;
mbst += stats["atk"] * 2 + 31 + 21 + 100 + 5;
mbst += stats["def"] * 2 + 31 + 21 + 100 + 5;
mbst += stats["spa"] * 2 + 31 + 21 + 100 + 5;
mbst += stats["spd"] * 2 + 31 + 21 + 100 + 5;
mbst += stats["spe"] * 2 + 31 + 21 + 100 + 5;
let level;
if (this.adjustLevel) {
level = this.adjustLevel;
} else {
level = Math.floor(100 * mbstmin / mbst);
while (level < 100) {
mbst = Math.floor((stats["hp"] * 2 + 31 + 21 + 100) * level / 100 + 10);
mbst += Math.floor(((stats["atk"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);
mbst += Math.floor((stats["def"] * 2 + 31 + 21 + 100) * level / 100 + 5);
mbst += Math.floor(((stats["spa"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);
mbst += Math.floor((stats["spd"] * 2 + 31 + 21 + 100) * level / 100 + 5);
mbst += Math.floor((stats["spe"] * 2 + 31 + 21 + 100) * level / 100 + 5);
if (mbst >= mbstmin)
break;
level++;
}
}
const happiness = this.random(256);
const shiny = this.randomChance(1, 1024);
const set = {
name: species.baseSpecies,
species: species.name,
gender: species.gender,
item,
ability,
moves,
evs,
ivs,
nature,
level,
happiness,
shiny
};
if (this.gen === 9) {
set.teraType = this.sample(this.dex.types.all()).name;
}
team.push(set);
}
return team;
}
}
var random_teams_default = RandomMnMTeams;
//# sourceMappingURL=random-teams.js.map