Item stealing items prioritize rarer items

Item stealing items prioritize rarer items; reward premium voucher for subsequent classic clears
This commit is contained in:
Flashfyre 2024-02-22 00:34:54 -05:00
parent 7ad099b243
commit 9c986f44ac
3 changed files with 27 additions and 3 deletions

View File

@ -59,6 +59,20 @@ export class ModifierType {
this.tier = tier; this.tier = tier;
} }
getOrInferTier(): ModifierTier {
if (this.tier)
return this.tier;
if (!this.id)
return null;
for (let tier of Utils.getEnumValues(ModifierTier)) {
if (!modifierPool.hasOwnProperty(tier))
continue;
if (modifierPool[tier].find(m => (m as WeightedModifierType).modifierType.id === (this.generatorId || this.id)))
return (this.tier = tier);
}
return null;
}
withIdFromFunc(func: ModifierTypeFunc): ModifierType { withIdFromFunc(func: ModifierTypeFunc): ModifierType {
this.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === func); this.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === func);
return this; return this;

View File

@ -18,6 +18,7 @@ import { MoneyAchv, achvs } from '../system/achv';
import { VoucherType } from '../system/voucher'; import { VoucherType } from '../system/voucher';
import { PreventBerryUseAbAttr, applyAbAttrs } from '../data/ability'; import { PreventBerryUseAbAttr, applyAbAttrs } from '../data/ability';
import { FormChangeItem, SpeciesFormChangeItemTrigger } from '../data/pokemon-forms'; import { FormChangeItem, SpeciesFormChangeItemTrigger } from '../data/pokemon-forms';
import { ModifierTier } from './modifier-tier';
type ModifierType = ModifierTypes.ModifierType; type ModifierType = ModifierTypes.ModifierType;
export type ModifierPredicate = (modifier: Modifier) => boolean; export type ModifierPredicate = (modifier: Modifier) => boolean;
@ -1648,12 +1649,18 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier {
const transferredModifierTypes: ModifierTypes.ModifierType[] = []; const transferredModifierTypes: ModifierTypes.ModifierType[] = [];
const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id && m.getTransferrable(withinParty), targetPokemon.isPlayer()) as PokemonHeldItemModifier[]; && (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id && m.getTransferrable(withinParty), targetPokemon.isPlayer()) as PokemonHeldItemModifier[];
let highestItemTier = itemModifiers.map(m => m.type.getOrInferTier()).reduce((highestTier, tier) => Math.max(tier, highestTier), 0);
let tierItemModifiers = itemModifiers.filter(m => m.type.getOrInferTier() === highestItemTier);
let heldItemTransferPromises: Promise<void>[] = []; let heldItemTransferPromises: Promise<void>[] = [];
for (let i = 0; i < transferredItemCount; i++) { for (let i = 0; i < transferredItemCount; i++) {
if (!itemModifiers.length) if (!tierItemModifiers.length) {
break; while (highestItemTier-- && !tierItemModifiers.length)
tierItemModifiers = itemModifiers.filter(m => m.type.tier === highestItemTier);
if (!tierItemModifiers.length)
break;
}
const randItemIndex = pokemon.randSeedInt(itemModifiers.length); const randItemIndex = pokemon.randSeedInt(itemModifiers.length);
const randItem = itemModifiers[randItemIndex]; const randItem = itemModifiers[randItemIndex];
heldItemTransferPromises.push(pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, false, false, true).then(success => { heldItemTransferPromises.push(pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, false, false, true).then(success => {

View File

@ -2885,8 +2885,9 @@ export class GameOverPhase extends BattlePhase {
this.scene.gameData.clearSession().then(() => { this.scene.gameData.clearSession().then(() => {
this.scene.time.delayedCall(1000, () => { this.scene.time.delayedCall(1000, () => {
let firstClear = false;
if (this.victory) { if (this.victory) {
this.scene.validateAchv(achvs.CLASSIC_VICTORY); firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
this.scene.gameData.gameStats.sessionsWon++; this.scene.gameData.gameStats.sessionsWon++;
} }
this.scene.gameData.saveSystem(); this.scene.gameData.saveSystem();
@ -2896,6 +2897,8 @@ export class GameOverPhase extends BattlePhase {
this.scene.clearPhaseQueue(); this.scene.clearPhaseQueue();
this.scene.ui.clearText(); this.scene.ui.clearText();
this.handleUnlocks(this.scene.getParty()); this.handleUnlocks(this.scene.getParty());
if (!firstClear)
this.scene.unshiftPhase(new ModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PREMIUM));
this.scene.reset(); this.scene.reset();
this.scene.unshiftPhase(new CheckLoadPhase(this.scene)); this.scene.unshiftPhase(new CheckLoadPhase(this.scene));
this.end(); this.end();