From db06c53693c655fae1612883cb81397ee00ce95d Mon Sep 17 00:00:00 2001 From: Madmadness65 <59298170+Madmadness65@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:03:15 -0500 Subject: [PATCH] Implement Happy Hour (#2358) --- src/battle.ts | 5 +++++ src/data/arena-tag.ts | 18 +++++++++++++++++- src/data/move.ts | 4 ++-- src/enums/arena-tag-type.ts | 3 ++- src/phases.ts | 4 ++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index 97fd8dd064c..b1fb0378e20 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -7,6 +7,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 { ArenaTagType } from "#enums/arena-tag-type"; import { BattleSpec } from "#enums/battle-spec"; import { Moves } from "#enums/moves"; import { PlayerGender } from "#enums/player-gender"; @@ -166,6 +167,10 @@ export default class Battle { const moneyAmount = new Utils.IntegerHolder(scene.currentBattle.moneyScattered); scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); + if (scene.arena.getTag(ArenaTagType.HAPPY_HOUR)) { + moneyAmount.value *= 2; + } + scene.addMoney(moneyAmount.value); scene.queueMessage(`You picked up ₽${moneyAmount.value.toLocaleString("en-US")}!`, null, true); diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 520fbad5a5e..c49730ad9e6 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -4,7 +4,7 @@ import * as Utils from "../utils"; import { MoveCategory, allMoves, MoveTarget } from "./move"; import { getPokemonMessage } from "../messages"; import Pokemon, { HitResult, PokemonMove } from "../field/pokemon"; -import { MoveEffectPhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase} from "../phases"; +import { MoveEffectPhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; import { StatusEffect } from "./status-effect"; import { BattlerIndex } from "../battle"; import { BlockNonDirectDamageAbAttr, ProtectStatAbAttr, applyAbAttrs } from "./ability"; @@ -695,6 +695,20 @@ class TailwindTag extends ArenaTag { } } +class HappyHourTag extends ArenaTag { + constructor(turnCount: integer, sourceId: integer, side: ArenaTagSide) { + super(ArenaTagType.HAPPY_HOUR, turnCount, Moves.HAPPY_HOUR, sourceId, side); + } + + onAdd(arena: Arena): void { + arena.scene.queueMessage("Everyone is caught up in the happy atmosphere!"); + } + + onRemove(arena: Arena): void { + arena.scene.queueMessage("The atmosphere returned to normal."); + } +} + export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMove: Moves, sourceId: integer, targetIndex?: BattlerIndex, side: ArenaTagSide = ArenaTagSide.BOTH): ArenaTag { switch (tagType) { case ArenaTagType.MIST: @@ -736,5 +750,7 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMov return new AuroraVeilTag(turnCount, sourceId, side); case ArenaTagType.TAILWIND: return new TailwindTag(turnCount, sourceId, side); + case ArenaTagType.HAPPY_HOUR: + return new HappyHourTag(turnCount, sourceId, side); } } diff --git a/src/data/move.ts b/src/data/move.ts index b78d8f799a2..3b7ed896ea0 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7304,8 +7304,8 @@ export function initMoves() { .target(MoveTarget.USER_AND_ALLIES) .condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ Abilities.PLUS, Abilities.MINUS].find(a => p.hasAbility(a, false)))), new StatusMove(Moves.HAPPY_HOUR, Type.NORMAL, -1, 30, -1, 0, 6) // No animation - .target(MoveTarget.USER_SIDE) - .unimplemented(), + .attr(AddArenaTagAttr, ArenaTagType.HAPPY_HOUR, null, true) + .target(MoveTarget.USER_SIDE), new StatusMove(Moves.ELECTRIC_TERRAIN, Type.ELECTRIC, -1, 10, -1, 0, 6) .attr(TerrainChangeAttr, TerrainType.ELECTRIC) .target(MoveTarget.BOTH_SIDES), diff --git a/src/enums/arena-tag-type.ts b/src/enums/arena-tag-type.ts index 90f45f481ba..722096c42cd 100644 --- a/src/enums/arena-tag-type.ts +++ b/src/enums/arena-tag-type.ts @@ -20,5 +20,6 @@ export enum ArenaTagType { WIDE_GUARD = "WIDE_GUARD", MAT_BLOCK = "MAT_BLOCK", CRAFTY_SHIELD = "CRAFTY_SHIELD", - TAILWIND = "TAILWIND" + TAILWIND = "TAILWIND", + HAPPY_HOUR = "HAPPY_HOUR" } diff --git a/src/phases.ts b/src/phases.ts index 70a4af03305..704f5e84391 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4010,6 +4010,10 @@ export class MoneyRewardPhase extends BattlePhase { this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); + if (this.scene.arena.getTag(ArenaTagType.HAPPY_HOUR)) { + moneyAmount.value *= 2; + } + this.scene.addMoney(moneyAmount.value); const userLocale = navigator.language || "en-US";