small cleanup to MEs branch
This commit is contained in:
parent
cc893daf73
commit
c9d57c1a36
|
@ -1160,14 +1160,6 @@ export default class BattleScene extends SceneBase {
|
||||||
this.field.add(newTrainer);
|
this.field.add(newTrainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove these once ME spawn rates are finalized
|
|
||||||
// let testStartingWeight = 3;
|
|
||||||
// while (testStartingWeight < 4) {
|
|
||||||
// calculateMEAggregateStats(this, testStartingWeight);
|
|
||||||
// testStartingWeight += 1;
|
|
||||||
// }
|
|
||||||
// calculateRareSpawnAggregateStats(this, 14);
|
|
||||||
|
|
||||||
// Check for mystery encounter
|
// Check for mystery encounter
|
||||||
// Can only occur in place of a standard (non-boss) wild battle, waves 10-180
|
// Can only occur in place of a standard (non-boss) wild battle, waves 10-180
|
||||||
const highestMysteryEncounterWave = 180;
|
const highestMysteryEncounterWave = 180;
|
||||||
|
@ -2582,19 +2574,18 @@ export default class BattleScene extends SceneBase {
|
||||||
party.forEach((enemyPokemon: EnemyPokemon, i: integer) => {
|
party.forEach((enemyPokemon: EnemyPokemon, i: integer) => {
|
||||||
if (heldModifiersConfigs && i < heldModifiersConfigs.length && heldModifiersConfigs[i] && heldModifiersConfigs[i].length > 0) {
|
if (heldModifiersConfigs && i < heldModifiersConfigs.length && heldModifiersConfigs[i] && heldModifiersConfigs[i].length > 0) {
|
||||||
heldModifiersConfigs[i].forEach(mt => {
|
heldModifiersConfigs[i].forEach(mt => {
|
||||||
|
let modifier: PokemonHeldItemModifier;
|
||||||
if (mt.modifier instanceof PokemonHeldItemModifierType) {
|
if (mt.modifier instanceof PokemonHeldItemModifierType) {
|
||||||
const stackCount = mt.stackCount ?? 1;
|
modifier = mt.modifier.newModifier(enemyPokemon);
|
||||||
// const isTransferable = mt.isTransferable ?? true;
|
|
||||||
const modifier = mt.modifier.newModifier(enemyPokemon);
|
|
||||||
modifier.stackCount = stackCount;
|
|
||||||
// TODO: set isTransferable
|
|
||||||
// modifier.setIsTransferable(isTransferable);
|
|
||||||
this.addEnemyModifier(modifier, true);
|
|
||||||
} else {
|
} else {
|
||||||
const modifier = mt.modifier as PokemonHeldItemModifier;
|
modifier = mt.modifier as PokemonHeldItemModifier;
|
||||||
modifier.pokemonId = enemyPokemon.id;
|
modifier.pokemonId = enemyPokemon.id;
|
||||||
this.addEnemyModifier(modifier, true);
|
|
||||||
}
|
}
|
||||||
|
const stackCount = mt.stackCount ?? 1;
|
||||||
|
modifier.stackCount = stackCount;
|
||||||
|
// TODO: set isTransferable
|
||||||
|
// modifier.isTransferrable = mt.isTransferable ?? true;
|
||||||
|
this.addEnemyModifier(modifier, true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const isBoss = enemyPokemon.isBoss() || (this.currentBattle.battleType === BattleType.TRAINER && !!this.currentBattle.trainer?.config.isBoss);
|
const isBoss = enemyPokemon.isBoss() || (this.currentBattle.battleType === BattleType.TRAINER && !!this.currentBattle.trainer?.config.isBoss);
|
||||||
|
@ -2957,7 +2948,7 @@ export default class BattleScene extends SceneBase {
|
||||||
// See Enum values for base tier weights
|
// See Enum values for base tier weights
|
||||||
const tierWeights = [MysteryEncounterTier.COMMON, MysteryEncounterTier.GREAT, MysteryEncounterTier.ULTRA, MysteryEncounterTier.ROGUE];
|
const tierWeights = [MysteryEncounterTier.COMMON, MysteryEncounterTier.GREAT, MysteryEncounterTier.ULTRA, MysteryEncounterTier.ROGUE];
|
||||||
|
|
||||||
// Adjust tier weights by previously encountered events to lower odds of only common/uncommons in run
|
// Adjust tier weights by previously encountered events to lower odds of only Common/Great in run
|
||||||
this.mysteryEncounterData.encounteredEvents.forEach(seenEncounterData => {
|
this.mysteryEncounterData.encounteredEvents.forEach(seenEncounterData => {
|
||||||
if (seenEncounterData.tier === MysteryEncounterTier.COMMON) {
|
if (seenEncounterData.tier === MysteryEncounterTier.COMMON) {
|
||||||
tierWeights[0] = tierWeights[0] - 6;
|
tierWeights[0] = tierWeights[0] - 6;
|
||||||
|
@ -2969,9 +2960,9 @@ export default class BattleScene extends SceneBase {
|
||||||
const totalWeight = tierWeights.reduce((a, b) => a + b);
|
const totalWeight = tierWeights.reduce((a, b) => a + b);
|
||||||
const tierValue = Utils.randSeedInt(totalWeight);
|
const tierValue = Utils.randSeedInt(totalWeight);
|
||||||
const commonThreshold = totalWeight - tierWeights[0];
|
const commonThreshold = totalWeight - tierWeights[0];
|
||||||
const uncommonThreshold = totalWeight - tierWeights[0] - tierWeights[1];
|
const greatThreshold = totalWeight - tierWeights[0] - tierWeights[1];
|
||||||
const rareThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2];
|
const ultraThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2];
|
||||||
let tier: MysteryEncounterTier | null = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > uncommonThreshold ? MysteryEncounterTier.GREAT : tierValue > rareThreshold ? MysteryEncounterTier.ULTRA : MysteryEncounterTier.ROGUE;
|
let tier: MysteryEncounterTier | null = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > greatThreshold ? MysteryEncounterTier.GREAT : tierValue > ultraThreshold ? MysteryEncounterTier.ULTRA : MysteryEncounterTier.ROGUE;
|
||||||
|
|
||||||
if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE)) {
|
if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE)) {
|
||||||
tier = Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE!;
|
tier = Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE!;
|
||||||
|
|
|
@ -195,8 +195,8 @@ export default class Battle {
|
||||||
getBgmOverride(scene: BattleScene): string | null {
|
getBgmOverride(scene: BattleScene): string | null {
|
||||||
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
||||||
if (this.battleType === BattleType.MYSTERY_ENCOUNTER && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
|
if (this.battleType === BattleType.MYSTERY_ENCOUNTER && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
|
||||||
// Music is overridden MEs during ME onInit()
|
// Music is overridden for MEs during ME onInit()
|
||||||
// Should not use BGM overrides before swapping from DEFAULT mode
|
// Should not use any BGM overrides before swapping from DEFAULT mode
|
||||||
return null;
|
return null;
|
||||||
} else if (this.battleType === BattleType.TRAINER || this.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) {
|
} else if (this.battleType === BattleType.TRAINER || this.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) {
|
||||||
if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) {
|
if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) {
|
||||||
|
|
|
@ -991,7 +991,7 @@ export function calculateMEAggregateStats(scene: BattleScene, baseSpawnWeight: n
|
||||||
// Common / Uncommon / Rare / Super Rare (base is out of 128)
|
// Common / Uncommon / Rare / Super Rare (base is out of 128)
|
||||||
const tierWeights = [66, 40, 19, 3];
|
const tierWeights = [66, 40, 19, 3];
|
||||||
|
|
||||||
// Adjust tier weights by currently encountered events (pity system that lowers odds of multiple common/uncommons)
|
// Adjust tier weights by currently encountered events (pity system that lowers odds of multiple Common/Great)
|
||||||
tierWeights[0] = tierWeights[0] - 6 * numEncounters[0];
|
tierWeights[0] = tierWeights[0] - 6 * numEncounters[0];
|
||||||
tierWeights[1] = tierWeights[1] - 4 * numEncounters[1];
|
tierWeights[1] = tierWeights[1] - 4 * numEncounters[1];
|
||||||
|
|
||||||
|
|
|
@ -685,7 +685,6 @@ export class TrainerConfig {
|
||||||
}
|
}
|
||||||
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_");
|
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_");
|
||||||
this.name = i18next.t(`trainerNames:${nameForCall}`);
|
this.name = i18next.t(`trainerNames:${nameForCall}`);
|
||||||
// this.setTitle(title);
|
|
||||||
this.setMoneyMultiplier(2);
|
this.setMoneyMultiplier(2);
|
||||||
this.setBoss();
|
this.setBoss();
|
||||||
this.setStaticParty();
|
this.setStaticParty();
|
||||||
|
|
|
@ -149,7 +149,7 @@ export class Arena {
|
||||||
return this.randomSpecies(waveIndex, level, (attempt || 0) + 1);
|
return this.randomSpecies(waveIndex, level, (attempt || 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newSpeciesId = ret.getWildSpeciesForLevel(level, true, !!isBoss, this.scene.gameMode);
|
const newSpeciesId = ret.getWildSpeciesForLevel(level, true, isBoss ?? isBossSpecies, this.scene.gameMode);
|
||||||
if (newSpeciesId !== ret.speciesId) {
|
if (newSpeciesId !== ret.speciesId) {
|
||||||
console.log("Replaced", Species[ret.speciesId], "with", Species[newSpeciesId]);
|
console.log("Replaced", Species[ret.speciesId], "with", Species[newSpeciesId]);
|
||||||
ret = getPokemonSpecies(newSpeciesId);
|
ret = getPokemonSpecies(newSpeciesId);
|
||||||
|
|
|
@ -335,7 +335,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
isAllowed(): boolean {
|
isAllowed(): boolean {
|
||||||
const challengeAllowed = new Utils.BooleanHolder(true);
|
const challengeAllowed = new Utils.BooleanHolder(true);
|
||||||
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed);
|
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed);
|
||||||
return !this.isFainted() && !this.wildFlee && challengeAllowed.value;
|
return !this.wildFlee && challengeAllowed.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive(onField?: boolean): boolean {
|
isActive(onField?: boolean): boolean {
|
||||||
|
|
|
@ -346,6 +346,6 @@ export function getGameMode(gameMode: GameModes): GameMode {
|
||||||
case GameModes.DAILY:
|
case GameModes.DAILY:
|
||||||
return new GameMode(GameModes.DAILY, { isDaily: true, hasTrainers: true, hasNoShop: true });
|
return new GameMode(GameModes.DAILY, { isDaily: true, hasTrainers: true, hasNoShop: true });
|
||||||
case GameModes.CHALLENGE:
|
case GameModes.CHALLENGE:
|
||||||
return new GameMode(GameModes.CHALLENGE, { isClassic: true, hasTrainers: true, isChallenge: true, hasMysteryEncounters: true }, classicFixedBattles);
|
return new GameMode(GameModes.CHALLENGE, { isClassic: true, hasTrainers: true, isChallenge: true }, classicFixedBattles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,8 +136,6 @@ export class ModifierType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to COMMON tier if no tier found
|
|
||||||
this.tier = ModifierTier.COMMON;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,7 @@ export class VictoryPhase extends PokemonPhase {
|
||||||
|
|
||||||
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||||
handleMysteryEncounterVictory(this.scene, false, this.isExpOnly);
|
handleMysteryEncounterVictory(this.scene, false, this.isExpOnly);
|
||||||
this.end();
|
return this.end();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) {
|
if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ export function encrypt(data: string, bypassLogin: boolean): string {
|
||||||
|
|
||||||
export function decrypt(data: string, bypassLogin: boolean): string {
|
export function decrypt(data: string, bypassLogin: boolean): string {
|
||||||
return (bypassLogin
|
return (bypassLogin
|
||||||
? (data: string) => decodeURIComponent(atob(data))
|
? (data: string) => atob(data)
|
||||||
: (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))(data);
|
: (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue