mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-25 15:40:31 -05:00
Battle Factory: Fix item and ability restrictions (#10109)
This commit is contained in:
parent
6bb9c97551
commit
fc3564f275
|
|
@ -1477,19 +1477,33 @@ export class RandomGen7Teams extends RandomGen8Teams {
|
|||
|
||||
// Build a pool of eligible sets, given the team partners
|
||||
// Also keep track of sets with moves the team requires
|
||||
let effectivePool: {set: AnyObject, moveVariants?: number[]}[] = [];
|
||||
let effectivePool: {set: AnyObject, moveVariants?: number[], item?: string, ability?: string}[] = [];
|
||||
const priorityPool = [];
|
||||
for (const curSet of setList) {
|
||||
if (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;
|
||||
|
||||
const item = this.dex.items.get(curSet.item);
|
||||
if (teamData.megaCount && teamData.megaCount > 0 && item.megaStone) continue; // reject 2+ mega stones
|
||||
if (teamData.zCount && teamData.zCount > 0 && item.zMove) continue; // reject 2+ Z stones
|
||||
if (itemsMax[item.id] && teamData.has[item.id] >= itemsMax[item.id]) continue;
|
||||
// reject disallowed items
|
||||
const allowedItems: string[] = [];
|
||||
for (const itemString of curSet.item) {
|
||||
const item = this.dex.items.get(itemString);
|
||||
if (teamData.megaCount && teamData.megaCount > 0 && item.megaStone) continue; // reject 2+ mega stones
|
||||
if (teamData.zCount && teamData.zCount > 0 && item.zMove) continue; // reject 2+ Z stones
|
||||
if (itemsMax[item.id] && teamData.has[item.id] >= itemsMax[item.id]) continue; // reject 2+ same choice item
|
||||
allowedItems.push(itemString);
|
||||
}
|
||||
if (allowedItems.length === 0) continue;
|
||||
const curSetItem = this.sample(allowedItems);
|
||||
|
||||
const ability = this.dex.abilities.get(curSet.ability);
|
||||
if (weatherAbilitiesRequire[ability.id] && teamData.weather !== weatherAbilitiesRequire[ability.id]) continue;
|
||||
if (teamData.weather && weatherAbilities.includes(ability.id)) continue; // reject 2+ weather setters
|
||||
// reject bad weather abilities
|
||||
const allowedAbilities: string[] = [];
|
||||
for (const abilityString of curSet.ability) {
|
||||
const ability = this.dex.abilities.get(abilityString);
|
||||
if (weatherAbilitiesRequire[ability.id] && teamData.weather !== weatherAbilitiesRequire[ability.id]) continue;
|
||||
if (teamData.weather && weatherAbilities.includes(ability.id)) continue; // reject 2+ weather setters
|
||||
allowedAbilities.push(abilityString);
|
||||
}
|
||||
if (allowedAbilities.length === 0) continue;
|
||||
const curSetAbility = this.sample(allowedAbilities);
|
||||
|
||||
let reject = false;
|
||||
let hasRequiredMove = false;
|
||||
|
|
@ -1507,8 +1521,10 @@ export class RandomGen7Teams extends RandomGen8Teams {
|
|||
curSetVariants.push(variantIndex);
|
||||
}
|
||||
if (reject) continue;
|
||||
effectivePool.push({set: curSet, moveVariants: curSetVariants});
|
||||
if (hasRequiredMove) priorityPool.push({set: curSet, moveVariants: curSetVariants});
|
||||
|
||||
const fullSetSpec = {set: curSet, moveVariants: curSetVariants, item: curSetItem, ability: curSetAbility};
|
||||
effectivePool.push(fullSetSpec);
|
||||
if (hasRequiredMove) priorityPool.push(fullSetSpec);
|
||||
}
|
||||
if (priorityPool.length) effectivePool = priorityPool;
|
||||
|
||||
|
|
@ -1526,8 +1542,8 @@ export class RandomGen7Teams extends RandomGen8Teams {
|
|||
}
|
||||
|
||||
|
||||
const item = this.sampleIfArray(setData.set.item);
|
||||
const ability = this.sampleIfArray(setData.set.ability);
|
||||
const item = setData.item || this.sampleIfArray(setData.set.item);
|
||||
const ability = setData.ability || this.sampleIfArray(setData.set.ability);
|
||||
const nature = this.sampleIfArray(setData.set.nature);
|
||||
const level = this.adjustLevel || setData.set.level || (tier === "LC" ? 5 : 100);
|
||||
|
||||
|
|
|
|||
|
|
@ -2662,16 +2662,30 @@ export class RandomGen8Teams {
|
|||
|
||||
// Build a pool of eligible sets, given the team partners
|
||||
// Also keep track of sets with moves the team requires
|
||||
let effectivePool: {set: AnyObject, moveVariants?: number[]}[] = [];
|
||||
let effectivePool: {set: AnyObject, moveVariants?: number[], item?: string, ability?: string}[] = [];
|
||||
const priorityPool = [];
|
||||
for (const curSet of setList) {
|
||||
// if (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;
|
||||
|
||||
const item = this.dex.items.get(curSet.item);
|
||||
if (itemsMax[item.id] && teamData.has[item.id] >= itemsMax[item.id]) continue;
|
||||
// reject disallowed items, specifically a second of any given choice item
|
||||
const allowedItems: string[] = [];
|
||||
for (const itemString of curSet.item) {
|
||||
const item = this.dex.items.get(itemString);
|
||||
if (itemsMax[item.id] && teamData.has[item.id] >= itemsMax[item.id]) continue;
|
||||
allowedItems.push(itemString);
|
||||
}
|
||||
if (allowedItems.length === 0) continue;
|
||||
const curSetItem = this.sample(allowedItems);
|
||||
|
||||
const ability = this.dex.abilities.get(curSet.ability);
|
||||
if (teamData.weather && weatherAbilities.includes(ability.id)) continue; // reject 2+ weather setters
|
||||
// reject 2+ weather setters
|
||||
const allowedAbilities: string[] = [];
|
||||
for (const abilityString of curSet.ability) {
|
||||
const ability = this.dex.abilities.get(abilityString);
|
||||
if (teamData.weather && weatherAbilities.includes(ability.id)) continue;
|
||||
allowedAbilities.push(abilityString);
|
||||
}
|
||||
if (allowedAbilities.length === 0) continue;
|
||||
const curSetAbility = this.sample(allowedAbilities);
|
||||
|
||||
let reject = false;
|
||||
let hasRequiredMove = false;
|
||||
|
|
@ -2689,8 +2703,10 @@ export class RandomGen8Teams {
|
|||
curSetVariants.push(variantIndex);
|
||||
}
|
||||
if (reject) continue;
|
||||
effectivePool.push({set: curSet, moveVariants: curSetVariants});
|
||||
if (hasRequiredMove) priorityPool.push({set: curSet, moveVariants: curSetVariants});
|
||||
|
||||
const fullSetSpec = {set: curSet, moveVariants: curSetVariants, item: curSetItem, ability: curSetAbility};
|
||||
effectivePool.push(fullSetSpec);
|
||||
if (hasRequiredMove) priorityPool.push(fullSetSpec);
|
||||
}
|
||||
if (priorityPool.length) effectivePool = priorityPool;
|
||||
|
||||
|
|
@ -2708,8 +2724,8 @@ export class RandomGen8Teams {
|
|||
}
|
||||
|
||||
|
||||
const item = this.sampleIfArray(setData.set.item);
|
||||
const ability = this.sampleIfArray(setData.set.ability);
|
||||
const item = setData.item || this.sampleIfArray(setData.set.item);
|
||||
const ability = setData.ability || this.sampleIfArray(setData.set.ability);
|
||||
const nature = this.sampleIfArray(setData.set.nature);
|
||||
const level = this.adjustLevel || setData.set.level || (tier === "LC" ? 5 : 100);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user