Compare commits

...

8 Commits

Author SHA1 Message Date
Tempoanon
6a58d1b928
[Misc] Update pull request template (#3360) 2024-08-05 12:02:53 -04:00
NightKev
0a77dcdb4f
[Bug] Sand Spit should only activate when hit with a damaging move (#3337)
* Sand Spit should only activate when hit with a damaging move

* Add tests for Sand Spit
2024-08-05 11:51:36 -04:00
Leo Kim
d323817eb9
[Enhancement] add filters for pokerus, HA, cost reduction (#3343)
* add filters for pokerus, HA, cost reduction

* add entries for translation

* Update src/ui/starter-select-ui-handler.ts

Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com>

* Update src/ui/starter-select-ui-handler.ts

Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com>

---------

Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com>
2024-08-05 11:43:47 -04:00
Leo Kim
91b32132d0
[Bug,Enhancement] Fix and improve Starter selector UI (#3340)
* apply offset to all hybrid filter

* make dropDownType to public for offsetHybridFilter function

* refactoring defaultSettings to additional suport default cursor.

* fix to remember last cursor on hover mode

* remove unnecessary reset code

* fix sort reset function

* update resetFilter function

* update requested changes

* remove log msg

* fix checking default on sort

* refactoring hasDefaultValues function for readability

* fix lastdir bug
2024-08-05 11:42:15 -04:00
flx-sta
97e362368c
[GH] Replace Feature request template with form (#3126)
* replace feature_request.md with feature_request.yml (form)

* fix typo and formatting in feature_request.yml
2024-08-05 11:41:38 -04:00
NightKev
063e6dbd2d
[Bug] Player pokemon shouldn't generate an NPC moveset (#3356)
* Player pokemon shouldn't generate an NPC moveset

* Make sure Keldeo starts new runs in the correct form
2024-08-05 10:22:06 -04:00
NightKev
68d3d27d47
[Test] Fix Power Spot test so Stonjourner always moves second (#3357) 2024-08-05 09:47:54 -04:00
NightKev
a301507f80
[Test] Remove held items from all tests when there are no item overrides (#3358) 2024-08-05 09:46:34 -04:00
24 changed files with 334 additions and 136 deletions

View File

@ -1,18 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature]"
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the Feature**
<!-- A clear and concise description of what you want to happen. -->
<!-- Add a link to the feature if it is an existing move/ability/etc -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

View File

@ -0,0 +1,39 @@
name: Feature Request
description: Suggest an idea for this project
title: "[Feature] "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: relation
attributes:
label: Is your feature request related to a problem? Please describe.
description: Clear and concise description of what the problem is.
placeholder: E.g. "I'm always frustrated when [...]"
validations:
required: true
- type: markdown
attributes:
value: |
---
- type: textarea
id: description
attributes:
label: Describe the Feature
description: A clear and concise description of what you want to happen. Add a link to the feature if it is an existing move/ability/etc.
validations:
required: true
- type: markdown
attributes:
value: |
---
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
validations:
required: true

View File

@ -5,12 +5,12 @@
## What are the changes? ## What are the changes?
<!-- Summarize what are the changes from a user perspective on the application --> <!-- Summarize what are the changes from a user perspective on the application -->
## Why am I doing these changes? ## Why am I doing these changes the user will see?
<!-- Explain why you decided to introduce these changes --> <!-- Explain why you decided to introduce these changes -->
<!-- Does it come from an issue or another PR? Please link it --> <!-- Does it come from an issue or another PR? Please link it -->
<!-- Explain why you believe this can enhance user experience --> <!-- Explain why you believe this can enhance user experience -->
## What did change? ## What are the changes from a developer perspective?
<!-- Explicitly state what are the changes introduced by the PR --> <!-- Explicitly state what are the changes introduced by the PR -->
<!-- You can make use of a comparison between what was the state before and after your PR changes --> <!-- You can make use of a comparison between what was the state before and after your PR changes -->
@ -30,6 +30,7 @@
- [ ] The PR is self-contained and cannot be split into smaller PRs? - [ ] The PR is self-contained and cannot be split into smaller PRs?
- [ ] Have I provided a clear explanation of the changes? - [ ] Have I provided a clear explanation of the changes?
- [ ] Have I considered writing automated tests for the issue? - [ ] Have I considered writing automated tests for the issue?
- [ ] If I have text, did I add placeholders for them in locales?
- [ ] Have I tested the changes (manually)? - [ ] Have I tested the changes (manually)?
- [ ] Are all unit tests still passing? (`npm run test`) - [ ] Are all unit tests still passing? (`npm run test`)
- [ ] Are the changes visual? - [ ] Are the changes visual?

View File

@ -941,14 +941,19 @@ export class PostDefendPerishSongAbAttr extends PostDefendAbAttr {
export class PostDefendWeatherChangeAbAttr extends PostDefendAbAttr { export class PostDefendWeatherChangeAbAttr extends PostDefendAbAttr {
private weatherType: WeatherType; private weatherType: WeatherType;
protected condition: PokemonDefendCondition | null;
constructor(weatherType: WeatherType) { constructor(weatherType: WeatherType, condition?: PokemonDefendCondition) {
super(); super();
this.weatherType = weatherType; this.weatherType = weatherType;
this.condition = condition ?? null;
} }
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean {
if (this.condition !== null && !this.condition(pokemon, attacker, move)) {
return false;
}
if (!pokemon.scene.arena.weather?.isImmutable()) { if (!pokemon.scene.arena.weather?.isImmutable()) {
return pokemon.scene.arena.trySetWeather(this.weatherType, true); return pokemon.scene.arena.trySetWeather(this.weatherType, true);
} }
@ -5092,7 +5097,7 @@ export function initAbilities() {
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.hasFlag(MoveFlags.SOUND_BASED), 0.5) .attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.hasFlag(MoveFlags.SOUND_BASED), 0.5)
.ignorable(), .ignorable(),
new Ability(Abilities.SAND_SPIT, 8) new Ability(Abilities.SAND_SPIT, 8)
.attr(PostDefendWeatherChangeAbAttr, WeatherType.SANDSTORM), .attr(PostDefendWeatherChangeAbAttr, WeatherType.SANDSTORM, (target, user, move) => move.category !== MoveCategory.STATUS),
new Ability(Abilities.ICE_SCALES, 8) new Ability(Abilities.ICE_SCALES, 8)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.category === MoveCategory.SPECIAL, 0.5) .attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.category === MoveCategory.SPECIAL, 0.5)
.ignorable(), .ignorable(),

View File

@ -3222,7 +3222,7 @@ export class PlayerPokemon extends Pokemon {
} }
if (!dataSource) { if (!dataSource) {
this.generateAndPopulateMoveset(); this.moveset = [];
} }
this.generateCompatibleTms(); this.generateCompatibleTms();
} }

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passive", "passive": "Passive",
"passiveUnlocked": "Passive freigeschaltet", "passiveUnlocked": "Passive freigeschaltet",
"passiveLocked": "Passive gesperrt", "passiveLocked": "Passive gesperrt",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Band", "ribbon": "Band",
"hasWon": "Hat Klassik-Modus gewonnen", "hasWon": "Hat Klassik-Modus gewonnen",
"hasNotWon": "Hat Klassik-Modus nicht gewonnen", "hasNotWon": "Hat Klassik-Modus nicht gewonnen",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "Pokédex-Nummer", "sortByNumber": "Pokédex-Nummer",
"sortByCost": "Kosten", "sortByCost": "Kosten",
"sortByCandies": "Anzahl Bonbons", "sortByCandies": "Anzahl Bonbons",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passive", "passive": "Passive",
"passiveUnlocked": "Passive Unlocked", "passiveUnlocked": "Passive Unlocked",
"passiveLocked": "Passive Locked", "passiveLocked": "Passive Locked",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Ribbon", "ribbon": "Ribbon",
"hasWon": "Ribbon - Yes", "hasWon": "Ribbon - Yes",
"hasNotWon": "Ribbon - No", "hasNotWon": "Ribbon - No",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "No.", "sortByNumber": "No.",
"sortByCost": "Cost", "sortByCost": "Cost",
"sortByCandies": "Candy Count", "sortByCandies": "Candy Count",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passive", "passive": "Passive",
"passiveUnlocked": "Pasiva Desbloq.", "passiveUnlocked": "Pasiva Desbloq.",
"passiveLocked": "Pasiva Bloq.", "passiveLocked": "Pasiva Bloq.",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Ribbon", "ribbon": "Ribbon",
"hasWon": "Ya ha ganado", "hasWon": "Ya ha ganado",
"hasNotWon": "Aún no ha ganado", "hasNotWon": "Aún no ha ganado",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "Núm.", "sortByNumber": "Núm.",
"sortByCost": "Coste", "sortByCost": "Coste",
"sortByCandies": "# Caramelos", "sortByCandies": "# Caramelos",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passif", "passive": "Passif",
"passiveUnlocked": "Passif débloqué", "passiveUnlocked": "Passif débloqué",
"passiveLocked": "Passif verrouillé", "passiveLocked": "Passif verrouillé",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Ruban", "ribbon": "Ruban",
"hasWon": "Ruban - Oui", "hasWon": "Ruban - Oui",
"hasNotWon": "Ruban - Non", "hasNotWon": "Ruban - Non",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "Par N°", "sortByNumber": "Par N°",
"sortByCost": "Par cout", "sortByCost": "Par cout",
"sortByCandies": "Par bonbons", "sortByCandies": "Par bonbons",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passive", "passive": "Passive",
"passiveUnlocked": "Passiva sbloccata", "passiveUnlocked": "Passiva sbloccata",
"passiveLocked": "Passiva bloccata", "passiveLocked": "Passiva bloccata",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Ribbon", "ribbon": "Ribbon",
"hasWon": "Ribbon - Yes", "hasWon": "Ribbon - Yes",
"hasNotWon": "Ribbon - No", "hasNotWon": "Ribbon - No",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "Num. Dex", "sortByNumber": "Num. Dex",
"sortByCost": "Costo", "sortByCost": "Costo",
"sortByCandies": "Caramelle", "sortByCandies": "Caramelle",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "패시브", "passive": "패시브",
"passiveUnlocked": "패시브 해금", "passiveUnlocked": "패시브 해금",
"passiveLocked": "패시브 잠김", "passiveLocked": "패시브 잠김",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "클리어 여부", "ribbon": "클리어 여부",
"hasWon": "클리어 함", "hasWon": "클리어 함",
"hasNotwon": "클리어 안함", "hasNotwon": "클리어 안함",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "도감번호", "sortByNumber": "도감번호",
"sortByCost": "코스트", "sortByCost": "코스트",
"sortByCandies": "사탕 수", "sortByCandies": "사탕 수",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "Passiva", "passive": "Passiva",
"passiveUnlocked": "Passiva Desbloq.", "passiveUnlocked": "Passiva Desbloq.",
"passiveLocked": "Passiva Bloq.", "passiveLocked": "Passiva Bloq.",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "Fita", "ribbon": "Fita",
"hasWon": "Fita - Sim", "hasWon": "Fita - Sim",
"hasNotWon": "Fita - Não", "hasNotWon": "Fita - Não",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "Número", "sortByNumber": "Número",
"sortByCost": "Custo", "sortByCost": "Custo",
"sortByCandies": "# Doces", "sortByCandies": "# Doces",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "被动", "passive": "被动",
"passiveUnlocked": "被动解锁", "passiveUnlocked": "被动解锁",
"passiveLocked": "被动未解锁", "passiveLocked": "被动未解锁",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "缎带", "ribbon": "缎带",
"hasWon": "有缎带", "hasWon": "有缎带",
"hasNotWon": "无缎带", "hasNotWon": "无缎带",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "编号", "sortByNumber": "编号",
"sortByCost": "费用", "sortByCost": "费用",
"sortByCandies": "糖果", "sortByCandies": "糖果",

View File

@ -13,9 +13,18 @@ export const filterBar: SimpleTranslationEntries = {
"passive": "被動", "passive": "被動",
"passiveUnlocked": "被動解鎖", "passiveUnlocked": "被動解鎖",
"passiveLocked": "被動未解鎖", "passiveLocked": "被動未解鎖",
"costReduction": "Cost Reduction",
"costReductionUnlocked": "Cost Reduction Unlocked",
"costReductionLocked": "Cost Reduction Locked",
"ribbon": "緞帶", "ribbon": "緞帶",
"hasWon": "有緞帶", "hasWon": "有緞帶",
"hasNotWon": "無緞帶", "hasNotWon": "無緞帶",
"hiddenAbility": "Hidden Ability",
"hasHiddenAbility": "Hidden Ability - Yes",
"noHiddenAbility": "Hidden Ability - No",
"pokerus": "Pokerus",
"hasPokerus": "Pokerus - Yes",
"noPokerus": "Pokerus - No",
"sortByNumber": "編號", "sortByNumber": "編號",
"sortByCost": "花費", "sortByCost": "花費",
"sortByCandies": "糖果", "sortByCandies": "糖果",

View File

@ -642,6 +642,10 @@ export class SelectStarterPhase extends Phase {
this.scene.arena.init(); this.scene.arena.init();
this.scene.sessionPlayTime = 0; this.scene.sessionPlayTime = 0;
this.scene.lastSavePlayTime = 0; this.scene.lastSavePlayTime = 0;
// Ensures Keldeo (or any future Pokemon that have this type of form change) starts in the correct form
this.scene.getParty().forEach((p: PlayerPokemon) => {
this.scene.triggerPokemonFormChange(p, SpeciesFormChangeMoveLearnedTrigger);
});
this.end(); this.end();
}); });
} }

View File

@ -8,15 +8,10 @@ import { generateStarter, getMovePosition } from "#app/test/utils/gameManagerUti
import { Command } from "#app/ui/command-ui-handler"; import { Command } from "#app/ui/command-ui-handler";
import { Status, StatusEffect } from "#app/data/status-effect"; import { Status, StatusEffect } from "#app/data/status-effect";
import { GameModes, getGameMode } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import { import { CommandPhase, DamagePhase, EncounterPhase, EnemyCommandPhase, SelectStarterPhase, TurnInitPhase } from "#app/phases";
CommandPhase, DamagePhase, EncounterPhase,
EnemyCommandPhase, SelectStarterPhase,
TurnInitPhase,
} from "#app/phases";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { removeEnemyHeldItems } from "../utils/testUtils";
describe("Abilities - Intimidate", () => { describe("Abilities - Intimidate", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -45,7 +40,6 @@ describe("Abilities - Intimidate", () => {
it("single - wild with switch", async () => { it("single - wild with switch", async () => {
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -76,7 +70,6 @@ describe("Abilities - Intimidate", () => {
it("single - boss should only trigger once then switch", async () => { it("single - boss should only trigger once then switch", async () => {
game.override.startingWave(10); game.override.startingWave(10);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -106,7 +99,6 @@ describe("Abilities - Intimidate", () => {
it("single - trainer should only trigger once with switch", async () => { it("single - trainer should only trigger once with switch", async () => {
game.override.startingWave(5); game.override.startingWave(5);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -137,7 +129,6 @@ describe("Abilities - Intimidate", () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.startingWave(5); game.override.startingWave(5);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -164,7 +155,6 @@ describe("Abilities - Intimidate", () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.startingWave(3); game.override.startingWave(3);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -191,7 +181,6 @@ describe("Abilities - Intimidate", () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.startingWave(10); game.override.startingWave(10);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -218,7 +207,6 @@ describe("Abilities - Intimidate", () => {
game.override.startingWave(2); game.override.startingWave(2);
game.override.moveset([Moves.AERIAL_ACE]); game.override.moveset([Moves.AERIAL_ACE]);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -245,7 +233,6 @@ describe("Abilities - Intimidate", () => {
game.override.startingWave(2); game.override.startingWave(2);
game.override.moveset([Moves.SPLASH]); game.override.moveset([Moves.SPLASH]);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -271,7 +258,6 @@ describe("Abilities - Intimidate", () => {
game.override.enemyMoveset([Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH]); game.override.enemyMoveset([Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH]);
game.override.startingWave(5); game.override.startingWave(5);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -311,7 +297,6 @@ describe("Abilities - Intimidate", () => {
game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
game.override.startingWave(5); game.override.startingWave(5);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -351,7 +336,6 @@ describe("Abilities - Intimidate", () => {
game.override.startingWave(3); game.override.startingWave(3);
vi.spyOn(Overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{ name: "COIN_CASE" }]); vi.spyOn(Overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{ name: "COIN_CASE" }]);
await game.runToSummon([Species.MIGHTYENA]); await game.runToSummon([Species.MIGHTYENA]);
removeEnemyHeldItems(game.scene);
await game.phaseInterceptor.to(CommandPhase, false); await game.phaseInterceptor.to(CommandPhase, false);
const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
@ -378,7 +362,6 @@ describe("Abilities - Intimidate", () => {
}); });
await game.phaseInterceptor.run(EncounterPhase); await game.phaseInterceptor.run(EncounterPhase);
removeEnemyHeldItems(game.scene);
await game.phaseInterceptor.to(CommandPhase, false); await game.phaseInterceptor.to(CommandPhase, false);
const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;

View File

@ -40,7 +40,7 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.PIKACHU, Species.STONJOURNER]); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -54,7 +54,7 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.PIKACHU, Species.STONJOURNER]); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]);
game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -68,7 +68,7 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.STONJOURNER, Species.PIKACHU]); await game.startBattle([Species.STONJOURNER, Species.REGIELEKI]);
game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

View File

@ -0,0 +1,57 @@
import GameManager from "#app/test/utils/gameManager";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { getMovePosition } from "../utils/gameManagerUtils";
import { WeatherType } from "#app/enums/weather-type.js";
describe("Ability Timing", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single");
game.override.disableCrits();
game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyAbility(Abilities.BALL_FETCH);
game.override.starterSpecies(Species.SILICOBRA);
game.override.ability(Abilities.SAND_SPIT);
game.override.moveset([Moves.SPLASH, Moves.COIL]);
});
it("should trigger when hit with damaging move", async() => {
game.override.enemyMoveset(Array(4).fill(Moves.TACKLE));
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.toNextTurn();
expect(game.scene.arena.weather.weatherType).toBe(WeatherType.SANDSTORM);
}, 20000);
it("should not trigger when targetted with status moves", async() => {
game.override.enemyMoveset(Array(4).fill(Moves.GROWL));
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.COIL));
await game.toNextTurn();
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SANDSTORM);
}, 20000);
});

View File

@ -8,7 +8,7 @@ import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { removeEnemyHeldItems, SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
describe("Moves - Octolock", () => { describe("Moves - Octolock", () => {
describe("integration tests", () => { describe("integration tests", () => {
@ -41,7 +41,6 @@ describe("Moves - Octolock", () => {
it("Reduces DEf and SPDEF by 1 each turn", { timeout: 10000 }, async () => { it("Reduces DEf and SPDEF by 1 each turn", { timeout: 10000 }, async () => {
await game.startBattle([Species.GRAPPLOCT]); await game.startBattle([Species.GRAPPLOCT]);
removeEnemyHeldItems(game.scene);
const enemyPokemon = game.scene.getEnemyField(); const enemyPokemon = game.scene.getEnemyField();
@ -63,7 +62,6 @@ describe("Moves - Octolock", () => {
it("Traps the target pokemon", { timeout: 10000 }, async () => { it("Traps the target pokemon", { timeout: 10000 }, async () => {
await game.startBattle([Species.GRAPPLOCT]); await game.startBattle([Species.GRAPPLOCT]);
removeEnemyHeldItems(game.scene);
const enemyPokemon = game.scene.getEnemyField(); const enemyPokemon = game.scene.getEnemyField();

View File

@ -1,31 +1,21 @@
import GameWrapper from "#app/test/utils/gameWrapper"; import GameWrapper from "#app/test/utils/gameWrapper";
import {Mode} from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import {generateStarter, waitUntil} from "#app/test/utils/gameManagerUtils"; import { generateStarter, waitUntil } from "#app/test/utils/gameManagerUtils";
import { import { CommandPhase, EncounterPhase, FaintPhase, LoginPhase, NewBattlePhase, SelectStarterPhase, SelectTargetPhase, TitlePhase, TurnEndPhase, TurnInitPhase, TurnStartPhase } from "#app/phases";
CommandPhase,
EncounterPhase,
FaintPhase,
LoginPhase,
NewBattlePhase,
SelectStarterPhase,
SelectTargetPhase,
TitlePhase, TurnEndPhase, TurnInitPhase,
TurnStartPhase,
} from "#app/phases";
import BattleScene from "#app/battle-scene.js"; import BattleScene from "#app/battle-scene.js";
import PhaseInterceptor from "#app/test/utils/phaseInterceptor"; import PhaseInterceptor from "#app/test/utils/phaseInterceptor";
import TextInterceptor from "#app/test/utils/TextInterceptor"; import TextInterceptor from "#app/test/utils/TextInterceptor";
import {GameModes, getGameMode} from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import fs from "fs"; import fs from "fs";
import {AES, enc} from "crypto-js"; import { AES, enc } from "crypto-js";
import {updateUserInfo} from "#app/account"; import { updateUserInfo } from "#app/account";
import InputsHandler from "#app/test/utils/inputsHandler"; import InputsHandler from "#app/test/utils/inputsHandler";
import ErrorInterceptor from "#app/test/utils/errorInterceptor"; import ErrorInterceptor from "#app/test/utils/errorInterceptor";
import {EnemyPokemon, PlayerPokemon} from "#app/field/pokemon"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import {MockClock} from "#app/test/utils/mocks/mockClock"; import { MockClock } from "#app/test/utils/mocks/mockClock";
import {Command} from "#app/ui/command-ui-handler"; import { Command } from "#app/ui/command-ui-handler";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import PartyUiHandler, {PartyUiMode} from "#app/ui/party-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler";
import Trainer from "#app/field/trainer"; import Trainer from "#app/field/trainer";
import { ExpNotification } from "#enums/exp-notification"; import { ExpNotification } from "#enums/exp-notification";
import { GameDataType } from "#enums/game-data-type"; import { GameDataType } from "#enums/game-data-type";
@ -36,6 +26,8 @@ import { BattlerIndex } from "#app/battle.js";
import TargetSelectUiHandler from "#app/ui/target-select-ui-handler.js"; import TargetSelectUiHandler from "#app/ui/target-select-ui-handler.js";
import { OverridesHelper } from "./overridesHelper"; import { OverridesHelper } from "./overridesHelper";
import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type.js"; import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type.js";
import overrides from "#app/overrides.js";
import { removeEnemyHeldItems } from "./testUtils";
/** /**
* Class to manage the game state and transitions between phases. * Class to manage the game state and transitions between phases.
@ -140,6 +132,9 @@ export default class GameManager {
}); });
await this.phaseInterceptor.run(EncounterPhase); await this.phaseInterceptor.run(EncounterPhase);
if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0) {
removeEnemyHeldItems(this.scene);
}
} }
/** /**

View File

@ -34,4 +34,5 @@ export function arrayOfRange(start: integer, end: integer) {
export function removeEnemyHeldItems(scene: BattleScene) { export function removeEnemyHeldItems(scene: BattleScene) {
scene.clearEnemyHeldItemModifiers(); scene.clearEnemyHeldItemModifiers();
scene.clearEnemyModifiers(); scene.clearEnemyModifiers();
console.log("Enemy held items removed");
} }

View File

@ -27,10 +27,10 @@ export class DropDownLabel {
public text: string; public text: string;
public sprite?: Phaser.GameObjects.Sprite; public sprite?: Phaser.GameObjects.Sprite;
constructor(label: string, sprite?: Phaser.GameObjects.Sprite, state: DropDownState = DropDownState.ON) { constructor(label: string, sprite?: Phaser.GameObjects.Sprite, state: DropDownState = DropDownState.OFF) {
this.text = label || ""; this.text = label || "";
this.sprite = sprite; this.sprite = sprite;
this.state = state || DropDownState.ON; this.state = state;
} }
} }
@ -262,12 +262,13 @@ export class DropDown extends Phaser.GameObjects.Container {
public options: DropDownOption[]; public options: DropDownOption[];
private window: Phaser.GameObjects.NineSlice; private window: Phaser.GameObjects.NineSlice;
private cursorObj: Phaser.GameObjects.Image; private cursorObj: Phaser.GameObjects.Image;
private dropDownType: DropDownType = DropDownType.MULTI; public dropDownType: DropDownType = DropDownType.MULTI;
public cursor: number = 0; public cursor: number = 0;
private lastCursor: number = -1;
public defaultCursor: number = 0; public defaultCursor: number = 0;
private onChange: () => void; private onChange: () => void;
private lastDir: SortDirection = SortDirection.ASC; private lastDir: SortDirection = SortDirection.ASC;
private defaultValues: any[]; private defaultSettings: any[];
constructor(scene: BattleScene, x: number, y: number, options: DropDownOption[], onChange: () => void, type: DropDownType = DropDownType.MULTI, optionSpacing: number = 2) { constructor(scene: BattleScene, x: number, y: number, options: DropDownOption[], onChange: () => void, type: DropDownType = DropDownType.MULTI, optionSpacing: number = 2) {
const windowPadding = 5; const windowPadding = 5;
@ -292,7 +293,7 @@ export class DropDown extends Phaser.GameObjects.Container {
this.options.unshift(new DropDownOption(scene, "ALL", new DropDownLabel(i18next.t("filterBar:all"), undefined, this.checkForAllOn() ? DropDownState.ON : DropDownState.OFF))); this.options.unshift(new DropDownOption(scene, "ALL", new DropDownLabel(i18next.t("filterBar:all"), undefined, this.checkForAllOn() ? DropDownState.ON : DropDownState.OFF)));
} }
this.defaultValues = this.getVals(); this.defaultSettings = this.getSettings();
// Place ui elements in the correct spot // Place ui elements in the correct spot
options.forEach((option, index) => { options.forEach((option, index) => {
@ -339,8 +340,8 @@ export class DropDown extends Phaser.GameObjects.Container {
resetCursor(): boolean { resetCursor(): boolean {
// If we are an hybrid dropdown in "hover" mode, don't move the cursor back to 0 // If we are an hybrid dropdown in "hover" mode, don't move the cursor back to 0
if (this.dropDownType === DropDownType.HYBRID && this.checkForAllOff() && this.cursor > 0) { if (this.dropDownType === DropDownType.HYBRID && this.checkForAllOff()) {
return false; return this.setCursor(this.lastCursor);
} }
return this.setCursor(this.defaultCursor); return this.setCursor(this.defaultCursor);
} }
@ -361,6 +362,7 @@ export class DropDown extends Phaser.GameObjects.Container {
this.cursorObj.setVisible(true); this.cursorObj.setVisible(true);
// If hydrid type, we need to update the filters when going up/down in the list // If hydrid type, we need to update the filters when going up/down in the list
if (this.dropDownType === DropDownType.HYBRID) { if (this.dropDownType === DropDownType.HYBRID) {
this.lastCursor = cursor;
this.onChange(); this.onChange();
} }
} }
@ -457,23 +459,43 @@ export class DropDown extends Phaser.GameObjects.Container {
} }
} }
/**
* Get the current selected settings dictionary for each option
* @returns an array of dictionaries with the current state of each option
* - the settings dictionary is like this { val: any, state: DropDownState, cursor: boolean, dir: SortDirection }
*/
private getSettings(): any[] {
const settings = [];
for (let i = 0; i < this.options.length; i++) {
settings.push({ val: this.options[i].val, state: this.options[i].state , cursor: (this.cursor === i), dir: this.options[i].dir });
}
return settings;
}
/** /**
* Check whether the values of all options are the same as the default ones * Check whether the values of all options are the same as the default ones
* @returns true if they are the same, false otherwise * @returns true if they are the same, false otherwise
*/ */
public hasDefaultValues(): boolean { public hasDefaultValues(): boolean {
const currentValues = this.getVals(); const currentValues = this.getSettings();
const compareValues = (keys: string[]): boolean => {
return currentValues.length === this.defaultSettings.length &&
currentValues.every((value, index) =>
keys.every(key => value[key] === this.defaultSettings[index][key])
);
};
switch (this.dropDownType) { switch (this.dropDownType) {
case DropDownType.MULTI: case DropDownType.MULTI:
case DropDownType.HYBRID:
return currentValues.length === this.defaultValues.length && currentValues.every((value, index) => value === this.defaultValues[index]);
case DropDownType.RADIAL: case DropDownType.RADIAL:
return currentValues.every((value, index) => value["val"] === this.defaultValues[index]["val"] && value["state"] === this.defaultValues[index]["state"]); return compareValues(["val", "state"]);
case DropDownType.HYBRID:
return compareValues(["val", "state", "cursor"]);
case DropDownType.SINGLE: case DropDownType.SINGLE:
return currentValues[0]["dir"] === this.defaultValues[0]["dir"] && currentValues[0]["val"] === this.defaultValues[0]["val"]; return compareValues(["val", "state", "dir"]);
default: default:
return false; return false;
@ -484,46 +506,29 @@ export class DropDown extends Phaser.GameObjects.Container {
* Set all values to their default state * Set all values to their default state
*/ */
public resetToDefault(): void { public resetToDefault(): void {
this.setCursor(this.defaultCursor); if (this.defaultSettings.length > 0) {
this.setCursor(this.defaultCursor);
this.lastDir = SortDirection.ASC;
for (let i = 0; i < this.options.length; i++) { for (let i = 0; i < this.options.length; i++) {
const option = this.options[i]; // reset values with the defaultValues
// reset values if (this.dropDownType === DropDownType.SINGLE) {
switch (this.dropDownType) { if (this.defaultSettings[i].state === DropDownState.OFF) {
case DropDownType.HYBRID: this.options[i].setOptionState(DropDownState.OFF);
case DropDownType.MULTI: this.options[i].setDirection(SortDirection.ASC);
if (this.defaultValues.includes(option.val)) { this.options[i].toggle.setVisible(false);
option.setOptionState(DropDownState.ON); } else {
this.options[i].setOptionState(DropDownState.ON);
this.options[i].setDirection(SortDirection.ASC);
this.options[i].toggle.setVisible(true);
}
} else { } else {
option.setOptionState(DropDownState.OFF); if (this.defaultSettings[i]) {
} this.options[i].setOptionState(this.defaultSettings[i]["state"]);
break;
case DropDownType.RADIAL:
const targetValue = this.defaultValues.find(value => value.val === option.val);
option.setOptionState(targetValue.state);
break;
case DropDownType.SINGLE:
if (option.val === this.defaultValues[0].val) {
if (option.state !== DropDownState.ON) {
this.toggleOptionState(i);
}
if (option.dir !== this.defaultValues[0].dir) {
this.toggleOptionState(i);
} }
} }
break;
} }
} }
// Select or unselect "ALL" button if applicable
if (this.dropDownType === DropDownType.MULTI || this.dropDownType === DropDownType.HYBRID) {
if (this.checkForAllOn()) {
this.options[0].setOptionState(DropDownState.ON);
} else {
this.options[0].setOptionState(DropDownState.OFF);
}
}
} }
/** /**

View File

@ -1,5 +1,5 @@
import BattleScene from "#app/battle-scene.js"; import BattleScene from "#app/battle-scene.js";
import { DropDown } from "./dropdown"; import { DropDown, DropDownType } from "./dropdown";
import { StarterContainer } from "./starter-container"; import { StarterContainer } from "./starter-container";
import { addTextObject, getTextColor, TextStyle } from "./text"; import { addTextObject, getTextColor, TextStyle } from "./text";
import { UiTheme } from "#enums/ui-theme"; import { UiTheme } from "#enums/ui-theme";
@ -120,11 +120,13 @@ export class FilterBar extends Phaser.GameObjects.Container {
/** /**
* Move the leftmost dropdown to the left of the FilterBar instead of below it * Move the leftmost dropdown to the left of the FilterBar instead of below it
*/ */
offsetFirstFilter(): void { offsetHybridFilters(): void {
if (this.dropDowns[0]) { for (let i=0; i<this.dropDowns.length; i++) {
this.dropDowns[0].autoSize(); if (this.dropDowns[i].dropDownType === DropDownType.HYBRID) {
this.dropDowns[0].x -= this.dropDowns[0].getWidth(); this.dropDowns[i].autoSize();
this.dropDowns[0].y = 0; this.dropDowns[i].x = - this.dropDowns[i].getWidth();
this.dropDowns[i].y = 0;
}
} }
} }

View File

@ -431,8 +431,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
new DropDownLabel(i18next.t("filterBar:passiveUnlocked"), undefined, DropDownState.ON), new DropDownLabel(i18next.t("filterBar:passiveUnlocked"), undefined, DropDownState.ON),
new DropDownLabel(i18next.t("filterBar:passiveLocked"), undefined, DropDownState.EXCLUDE), new DropDownLabel(i18next.t("filterBar:passiveLocked"), undefined, DropDownState.EXCLUDE),
]; ];
const costReductionLabels = [
new DropDownLabel(i18next.t("filterBar:costReduction"), undefined, DropDownState.OFF),
new DropDownLabel(i18next.t("filterBar:costReductionUnlocked"), undefined, DropDownState.ON),
new DropDownLabel(i18next.t("filterBar:costReductionLocked"), undefined, DropDownState.EXCLUDE),
];
const unlocksOptions = [ const unlocksOptions = [
new DropDownOption(this.scene, "PASSIVE", passiveLabels), new DropDownOption(this.scene, "PASSIVE", passiveLabels),
new DropDownOption(this.scene, "COST_REDUCTION", costReductionLabels),
]; ];
this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(this.scene, 0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL)); this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(this.scene, 0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL));
@ -443,18 +451,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
new DropDownLabel(i18next.t("filterBar:hasWon"), undefined, DropDownState.ON), new DropDownLabel(i18next.t("filterBar:hasWon"), undefined, DropDownState.ON),
new DropDownLabel(i18next.t("filterBar:hasNotWon"), undefined, DropDownState.EXCLUDE), new DropDownLabel(i18next.t("filterBar:hasNotWon"), undefined, DropDownState.EXCLUDE),
]; ];
const hiddenAbilityLabels = [
new DropDownLabel(i18next.t("filterBar:hiddenAbility"), undefined, DropDownState.OFF),
new DropDownLabel(i18next.t("filterBar:hasHiddenAbility"), undefined, DropDownState.ON),
new DropDownLabel(i18next.t("filterBar:noHiddenAbility"), undefined, DropDownState.EXCLUDE),
];
const pokerusLabels = [
new DropDownLabel(i18next.t("filterBar:pokerus"), undefined, DropDownState.OFF),
new DropDownLabel(i18next.t("filterBar:hasPokerus"), undefined, DropDownState.ON),
new DropDownLabel(i18next.t("filterBar:noPokerus"), undefined, DropDownState.EXCLUDE),
];
const miscOptions = [ const miscOptions = [
new DropDownOption(this.scene, "WIN", winLabels), new DropDownOption(this.scene, "WIN", winLabels),
new DropDownOption(this.scene, "HIDDEN_ABILITY", hiddenAbilityLabels),
new DropDownOption(this.scene, "POKERUS", pokerusLabels),
]; ];
this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(this.scene, 0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL)); this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(this.scene, 0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL));
// sort filter // sort filter
const sortOptions = [ const sortOptions = [
new DropDownOption(this.scene, 0, new DropDownLabel(i18next.t("filterBar:sortByNumber"))), new DropDownOption(this.scene, 0, new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON)),
new DropDownOption(this.scene, 1, new DropDownLabel(i18next.t("filterBar:sortByCost"), undefined, DropDownState.OFF)), new DropDownOption(this.scene, 1, new DropDownLabel(i18next.t("filterBar:sortByCost"))),
new DropDownOption(this.scene, 2, new DropDownLabel(i18next.t("filterBar:sortByCandies"), undefined, DropDownState.OFF)), new DropDownOption(this.scene, 2, new DropDownLabel(i18next.t("filterBar:sortByCandies"))),
new DropDownOption(this.scene, 3, new DropDownLabel(i18next.t("filterBar:sortByIVs"), undefined, DropDownState.OFF)), new DropDownOption(this.scene, 3, new DropDownLabel(i18next.t("filterBar:sortByIVs"))),
new DropDownOption(this.scene, 4, new DropDownLabel(i18next.t("filterBar:sortByName"), undefined, DropDownState.OFF)) new DropDownOption(this.scene, 4, new DropDownLabel(i18next.t("filterBar:sortByName")))
]; ];
this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(this.scene, 0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE)); this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(this.scene, 0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE));
this.filterBarContainer.add(this.filterBar); this.filterBarContainer.add(this.filterBar);
@ -462,7 +482,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.starterSelectContainer.add(this.filterBarContainer); this.starterSelectContainer.add(this.filterBarContainer);
// Offset the generation filter dropdown to avoid covering the filtered pokemon // Offset the generation filter dropdown to avoid covering the filtered pokemon
this.filterBar.offsetFirstFilter(); this.filterBar.offsetHybridFilters();
if (!this.scene.uiTheme) { if (!this.scene.uiTheme) {
starterContainerWindow.setVisible(false); starterContainerWindow.setVisible(false);
@ -914,19 +934,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
*/ */
resetFilters() : void { resetFilters() : void {
const genDropDown: DropDown = this.filterBar.getFilter(DropDownColumn.GEN); const genDropDown: DropDown = this.filterBar.getFilter(DropDownColumn.GEN);
if (this.scene.gameMode.isChallenge) {
// In challenge mode all gens are selected by default
genDropDown.defaultCursor = 0;
} else {
// in other modes, gen 1 is selected by default, and all options disabled
genDropDown.defaultCursor = 1;
}
this.filterBar.setValsToDefault(); this.filterBar.setValsToDefault();
// for all modes except challenge, disable all gen options to enable hovering behavior
if (!this.scene.gameMode.isChallenge) { if (!this.scene.gameMode.isChallenge) {
genDropDown.unselectAllOptions(); // if not in a challenge, in Gen hybrid filter hovering mode, set the cursor to the Gen1
genDropDown.setCursor(1);
} }
} }
@ -2107,9 +2120,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const isCaught = !!(caughtVariants & DexAttr.NON_SHINY); const isCaught = !!(caughtVariants & DexAttr.NON_SHINY);
const isUncaught = !isCaught && !isVariantCaught && !isVariant2Caught && !isVariant3Caught; const isUncaught = !isCaught && !isVariantCaught && !isVariant2Caught && !isVariant3Caught;
const isPassiveUnlocked = this.scene.gameData.starterData[container.species.speciesId].passiveAttr > 0; const isPassiveUnlocked = this.scene.gameData.starterData[container.species.speciesId].passiveAttr > 0;
const isCostReduced = this.scene.gameData.starterData[container.species.speciesId].valueReduction > 0;
const isWin = this.scene.gameData.starterData[container.species.speciesId].classicWinCount > 0; const isWin = this.scene.gameData.starterData[container.species.speciesId].classicWinCount > 0;
const isNotWin = this.scene.gameData.starterData[container.species.speciesId].classicWinCount === 0; const isNotWin = this.scene.gameData.starterData[container.species.speciesId].classicWinCount === 0;
const isUndefined = this.scene.gameData.starterData[container.species.speciesId].classicWinCount === undefined; const isUndefined = this.scene.gameData.starterData[container.species.speciesId].classicWinCount === undefined;
const isHA = this.scene.gameData.starterData[container.species.speciesId].abilityAttr & AbilityAttr.ABILITY_HIDDEN;
const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation); const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation);
@ -2139,6 +2154,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
}); });
const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => {
if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) {
return isCostReduced;
} else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) {
return !isCostReduced;
} else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) {
return true;
}
});
const fitsWin = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { const fitsWin = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
if (container.species.speciesId < 10) { if (container.species.speciesId < 10) {
} }
@ -2151,7 +2176,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
}); });
if (fitsGen && fitsType && fitsShiny && fitsPassive && fitsWin) { const fitsHA = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.ON) {
return isHA;
} else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.EXCLUDE) {
return !isHA;
} else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.OFF) {
return true;
}
});
const fitsPokerus = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
if (misc.val === "POKERUS" && misc.state === DropDownState.ON) {
return this.pokerusSpecies.includes(container.species);
} else if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) {
return !this.pokerusSpecies.includes(container.species);
} else if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) {
return true;
}
});
if (fitsGen && fitsType && fitsShiny && fitsPassive && fitsCostReduction && fitsWin && fitsHA && fitsPokerus) {
this.filteredStarterContainers.push(container); this.filteredStarterContainers.push(container);
} }
}); });