Use weight 0 for modifiers when stack is maxed

This commit is contained in:
Flashfyre 2023-05-09 15:01:27 -04:00
parent 930b960374
commit 9f28a067cd
2 changed files with 17 additions and 12 deletions

View File

@ -27,6 +27,7 @@ type NewModifierFunc = (type: ModifierType, args: any[]) => Modifier;
export class ModifierType {
public id: string;
public generatorId: string;
public name: string;
public description: string;
public iconImage: string;
@ -66,6 +67,7 @@ export class ModifierTypeGenerator extends ModifierType {
generateType(party: Pokemon[], pregenArgs?: any[]) {
const ret = this.genTypeFunc(party, pregenArgs);
if (ret) {
ret.generatorId = ret.id;
ret.id = this.id;
ret.setTier(this.tier);
}
@ -693,11 +695,9 @@ const modifierPool = {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => (m.getMove().pp - m.ppUsed) <= 5).length).length, 3);
return thresholdPartyMemberCount;
}),
new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => {
return !party[0].scene.findModifier(m => m instanceof Modifiers.MapModifier) ? 1 : 0;
}),
new WeightedModifierType(modifierTypes.MAP, 1),
new WeightedModifierType(modifierTypes.TM_GREAT, 2),
new WeightedModifierType(modifierTypes.EXP_SHARE, (party: Pokemon[]) => party.filter(p => p.level < maxExpLevel).length ? 1 : 0),
new WeightedModifierType(modifierTypes.EXP_SHARE, 1),
new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
[ModifierTier.ULTRA]: [
@ -714,10 +714,9 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.LEFTOVERS, 2),
new WeightedModifierType(modifierTypes.SHELL_BELL, 2),
new WeightedModifierType(modifierTypes.BERRY_POUCH, 3),
new WeightedModifierType(modifierTypes.EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < maxExpLevel).length ? 4 : 0),
new WeightedModifierType(modifierTypes.OVAL_CHARM, (party: Pokemon[]) => party.filter(p => p.level < maxExpLevel).length ? 2 : 0),
new WeightedModifierType(modifierTypes.EXP_BALANCE,
(party: Pokemon[]) => party.filter(p => p.level < maxExpLevel).length && !party[0].scene.findModifier(m => m instanceof Modifiers.ExpBalanceModifier) ? 1 : 0)
new WeightedModifierType(modifierTypes.EXP_CHARM, 4),
new WeightedModifierType(modifierTypes.OVAL_CHARM, 2),
new WeightedModifierType(modifierTypes.EXP_BALANCE, 1)
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [
new WeightedModifierType(modifierTypes.MASTER_BALL, 3),
@ -725,7 +724,7 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => party[0].scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE] ? 1 : 0)
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
[ModifierTier.LUXURY]: [
new WeightedModifierType(modifierTypes.GOLDEN_EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < maxExpLevel).length ? 1 : 0),
new WeightedModifierType(modifierTypes.GOLDEN_EXP_CHARM, 1),
new WeightedModifierType(modifierTypes.GOLDEN_POKEBALL, 1),
new WeightedModifierType(modifierTypes.RARER_CANDY, 1)
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
@ -769,9 +768,12 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], player?: bool
let i = 0;
pool[t].reduce((total: integer, modifierType: WeightedModifierType) => {
const weightedModifierType = modifierType as WeightedModifierType;
const weight = weightedModifierType.weight instanceof Function
? (weightedModifierType.weight as Function)(party)
: weightedModifierType.weight as integer;
const existingModifier = party[0].scene.findModifier(m => (m.type.generatorId || m.type.id) === weightedModifierType.modifierType.id);
const weight = !existingModifier || existingModifier.stackCount < existingModifier.getMaxStackCount()
? weightedModifierType.weight instanceof Function
? (weightedModifierType.weight as Function)(party)
: weightedModifierType.weight as integer
: 0;
if (weight)
total += weight;
else {

View File

@ -5,6 +5,7 @@ import { GeneratedPersistentModifierType, ModifierTypeGenerator, getModifierType
export default class ModifierData {
private player: boolean;
private typeId: string;
private typeGeneratorId: string;
private typePregenArgs: any[];
private args: any[];
private stackCount: integer;
@ -15,6 +16,7 @@ export default class ModifierData {
const sourceModifier = source instanceof PersistentModifier ? source as PersistentModifier : null;
this.player = player;
this.typeId = sourceModifier ? sourceModifier.type.id : source.typeId;
this.typeGeneratorId = sourceModifier ? sourceModifier.type.generatorId : source.typeGeneratorId;
if (sourceModifier) {
if ('getPregenArgs' in source.type)
this.typePregenArgs = (source.type as GeneratedPersistentModifierType).getPregenArgs();
@ -32,6 +34,7 @@ export default class ModifierData {
let type = typeFunc();
type.id = this.typeId;
type.generatorId = this.typeGeneratorId;
if (type instanceof ModifierTypeGenerator)
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyParty(), this.typePregenArgs);