From 990c1c2fbc26114d48e43ba18214b69260271c1c Mon Sep 17 00:00:00 2001 From: "C.Ezra.M" <70766223+C-Ezra-M@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:59:36 +0100 Subject: [PATCH] Merge the core of Terrain-inducing moves This is already present with weather moves, so I might as well do it on terrain moves for sake of DRY. --- .../003_Move/004_Move_BaseEffects.rb | 24 ++++++++ .../003_Move/005_MoveEffects_Misc.rb | 60 +++++-------------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index fd8cd49a87..4fc687054d 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -533,6 +533,30 @@ def pbEffectGeneral(user) end end +#=============================================================================== +# Terrain-inducing move. +#=============================================================================== +class Battle::Move::TerrainMove < Battle::Move + attr_reader :terrainType + + def initialize(battle, move) + super + @terrainType = :None + end + + def pbMoveFailed?(user, targets) + if @battle.field.terrain == @terrainType + @battle.pbDisplay(_INTL("But it failed!")) + return true + end + return false + end + + def pbEffectGeneral(user) + @battle.pbStartTerrain(user, @terrainType) + end +end + #=============================================================================== # Pledge move. #=============================================================================== diff --git a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb index 5bdba0d338..7319183868 100644 --- a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb +++ b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb @@ -276,17 +276,10 @@ def initialize(battle, move) # prevents Pokémon from falling asleep. Affects non-airborne Pokémon only. # (Electric Terrain) #=============================================================================== -class Battle::Move::StartElectricTerrain < Battle::Move - def pbMoveFailed?(user, targets) - if @battle.field.terrain == :Electric - @battle.pbDisplay(_INTL("But it failed!")) - return true - end - return false - end - - def pbEffectGeneral(user) - @battle.pbStartTerrain(user, :Electric) +class Battle::Move::StartElectricTerrain < Battle::Move::TerrainMove + def initialize(battle, move) + super + @terrainType = :Electric end end @@ -295,17 +288,10 @@ def pbEffectGeneral(user) # Pokémon at the end of each round. Affects non-airborne Pokémon only. # (Grassy Terrain) #=============================================================================== -class Battle::Move::StartGrassyTerrain < Battle::Move - def pbMoveFailed?(user, targets) - if @battle.field.terrain == :Grassy - @battle.pbDisplay(_INTL("But it failed!")) - return true - end - return false - end - - def pbEffectGeneral(user) - @battle.pbStartTerrain(user, :Grassy) +class Battle::Move::StartGrassyTerrain < Battle::Move::TerrainMove + def initialize(battle, move) + super + @terrainType = :Grassy end end @@ -314,17 +300,10 @@ def pbEffectGeneral(user) # protects Pokémon from status problems. Affects non-airborne Pokémon only. # (Misty Terrain) #=============================================================================== -class Battle::Move::StartMistyTerrain < Battle::Move - def pbMoveFailed?(user, targets) - if @battle.field.terrain == :Misty - @battle.pbDisplay(_INTL("But it failed!")) - return true - end - return false - end - - def pbEffectGeneral(user) - @battle.pbStartTerrain(user, :Misty) +class Battle::Move::StartMistyTerrain < Battle::Move::TerrainMove + def initialize(battle, move) + super + @terrainType = :Misty end end @@ -333,17 +312,10 @@ def pbEffectGeneral(user) # prevents Pokémon from being hit by >0 priority moves. Affects non-airborne # Pokémon only. (Psychic Terrain) #=============================================================================== -class Battle::Move::StartPsychicTerrain < Battle::Move - def pbMoveFailed?(user, targets) - if @battle.field.terrain == :Psychic - @battle.pbDisplay(_INTL("But it failed!")) - return true - end - return false - end - - def pbEffectGeneral(user) - @battle.pbStartTerrain(user, :Psychic) +class Battle::Move::StartPsychicTerrain < Battle::Move::TerrainMove + def initialize(battle, move) + super + @terrainType = :Psychic end end