Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ImperialSympathizer committed Aug 8, 2024
1 parent ba637e8 commit de928e5
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ export default class BattleScene extends SceneBase {
const previousEncounter = this.mysteryEncounterData.encounteredEvents?.length > 0 ? this.mysteryEncounterData.encounteredEvents[this.mysteryEncounterData.encounteredEvents.length - 1][0] : null;
const biomeMysteryEncounters = mysteryEncountersByBiome.get(this.arena.biomeType) ?? [];
// If no valid encounters exist at tier, checks next tier down, continuing until there are some encounters available
while (availableEncounters.length === 0 && tier >= 0) {
while (availableEncounters.length === 0 && tier !== null) {
availableEncounters = biomeMysteryEncounters
.filter((encounterType) => {
const encounterCandidate = allMysteryEncounters[encounterType];
Expand All @@ -2784,7 +2784,16 @@ export default class BattleScene extends SceneBase {
return true;
})
.map((m) => (allMysteryEncounters[m]));
tier--;
// Decrement tier
if (tier === MysteryEncounterTier.ROGUE) {
tier = MysteryEncounterTier.ULTRA;
} else if (tier === MysteryEncounterTier.ULTRA) {
tier = MysteryEncounterTier.GREAT;
} else if (tier === MysteryEncounterTier.GREAT) {
tier = MysteryEncounterTier.COMMON;
} else {
tier = null; // Ends loop
}
}

// If absolutely no encounters are available, spawn 0th encounter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
});

it("should not spawn outside of proper biomes", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
game.override.startingBiome(Biome.VOLCANO);
await game.runToMysteryEncounter();

Expand All @@ -96,6 +97,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
});

it("should spawn if player has enough berries", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
game.override.starterHeldItems([{name: "BERRY", count: 2, type: BerryType.SITRUS}, {name: "BERRY", count: 3, type: BerryType.GANLON}]);

await game.runToMysteryEncounter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
});

it("should not spawn outside of HUMAN_TRANSITABLE_BIOMES", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
game.override.startingBiome(Biome.VOLCANO);
await game.runToMysteryEncounter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
});

it("should not spawn outside of CIVILIZATION_ENCOUNTER_BIOMES", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.COMMON);
game.override.startingBiome(Biome.VOLCANO);
await game.runToMysteryEncounter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe("Lost at Sea - Mystery Encounter", () => {
});

it("should not spawn outside of sea biome", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.COMMON);
game.override.startingBiome(Biome.MOUNTAIN);
await game.runToMysteryEncounter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
});

it("should not spawn outside of HUMAN_TRANSITABLE_BIOMES", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
game.override.startingBiome(Biome.VOLCANO);
await game.runToMysteryEncounter();

Expand All @@ -86,7 +87,6 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
});

it("should not run above wave 179", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
game.override.startingWave(181);

await game.runToMysteryEncounter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
});

it("should not spawn outside of HUMAN_TRANSITABLE_BIOMES", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.ULTRA);
game.override.startingBiome(Biome.VOLCANO);
await game.runToMysteryEncounter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe("The Strong Stuff - Mystery Encounter", () => {
});

it("should not spawn outside of CAVE biome", async () => {
game.override.mysteryEncounterTier(MysteryEncounterTier.COMMON);
game.override.startingBiome(Biome.MOUNTAIN);
await game.runToMysteryEncounter();

Expand Down

0 comments on commit de928e5

Please sign in to comment.