File size: 7,597 Bytes
5c2ed06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
"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 teams_exports = {};
__export(teams_exports, {
  RandomGen7ApexTeams: () => RandomGen7ApexTeams,
  default: () => teams_default
});
module.exports = __toCommonJS(teams_exports);
var import_teams = require("../gen7/teams");
const POWERFUL_ABILITIES = [
  "Adaptability",
  "Aftermath",
  "Analytic",
  "Arena Trap",
  "Beast Boost",
  "Berserk",
  "Comatose",
  "Competitive",
  "Compound Eyes",
  "Contrary",
  "Cursed Body",
  "Defiant",
  "Desolate Land",
  "Download",
  "Drizzle",
  "Drought",
  "Dry Skin",
  "Effect Spore",
  "Filter",
  "Flame Body",
  "Flash Fire",
  "Fluffy",
  "Fur Coat",
  "Gooey",
  "Grassy Surge",
  "Heatproof",
  "Huge Power",
  "Hustle",
  "Illusion",
  "Imposter",
  "Innards Out",
  "Intimidate",
  "Iron Barbs",
  "Levitate",
  "Lightning Rod",
  "Magic Bounce",
  "Magic Guard",
  "Marvel Scale",
  "Mold Breaker",
  "Moody",
  "Motor Drive",
  "Moxie",
  "Multiscale",
  "Natural Cure",
  "Neuroforce",
  "Parental Bond",
  "Poison Point",
  "Poison Touch",
  "Prankster",
  "Primordial Sea",
  "Prism Armor",
  "Protean",
  "Pure Power",
  "Regenerator",
  "Rough Skin",
  "Sand Stream",
  "Sap Sipper",
  "Serene Grace",
  "Shadow Shield",
  "Shadow Tag",
  "Shed Skin",
  "Sheer Force",
  "Shield Dust",
  "Simple",
  "Snow Warning",
  "Solid Rock",
  "Soul-Heart",
  "Speed Boost",
  "Stakeout",
  "Stamina",
  "Static",
  "Storm Drain",
  "Sturdy",
  "Tangling Hair",
  "Technician",
  "Teravolt",
  "Thick Fat",
  "Tinted Lens",
  "Tough Claws",
  "Trace",
  "Triage",
  "Turboblaze",
  "Unaware",
  "Volt Absorb",
  "Water Absorb",
  "Water Bubble",
  "Wonder Guard"
];
class RandomGen7ApexTeams extends import_teams.RandomGen7Teams {
  randomSet(species, teamDetails = {}, isLead = false) {
    species = this.dex.species.get(species);
    const forme = this.getForme(species);
    const sets = this.randomSets[species.id]["sets"];
    const possibleSets = [];
    let canZMove = false;
    for (const set2 of sets) {
      if (!teamDetails.zMove && set2.role === "Z-Move user")
        canZMove = true;
    }
    for (const set2 of sets) {
      if (teamDetails.zMove && set2.role === "Z-Move user")
        continue;
      if (canZMove && ["Setup Sweeper", "Bulky Setup"].includes(set2.role))
        continue;
      possibleSets.push(set2);
    }
    const set = this.sampleIfArray(possibleSets);
    const role = set.role;
    const movePool = Array.from(set.movepool);
    const preferredTypes = set.preferredTypes;
    const preferredType = this.sampleIfArray(preferredTypes) || "";
    let ability = "";
    let item = void 0;
    const evs = { hp: 85, atk: 85, def: 85, spa: 85, spd: 85, spe: 85 };
    const ivs = { hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31 };
    const types = species.types;
    const baseAbilities = set.abilities;
    const abilities = species.battleOnly && !species.requiredAbility ? Object.values(species.abilities) : baseAbilities;
    const moves = this.randomMoveset(
      types,
      abilities,
      teamDetails,
      species,
      isLead,
      movePool,
      preferredType,
      role
    );
    const counter = this.newQueryMoves(moves, species, preferredType, abilities);
    ability = this.getAbility(
      new Set(types),
      moves,
      baseAbilities,
      counter,
      movePool,
      teamDetails,
      species,
      preferredType,
      role
    );
    item = this.getPriorityItem(ability, types, moves, counter, teamDetails, species, isLead, preferredType, role);
    if (item === void 0) {
      item = this.getItem(ability, types, moves, counter, teamDetails, species, isLead, preferredType, role);
    }
    if (item === "Leftovers" && types.includes("Poison")) {
      item = "Black Sludge";
    }
    const level = this.getLevel(species);
    if ((!counter.get("Physical") || counter.get("Physical") <= 1 && (moves.has("foulplay") || moves.has("rapidspin"))) && !moves.has("copycat") && !moves.has("transform")) {
      evs.atk = 0;
      ivs.atk = 0;
    }
    ability = this.sample(POWERFUL_ABILITIES);
    if (ability === "Beast Boost" && !counter.get("Special")) {
      evs.spa = 0;
      ivs.spa = 0;
    }
    let hasHiddenPower = false;
    for (const move of moves) {
      if (move.startsWith("hiddenpower"))
        hasHiddenPower = true;
    }
    if (hasHiddenPower && level < 100) {
      let hpType;
      for (const move of moves) {
        if (move.startsWith("hiddenpower"))
          hpType = move.substr(11);
      }
      if (!hpType)
        throw new Error(`hasHiddenPower is true, but no Hidden Power move was found.`);
      const HPivs = ivs.atk === 0 ? import_teams.ZeroAttackHPIVs[hpType] : this.dex.types.get(hpType).HPivs;
      let iv;
      for (iv in HPivs) {
        ivs[iv] = HPivs[iv];
      }
    }
    const srImmunity = ability === "Magic Guard";
    const srWeakness = srImmunity ? 0 : this.dex.getEffectiveness("Rock", species);
    while (evs.hp > 1) {
      const hp = Math.floor(Math.floor(2 * species.baseStats.hp + ivs.hp + Math.floor(evs.hp / 4) + 100) * level / 100 + 10);
      if (moves.has("substitute") && !["Black Sludge", "Leftovers"].includes(item)) {
        if (item === "Sitrus Berry") {
          if (hp % 4 === 0)
            break;
        } else {
          if (hp % 4 > 0)
            break;
        }
      } else if (moves.has("bellydrum") && item === "Sitrus Berry") {
        if (hp % 2 === 0)
          break;
      } else if (["highjumpkick", "jumpkick"].some((m) => moves.has(m))) {
        if (hp % 2 > 0)
          break;
      } else {
        if (srWeakness <= 0 || ability === "Regenerator")
          break;
        if (srWeakness === 1 && ["Black Sludge", "Leftovers", "Life Orb"].includes(item))
          break;
        if (item !== "Sitrus Berry" && hp % (4 / srWeakness) > 0)
          break;
        if (item === "Sitrus Berry" && hp % (4 / srWeakness) === 0)
          break;
      }
      evs.hp -= 4;
    }
    if (["gyroball", "metalburst", "trickroom"].some((m) => moves.has(m))) {
      evs.spe = 0;
      ivs.spe = hasHiddenPower && level < 100 ? ivs.spe - 30 : 0;
    }
    const shuffledMoves = Array.from(moves);
    this.prng.shuffle(shuffledMoves);
    if (species.id === "porygonz" && role === "Z-Move user") {
      const firstMove = moves.has("shadowball") ? "shadowball" : "thunderbolt";
      this.fastPop(shuffledMoves, shuffledMoves.indexOf(firstMove));
      shuffledMoves.unshift(firstMove);
    }
    return {
      name: species.baseSpecies,
      species: forme,
      gender: species.baseSpecies === "Greninja" ? "M" : species.gender,
      shiny: this.randomChance(1, 1024),
      level,
      moves: shuffledMoves,
      ability,
      evs,
      ivs,
      item,
      role
    };
  }
}
var teams_default = RandomGen7ApexTeams;
//# sourceMappingURL=teams.js.map