[Move] Add Retaliate double damage condition (#1831)

* Add retaliate double damage condition

* undo override changes

* add death history and bug fix where retaliate didn't work after 10 turns

* delete the unnecassary log

* optimization

* made some corrections

* add retaliate test as draft

* add retaliate test

* Update src/test/moves/retaliate.test.ts (delete log)

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* remove submodule

* Update src/test/moves/retaliate.test.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* update retaliate test

* Update src/test/moves/retaliate.test.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* update unit test

* remove wide lens for retaliate test

* Update src/test/moves/retaliate.test.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update src/battle.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update src/test/moves/retaliate.test.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update src/test/moves/retaliate.test.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* optimization

* Fix indentation

* Use default values

* Add parentheses for clarity

* Update src/battle.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* Update src/battle.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* Update src/data/move.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* Update src/phases/faint-phase.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* Update src/phases/faint-phase.ts

Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>

* bug on import

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com>
Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
This commit is contained in:
Lylian BALL 2024-09-12 03:31:57 +02:00 committed by GitHub
parent 91d266ea74
commit 8195373824
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 68 additions and 2 deletions

View File

@ -1,5 +1,4 @@
import BattleScene from "./battle-scene";
import { EnemyPokemon, PlayerPokemon, QueuedMove } from "./field/pokemon";
import { Command } from "./ui/command-ui-handler";
import * as Utils from "./utils";
import Trainer, { TrainerVariant } from "./field/trainer";
@ -7,6 +6,7 @@ import { GameMode } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "./data/pokeball";
import { trainerConfigs } from "#app/data/trainer-config";
import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattleSpec } from "#enums/battle-spec";
import { Moves } from "#enums/moves";
@ -38,6 +38,11 @@ export interface TurnCommand {
args?: any[];
}
export interface FaintLogEntry {
pokemon: Pokemon,
turn: number
}
interface TurnCommands {
[key: number]: TurnCommand | null
}
@ -69,6 +74,8 @@ export default class Battle {
public playerFaints: number = 0;
/** The number of times a Pokemon on the enemy's side has fainted this battle */
public enemyFaints: number = 0;
public playerFaintsHistory: FaintLogEntry[] = [];
public enemyFaintsHistory: FaintLogEntry[] = [];
private rngCounter: number = 0;

View File

@ -8024,7 +8024,15 @@ export function initMoves() {
new StatusMove(Moves.REFLECT_TYPE, Type.NORMAL, -1, 15, -1, 0, 5)
.attr(CopyTypeAttr),
new AttackMove(Moves.RETALIATE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 5, -1, 0, 5)
.partial(),
.attr(MovePowerMultiplierAttr, (user, target, move) => {
const turn = user.scene.currentBattle.turn;
const lastPlayerFaint = user.scene.currentBattle.playerFaintsHistory[user.scene.currentBattle.playerFaintsHistory.length - 1];
const lastEnemyFaint = user.scene.currentBattle.enemyFaintsHistory[user.scene.currentBattle.enemyFaintsHistory.length - 1];
return (
(lastPlayerFaint !== undefined && turn - lastPlayerFaint.turn === 1 && user.isPlayer()) ||
(lastEnemyFaint !== undefined && turn - lastEnemyFaint.turn === 1 && !user.isPlayer())
) ? 2 : 1;
}),
new AttackMove(Moves.FINAL_GAMBIT, Type.FIGHTING, MoveCategory.SPECIAL, -1, 100, 5, -1, 0, 5)
.attr(UserHpDamageAttr)
.attr(SacrificialAttrOnHit),

View File

@ -55,8 +55,10 @@ export class FaintPhase extends PokemonPhase {
// Track total times pokemon have been KO'd for supreme overlord/last respects
if (pokemon.isPlayer()) {
this.scene.currentBattle.playerFaints += 1;
this.scene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: this.scene.currentBattle.turn });
} else {
this.scene.currentBattle.enemyFaints += 1;
this.scene.currentBattle.enemyFaintsHistory.push({ pokemon: pokemon, turn: this.scene.currentBattle.turn });
}
this.scene.queueMessage(i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, true);

View File

@ -0,0 +1,49 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager";
import { Species } from "#enums/species";
import { Moves } from "#enums/moves";
import { allMoves } from "#app/data/move";
describe("Moves - Retaliate", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const retaliate = allMoves[Moves.RETALIATE];
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.enemySpecies(Species.SNORLAX)
.enemyMoveset([Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE])
.enemyLevel(100)
.moveset([Moves.RETALIATE, Moves.SPLASH])
.startingLevel(80)
.disableCrits();
});
it("increases power if ally died previous turn", async () => {
vi.spyOn(retaliate, "calculateBattlePower");
await game.startBattle([Species.ABRA, Species.COBALION]);
game.move.select(Moves.RETALIATE);
await game.phaseInterceptor.to("TurnEndPhase");
expect(retaliate.calculateBattlePower).toHaveLastReturnedWith(70);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.RETALIATE);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(retaliate.calculateBattlePower).toHaveReturnedWith(140);
});
});