Compare commits
10 Commits
caa982368f
...
c63960b61c
Author | SHA1 | Date |
---|---|---|
NightKev | c63960b61c | |
NightKev | 10e0f9f0de | |
AJ Fontaine | 8457fb96fe | |
damocleas | f95a5d41cb | |
NightKev | 689162772d | |
Tempoanon | 6d903440b4 | |
NightKev | 3ba2a03223 | |
NightKev | 836cb90d8b | |
NightKev | 9e30541565 | |
NightKev | 903c050d2b |
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "pokemon-rogue-battle",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pokemon-rogue-battle",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@material/material-color-utilities": "^0.2.7",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "pokemon-rogue-battle",
|
||||
"private": true,
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
|
|
|
@ -40,6 +40,9 @@ import { GameMode } from "#app/game-mode";
|
|||
import { applyChallenges, ChallengeType } from "./challenge";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { StatusEffect } from "enums/status-effect";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import PartyUiHandler, { PartyUiMode, type PartyOption } from "#app/ui/party-ui-handler";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
|
||||
export enum MoveCategory {
|
||||
PHYSICAL,
|
||||
|
@ -5920,30 +5923,63 @@ export class AddPledgeEffectAttr extends AddArenaTagAttr {
|
|||
* @see {@linkcode apply}
|
||||
*/
|
||||
export class RevivalBlessingAttr extends MoveEffectAttr {
|
||||
constructor(user?: boolean) {
|
||||
constructor() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user {@linkcode Pokemon} using this move
|
||||
* @param target {@linkcode Pokemon} target of this move
|
||||
* @param move {@linkcode Move} being used
|
||||
* @param target N/A
|
||||
* @param move N/A
|
||||
* @param args N/A
|
||||
* @returns Promise, true if function succeeds.
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
const revivePlayer = (): Promise<void> => {
|
||||
return new Promise(resolve => {
|
||||
user.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, user.getFieldIndex(), (slotIndex: number, option: PartyOption) => {
|
||||
if (slotIndex >= 0 && slotIndex < 6) {
|
||||
const pokemon = user.scene.getPlayerParty()[slotIndex];
|
||||
if (!pokemon || !pokemon.isFainted()) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
pokemon.resetTurnData();
|
||||
pokemon.resetStatus();
|
||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||
user.scene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
|
||||
|
||||
if (user.scene.currentBattle.double && user.scene.getPlayerParty().length > 1) {
|
||||
const allyPokemon = user.getAlly();
|
||||
if (slotIndex <= 1) {
|
||||
// Revived ally pokemon
|
||||
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, SwitchType.SWITCH, pokemon.getFieldIndex(), slotIndex, false, true));
|
||||
user.scene.unshiftPhase(new ToggleDoublePositionPhase(user.scene, true));
|
||||
} else if (allyPokemon.isFainted()) {
|
||||
// Revived party pokemon, and ally pokemon is fainted
|
||||
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, true));
|
||||
user.scene.unshiftPhase(new ToggleDoublePositionPhase(user.scene, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
user.scene.ui.setMode(Mode.MESSAGE).then(() => resolve());
|
||||
}, PartyUiHandler.FilterFainted);
|
||||
});
|
||||
};
|
||||
|
||||
return new Promise(resolve => {
|
||||
// If user is player, checks if the user has fainted pokemon
|
||||
if (user instanceof PlayerPokemon
|
||||
&& user.scene.getPlayerParty().findIndex(p => p.isFainted()) > -1) {
|
||||
(user as PlayerPokemon).revivalBlessing().then(() => {
|
||||
if (user instanceof PlayerPokemon && user.scene.getPlayerParty().findIndex(p => p.isFainted()) > -1) {
|
||||
revivePlayer().then(() => {
|
||||
resolve(true);
|
||||
});
|
||||
// If user is enemy, checks that it is a trainer, and it has fainted non-boss pokemon in party
|
||||
} else if (user instanceof EnemyPokemon
|
||||
} else if (
|
||||
user instanceof EnemyPokemon
|
||||
&& user.hasTrainer()
|
||||
&& user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) {
|
||||
&& user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1
|
||||
) {
|
||||
// Selects a random fainted pokemon
|
||||
const faintedPokemon = user.scene.getEnemyParty().filter(p => p.isFainted() && !p.isBoss());
|
||||
const pokemon = faintedPokemon[user.randSeedInt(faintedPokemon.length)];
|
||||
|
|
|
@ -31,7 +31,7 @@ import { BerryType } from "#enums/berry-type";
|
|||
import { PERMANENT_STATS, Stat } from "#enums/stat";
|
||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import PokemonSpecies, { allSpecies } from "#app/data/pokemon-species";
|
||||
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounters/berriesAbound";
|
||||
|
@ -62,8 +62,8 @@ export const BerriesAboundEncounter: MysteryEncounter =
|
|||
let bossSpecies: PokemonSpecies;
|
||||
if (scene.eventManager.isEventActive() && scene.eventManager.activeEvent()?.uncommonBreedEncounters && randSeedInt(2) === 1) {
|
||||
const eventEncounter = randSeedItem(scene.eventManager.activeEvent()!.uncommonBreedEncounters!);
|
||||
bossSpecies = allSpecies[eventEncounter.species];
|
||||
bossSpecies.speciesId = bossSpecies.getSpeciesForLevel(level, eventEncounter.allowEvolution);
|
||||
const levelSpecies = getPokemonSpecies(eventEncounter.species).getWildSpeciesForLevel(level, eventEncounter.allowEvolution ?? false, true, scene.gameMode);
|
||||
bossSpecies = getPokemonSpecies( levelSpecies );
|
||||
} else {
|
||||
bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encoun
|
|||
import { randSeedInt, randSeedItem } from "#app/utils";
|
||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import PokemonSpecies, { allSpecies } from "#app/data/pokemon-species";
|
||||
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounters/fightOrFlight";
|
||||
|
@ -60,8 +60,8 @@ export const FightOrFlightEncounter: MysteryEncounter =
|
|||
let bossSpecies: PokemonSpecies;
|
||||
if (scene.eventManager.isEventActive() && scene.eventManager.activeEvent()?.uncommonBreedEncounters && randSeedInt(2) === 1) {
|
||||
const eventEncounter = randSeedItem(scene.eventManager.activeEvent()!.uncommonBreedEncounters!);
|
||||
bossSpecies = allSpecies[eventEncounter.species];
|
||||
bossSpecies.speciesId = bossSpecies.getSpeciesForLevel(level, eventEncounter.allowEvolution);
|
||||
const levelSpecies = getPokemonSpecies(eventEncounter.species).getWildSpeciesForLevel(level, eventEncounter.allowEvolution ?? false, true, scene.gameMode);
|
||||
bossSpecies = getPokemonSpecies( levelSpecies );
|
||||
} else {
|
||||
bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import { BerryModifier } from "#app/modifier/modifier";
|
|||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import PokemonSpecies, { allSpecies } from "#app/data/pokemon-species";
|
||||
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounters/uncommonBreed";
|
||||
|
@ -55,8 +55,8 @@ export const UncommonBreedEncounter: MysteryEncounter =
|
|||
let species: PokemonSpecies;
|
||||
if (scene.eventManager.isEventActive() && scene.eventManager.activeEvent()?.uncommonBreedEncounters && randSeedInt(2) === 1) {
|
||||
const eventEncounter = randSeedItem(scene.eventManager.activeEvent()!.uncommonBreedEncounters!);
|
||||
species = allSpecies[eventEncounter.species];
|
||||
species.speciesId = species.getSpeciesForLevel(level, eventEncounter.allowEvolution);
|
||||
const levelSpecies = getPokemonSpecies(eventEncounter.species).getWildSpeciesForLevel(level, eventEncounter.allowEvolution ?? false, true, scene.gameMode);
|
||||
species = getPokemonSpecies( levelSpecies );
|
||||
} else {
|
||||
species = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|||
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
|
||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||
|
@ -4336,43 +4335,6 @@ export class PlayerPokemon extends Pokemon {
|
|||
this.friendship = Math.max(this.friendship + friendship, 0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handles Revival Blessing when used by player.
|
||||
* @returns Promise to revive a pokemon.
|
||||
* @see {@linkcode RevivalBlessingAttr}
|
||||
*/
|
||||
revivalBlessing(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
|
||||
if (slotIndex >= 0 && slotIndex < 6) {
|
||||
const pokemon = this.scene.getPlayerParty()[slotIndex];
|
||||
if (!pokemon || !pokemon.isFainted()) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
pokemon.resetTurnData();
|
||||
pokemon.resetStatus();
|
||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||
this.scene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
|
||||
|
||||
if (this.scene.currentBattle.double && this.scene.getPlayerParty().length > 1) {
|
||||
const allyPokemon = this.getAlly();
|
||||
if (slotIndex <= 1) {
|
||||
// Revived ally pokemon
|
||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, SwitchType.SWITCH, pokemon.getFieldIndex(), slotIndex, false, true));
|
||||
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
|
||||
} else if (allyPokemon.isFainted()) {
|
||||
// Revived party pokemon, and ally pokemon is fainted
|
||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, true));
|
||||
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => resolve());
|
||||
}, PartyUiHandler.FilterFainted);
|
||||
});
|
||||
}
|
||||
|
||||
getPossibleEvolution(evolution: SpeciesFormEvolution | null): Promise<Pokemon> {
|
||||
if (!evolution) {
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
import { toDmgValue } from "#app/utils";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Moves - Revival Blessing", () => {
|
||||
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
|
||||
.moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING ])
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.battleType("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(Species.MAGIKARP)
|
||||
.enemyAbility(Abilities.NO_GUARD)
|
||||
.enemyMoveset([ Moves.SPLASH, Moves.FISSURE ])
|
||||
.enemyLevel(10);
|
||||
});
|
||||
|
||||
it("should revive a player pokemon to half health", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]);
|
||||
|
||||
const feebas = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.FISSURE);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(feebas.isFainted()).toBe(true);
|
||||
|
||||
game.move.select(Moves.REVIVAL_BLESSING);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
game.doSelectPartyPokemon(1, "MoveEffectPhase");
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(feebas.isFainted()).toBe(false);
|
||||
expect(feebas.hp).toBe(toDmgValue(0.5 * feebas.getMaxHp()));
|
||||
});
|
||||
|
||||
it("should revive a player pokemon to half health and send it back out if used in the same turn it fainted in doubles", async () => {
|
||||
game.override.battleType("double");
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC, Species.GYARADOS ]);
|
||||
|
||||
const feebas = game.scene.getPlayerField()[0];
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.REVIVAL_BLESSING, 1);
|
||||
await game.forceEnemyMove(Moves.FISSURE, BattlerIndex.PLAYER);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
|
||||
expect(feebas.isFainted()).toBe(true);
|
||||
|
||||
game.doSelectPartyPokemon(0, "MoveEffectPhase");
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(feebas.isFainted()).toBe(false);
|
||||
expect(feebas.hp).toBe(toDmgValue(0.5 * feebas.getMaxHp()));
|
||||
expect(game.scene.getPlayerField()[0]).toBe(feebas);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue