bug fixes, cleanup, and tests
This commit is contained in:
parent
69f574b908
commit
666ec135ba
|
@ -1098,7 +1098,7 @@ export default class BattleScene extends SceneBase {
|
||||||
|
|
||||||
// Check for mystery encounter
|
// Check for mystery encounter
|
||||||
// Can only occur in place of a standard wild battle, waves 10-180
|
// Can only occur in place of a standard wild battle, waves 10-180
|
||||||
if (this.gameMode.hasMysteryEncounters && newBattleType === BattleType.WILD && !this.gameMode.isBoss(newWaveIndex) && !(this.gameMode.isClassic && (newWaveIndex > 180 || newWaveIndex < 10))) {
|
if (this.gameMode.hasMysteryEncounters && newBattleType === BattleType.WILD && !this.gameMode.isBoss(newWaveIndex) && newWaveIndex < 180 && newWaveIndex > 10) {
|
||||||
const roll = Utils.randSeedInt(256);
|
const roll = Utils.randSeedInt(256);
|
||||||
|
|
||||||
// Base spawn weight is 3/256, and increases by 1/256 for each missed attempt at spawning an encounter on a valid floor
|
// Base spawn weight is 3/256, and increases by 1/256 for each missed attempt at spawning an encounter on a valid floor
|
||||||
|
@ -1111,7 +1111,7 @@ export default class BattleScene extends SceneBase {
|
||||||
const currentRunDiffFromAvg = expectedEncountersByFloor - (this.mysteryEncounterFlags?.encounteredEvents?.length || 0);
|
const currentRunDiffFromAvg = expectedEncountersByFloor - (this.mysteryEncounterFlags?.encounteredEvents?.length || 0);
|
||||||
const favoredEncounterRate = sessionEncounterRate + currentRunDiffFromAvg * 5;
|
const favoredEncounterRate = sessionEncounterRate + currentRunDiffFromAvg * 5;
|
||||||
|
|
||||||
const successRate = Utils.isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE) ? favoredEncounterRate : Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE;
|
const successRate = isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE) ? favoredEncounterRate : Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE;
|
||||||
|
|
||||||
if (roll < successRate) {
|
if (roll < successRate) {
|
||||||
newBattleType = BattleType.MYSTERY_ENCOUNTER;
|
newBattleType = BattleType.MYSTERY_ENCOUNTER;
|
||||||
|
@ -2639,7 +2639,7 @@ export default class BattleScene extends SceneBase {
|
||||||
getMysteryEncounter(override: MysteryEncounter): MysteryEncounter {
|
getMysteryEncounter(override: MysteryEncounter): MysteryEncounter {
|
||||||
// Loading override or session encounter
|
// Loading override or session encounter
|
||||||
let encounter: MysteryEncounter;
|
let encounter: MysteryEncounter;
|
||||||
if (!Utils.isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_OVERRIDE) && allMysteryEncounters.hasOwnProperty(Overrides.MYSTERY_ENCOUNTER_OVERRIDE)) {
|
if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_OVERRIDE) && allMysteryEncounters.hasOwnProperty(Overrides.MYSTERY_ENCOUNTER_OVERRIDE)) {
|
||||||
encounter = allMysteryEncounters[Overrides.MYSTERY_ENCOUNTER_OVERRIDE];
|
encounter = allMysteryEncounters[Overrides.MYSTERY_ENCOUNTER_OVERRIDE];
|
||||||
} else {
|
} else {
|
||||||
encounter = override?.encounterType >= 0 ? allMysteryEncounters[override?.encounterType] : null;
|
encounter = override?.encounterType >= 0 ? allMysteryEncounters[override?.encounterType] : null;
|
||||||
|
@ -2685,7 +2685,7 @@ export default class BattleScene extends SceneBase {
|
||||||
const rareThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2];
|
const rareThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2];
|
||||||
let tier = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > uncommonThreshold ? MysteryEncounterTier.UNCOMMON : tierValue > rareThreshold ? MysteryEncounterTier.RARE : MysteryEncounterTier.SUPER_RARE;
|
let tier = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > uncommonThreshold ? MysteryEncounterTier.UNCOMMON : tierValue > rareThreshold ? MysteryEncounterTier.RARE : MysteryEncounterTier.SUPER_RARE;
|
||||||
|
|
||||||
if (!Utils.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as Utils from "../utils";
|
|
||||||
import {MysteryEncounterTier} from "#app/data/mystery-encounter";
|
import {MysteryEncounterTier} from "#app/data/mystery-encounter";
|
||||||
import {MysteryEncounterType} from "#enums/mystery-encounter-type";
|
import {MysteryEncounterType} from "#enums/mystery-encounter-type";
|
||||||
import {BASE_MYSTYERY_ENCOUNTER_WEIGHT} from "#app/data/mystery-encounters/mystery-encounters";
|
import {BASE_MYSTYERY_ENCOUNTER_WEIGHT} from "#app/data/mystery-encounters/mystery-encounters";
|
||||||
|
import {isNullOrUndefined} from "../utils";
|
||||||
|
|
||||||
export class MysteryEncounterFlags {
|
export class MysteryEncounterFlags {
|
||||||
encounteredEvents: [MysteryEncounterType, MysteryEncounterTier][] = [];
|
encounteredEvents: [MysteryEncounterType, MysteryEncounterTier][] = [];
|
||||||
|
@ -9,7 +9,7 @@ export class MysteryEncounterFlags {
|
||||||
nextEncounterQueue: [MysteryEncounterType, integer][] = [];
|
nextEncounterQueue: [MysteryEncounterType, integer][] = [];
|
||||||
|
|
||||||
constructor(flags: MysteryEncounterFlags) {
|
constructor(flags: MysteryEncounterFlags) {
|
||||||
if (!Utils.isNullOrUndefined(flags)) {
|
if (!isNullOrUndefined(flags)) {
|
||||||
Object.assign(this, flags);
|
Object.assign(this, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ export default interface MysteryEncounter {
|
||||||
*/
|
*/
|
||||||
export default class MysteryEncounter implements MysteryEncounter {
|
export default class MysteryEncounter implements MysteryEncounter {
|
||||||
constructor(encounter: MysteryEncounter) {
|
constructor(encounter: MysteryEncounter) {
|
||||||
if (!Utils.isNullOrUndefined(encounter)) {
|
if (!isNullOrUndefined(encounter)) {
|
||||||
Object.assign(this, encounter);
|
Object.assign(this, encounter);
|
||||||
}
|
}
|
||||||
this.encounterTier = this.encounterTier ? this.encounterTier : MysteryEncounterTier.COMMON;
|
this.encounterTier = this.encounterTier ? this.encounterTier : MysteryEncounterTier.COMMON;
|
||||||
|
|
|
@ -186,21 +186,19 @@ export function getRandomSpeciesByStarterTier(starterTiers: number | [number, nu
|
||||||
let min = starterTiers instanceof Array ? starterTiers[0] : starterTiers;
|
let min = starterTiers instanceof Array ? starterTiers[0] : starterTiers;
|
||||||
let max = starterTiers instanceof Array ? starterTiers[1] : starterTiers;
|
let max = starterTiers instanceof Array ? starterTiers[1] : starterTiers;
|
||||||
|
|
||||||
let filteredSpecies = Object.entries(speciesStarters)
|
let filteredSpecies: [PokemonSpecies, number][] = Object.keys(speciesStarters)
|
||||||
.map(s => parseInt(s[0]))
|
.map(s => [parseInt(s) as Species, speciesStarters[s] as number])
|
||||||
.filter(s => getPokemonSpecies(s) && !excludedSpecies.includes(s));
|
.filter(s => getPokemonSpecies(s[0]) && !excludedSpecies.includes(s[0]))
|
||||||
|
.map(s => [getPokemonSpecies(s[0]), s[1]]);
|
||||||
|
|
||||||
if (!isNullOrUndefined(types) && types.length > 0) {
|
if (!isNullOrUndefined(types) && types.length > 0) {
|
||||||
filteredSpecies = filteredSpecies.filter(s => {
|
filteredSpecies = filteredSpecies.filter(s => types.includes(s[0].type1) || types.includes(s[0].type2));
|
||||||
const species = getPokemonSpecies(s);
|
|
||||||
return types.includes(species.type1) || types.includes(species.type2);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no filtered mons exist at specified starter tiers, will expand starter search range until there are
|
// If no filtered mons exist at specified starter tiers, will expand starter search range until there are
|
||||||
// Starts by decrementing starter tier min until it is 0, then increments tier max up to 10
|
// Starts by decrementing starter tier min until it is 0, then increments tier max up to 10
|
||||||
let tryFilterStarterTiers = filteredSpecies.filter(s => s[1] >= min && s[1] <= max);
|
let tryFilterStarterTiers: [PokemonSpecies, number][] = filteredSpecies.filter(s => (s[1] >= min && s[1] <= max));
|
||||||
while (tryFilterStarterTiers.length === 0 || !(min === 0 && max === 10)) {
|
while (tryFilterStarterTiers.length === 0 && (min !== 0 && max !== 10)) {
|
||||||
if (min > 0) {
|
if (min > 0) {
|
||||||
min--;
|
min--;
|
||||||
} else {
|
} else {
|
||||||
|
@ -212,7 +210,7 @@ export function getRandomSpeciesByStarterTier(starterTiers: number | [number, nu
|
||||||
|
|
||||||
if (tryFilterStarterTiers.length > 0) {
|
if (tryFilterStarterTiers.length > 0) {
|
||||||
const index = Utils.randSeedInt(tryFilterStarterTiers.length);
|
const index = Utils.randSeedInt(tryFilterStarterTiers.length);
|
||||||
return Phaser.Math.RND.shuffle(tryFilterStarterTiers)[index];
|
return Phaser.Math.RND.shuffle(tryFilterStarterTiers)[index][0].speciesId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Species.BULBASAUR;
|
return Species.BULBASAUR;
|
||||||
|
@ -427,7 +425,7 @@ export function setCustomEncounterRewards(scene: BattleScene, customShopRewards?
|
||||||
scene.unshiftPhase(new ModifierRewardPhase(scene, reward));
|
scene.unshiftPhase(new ModifierRewardPhase(scene, reward));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
while (!Utils.isNullOrUndefined(scene.findPhase(p => p instanceof ModifierRewardPhase))) {
|
while (!isNullOrUndefined(scene.findPhase(p => p instanceof ModifierRewardPhase))) {
|
||||||
scene.tryRemovePhase(p => p instanceof ModifierRewardPhase);
|
scene.tryRemovePhase(p => p instanceof ModifierRewardPhase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +472,6 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
||||||
}).concat({
|
}).concat({
|
||||||
label: i18next.t("menu:cancel"),
|
label: i18next.t("menu:cancel"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
scene.ui.clearText();
|
|
||||||
scene.ui.setMode(Mode.MYSTERY_ENCOUNTER);
|
scene.ui.setMode(Mode.MYSTERY_ENCOUNTER);
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -118,9 +118,9 @@ export const EGG_GACHA_PULL_COUNT_OVERRIDE: number = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 1 to 256, set to null to ignore
|
// 1 to 256, set to null to ignore
|
||||||
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = 256;
|
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = null;
|
||||||
export const MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier = null;
|
export const MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier = null;
|
||||||
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = MysteryEncounterType.FIGHT_OR_FLIGHT;
|
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MODIFIER / ITEM OVERRIDES
|
* MODIFIER / ITEM OVERRIDES
|
||||||
|
|
|
@ -35,7 +35,6 @@ export class MysteryEncounterPhase extends Phase {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
// Clears out queued phases that are part of standard battle
|
// Clears out queued phases that are part of standard battle
|
||||||
this.scene.ui.clearText();
|
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.clearPhaseQueueSplice();
|
this.scene.clearPhaseQueueSplice();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { Button } from "#app/enums/buttons";
|
||||||
import * as overrides from "#app/overrides";
|
import * as overrides from "#app/overrides";
|
||||||
import {
|
import {
|
||||||
BattleEndPhase,
|
BattleEndPhase,
|
||||||
SelectModifierPhase
|
|
||||||
} from "#app/phases";
|
} from "#app/phases";
|
||||||
import GameManager from "#app/test/utils/gameManager";
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
||||||
|
@ -15,6 +14,7 @@ import Phaser from "phaser";
|
||||||
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { getMovePosition } from "../utils/gameManagerUtils";
|
import { getMovePosition } from "../utils/gameManagerUtils";
|
||||||
|
import {SelectModifierPhase} from "#app/phases/select-modifier-phase";
|
||||||
|
|
||||||
|
|
||||||
describe("UI - Transfer Items", () => {
|
describe("UI - Transfer Items", () => {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { PartyUiMode } from "./party-ui-handler";
|
||||||
import MysteryEncounterOption from "../data/mystery-encounter-option";
|
import MysteryEncounterOption from "../data/mystery-encounter-option";
|
||||||
import * as Utils from "../utils";
|
import * as Utils from "../utils";
|
||||||
import { getPokeballAtlasKey } from "../data/pokeball";
|
import { getPokeballAtlasKey } from "../data/pokeball";
|
||||||
|
import {isNullOrUndefined} from "../utils";
|
||||||
|
|
||||||
export default class MysteryEncounterUiHandler extends UiHandler {
|
export default class MysteryEncounterUiHandler extends UiHandler {
|
||||||
private cursorContainer: Phaser.GameObjects.Container;
|
private cursorContainer: Phaser.GameObjects.Container;
|
||||||
|
@ -294,6 +295,7 @@ export default class MysteryEncounterUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
displayEncounterOptions(slideInDescription: boolean = true): void {
|
displayEncounterOptions(slideInDescription: boolean = true): void {
|
||||||
|
this.getUi().clearText();
|
||||||
const mysteryEncounter = this.scene.currentBattle.mysteryEncounter;
|
const mysteryEncounter = this.scene.currentBattle.mysteryEncounter;
|
||||||
this.filteredEncounterOptions = mysteryEncounter.options;
|
this.filteredEncounterOptions = mysteryEncounter.options;
|
||||||
this.optionsMeetsReqs = [];
|
this.optionsMeetsReqs = [];
|
||||||
|
@ -405,7 +407,7 @@ export default class MysteryEncounterUiHandler extends UiHandler {
|
||||||
}
|
}
|
||||||
this.tooltipContainer.setVisible(true);
|
this.tooltipContainer.setVisible(true);
|
||||||
|
|
||||||
if (Utils.isNullOrUndefined(cursor) || cursor > this.optionsContainer.length - 2) {
|
if (isNullOrUndefined(cursor) || cursor > this.optionsContainer.length - 2) {
|
||||||
// Ignore hovers on view party button
|
// Ignore hovers on view party button
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { CommandPhase, SelectModifierPhase } from "../phases";
|
import { CommandPhase } from "../phases";
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene from "../battle-scene";
|
||||||
import { PlayerPokemon, PokemonMove } from "../field/pokemon";
|
import { PlayerPokemon, PokemonMove } from "../field/pokemon";
|
||||||
import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "./text";
|
import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "./text";
|
||||||
|
|
Loading…
Reference in New Issue