From 705e82c95ea23684cc329fcd9312117963a4ca1f Mon Sep 17 00:00:00 2001 From: Lylian Date: Wed, 5 Jun 2024 21:16:59 +0200 Subject: [PATCH] add death history and bug fix where retaliate didn't work after 10 turns --- src/battle.ts | 22 ++++++++++------------ src/data/move.ts | 11 ++++++++++- src/phases.ts | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index 6b8e489f950..3f524cbe572 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -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"; @@ -12,6 +11,7 @@ import { PlayerGender } from "./system/game-data"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; import { PokeballType } from "./data/pokeball"; import {trainerConfigs} from "#app/data/trainer-config"; +import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "field/pokemon"; export enum BattleType { WILD, @@ -36,6 +36,11 @@ export interface TurnCommand { args?: any[]; } +export interface FaintLogEntry { + pokemon: Pokemon, + turn: number +} + interface TurnCommands { [key: integer]: TurnCommand } @@ -65,8 +70,8 @@ export default class Battle { public lastUsedPokeball: PokeballType; public playerFaints: number; // The amount of times pokemon on the players side have fainted public enemyFaints: number; // The amount of times pokemon on the enemies side have fainted - public turnsSincePlayerFaints: number; // The amount of turns after pokemon on the players side have fainted - public turnsSinceEnemyFaints: number; // The amount of turns after pokemon on the players side have fainted + public playerFaintsHistory: FaintLogEntry[]; + public enemyFaintsHistory: FaintLogEntry[]; private rngCounter: integer = 0; @@ -95,8 +100,8 @@ export default class Battle { this.lastUsedPokeball = null; this.playerFaints = 0; this.enemyFaints = 0; - this.turnsSincePlayerFaints = -1; - this.turnsSinceEnemyFaints = -1; + this.playerFaintsHistory = []; + this.enemyFaintsHistory = []; } private initBattleSpec(): void { @@ -148,13 +153,6 @@ export default class Battle { this.turn++; this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ])); this.battleSeedState = null; - - if (this.turnsSincePlayerFaints > -1 && this.turnsSincePlayerFaints < 10) { - this.turnsSincePlayerFaints++; - } - if (this.turnsSinceEnemyFaints > -1 && this.turnsSinceEnemyFaints < 10) { - this.turnsSinceEnemyFaints++; - } } addParticipant(playerPokemon: PlayerPokemon): void { diff --git a/src/data/move.ts b/src/data/move.ts index 7c51c3cdc0e..28de9c8cc34 100755 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -184,6 +184,8 @@ export default class Move implements Localizable { return this; } + isRetaliate = () => {}; + addAttr(attr: MoveAttr): this { this.attrs.push(attr); let attrCondition = attr.getCondition(); @@ -6546,7 +6548,14 @@ 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) - .attr(MovePowerMultiplierAttr, (user, target, move) => (user.scene.currentBattle.turnsSincePlayerFaints === 1 && user instanceof PlayerPokemon || user.scene.currentBattle.turnsSinceEnemyFaints === 1 && user instanceof EnemyPokemon) ? 2 : 1), + .attr(MovePowerMultiplierAttr, (user, target, move) => { + console.log(user.scene.currentBattle.playerFaintsHistory.slice(-1)[0].turn - user.scene.currentBattle.turn); + return ( + user.scene.currentBattle.turn - user.scene.currentBattle.playerFaintsHistory.slice(-1)[0].turn === 1 && + user instanceof PlayerPokemon || + user.scene.currentBattle.turn - user.scene.currentBattle.enemyFaintsHistory.slice(-1)[0].turn === 1 && + user instanceof EnemyPokemon) ? 2 : 1; + }), new AttackMove(Moves.FINAL_GAMBIT, Type.FIGHTING, MoveCategory.SPECIAL, -1, 100, 5, -1, 0, 5) .attr(UserHpDamageAttr) .attr(SacrificialAttrOnHit), diff --git a/src/phases.ts b/src/phases.ts index 0b46fb4533d..9d436e2f24f 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3518,10 +3518,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.turnsSincePlayerFaints = 0; + this.scene.currentBattle.playerFaintsHistory = [...this.scene.currentBattle.playerFaintsHistory, {pokemon, turn: this.scene.currentBattle.turn}]; } else { this.scene.currentBattle.enemyFaints += 1; - this.scene.currentBattle.turnsSinceEnemyFaints = 0; + this.scene.currentBattle.enemyFaintsHistory = [...this.scene.currentBattle.enemyFaintsHistory, {pokemon, turn: this.scene.currentBattle.turn}]; } this.scene.queueMessage(getPokemonMessage(pokemon, " fainted!"), null, true);