More aligning of code

This commit is contained in:
Maruno17
2021-12-19 12:19:08 +00:00
parent 13a238cc6a
commit 33781493f4
121 changed files with 977 additions and 838 deletions

View File

@@ -701,8 +701,8 @@ class Battle
@field.weather = newWeather
duration = (fixedDuration) ? 5 : -1
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerWeatherExtender(user.item,
@field.weather, duration, user, self)
duration = Battle::ItemEffects.triggerWeatherExtender(user.item, @field.weather,
duration, user, self)
end
@field.weatherDuration = duration
weather_data = GameData::BattleWeather.try_get(@field.weather)
@@ -779,8 +779,8 @@ class Battle
@field.terrain = newTerrain
duration = (fixedDuration) ? 5 : -1
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerTerrainExtender(user.item,
newTerrain, duration, user, self)
duration = Battle::ItemEffects.triggerTerrainExtender(user.item, newTerrain,
duration, user, self)
end
@field.terrainDuration = duration
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)

View File

@@ -56,14 +56,14 @@ class Battle
# Compare the have values with the need values
if requireds.length > sideCounts.length
raise _INTL("Error: def pbGetOwnerIndexFromBattlerIndex gives invalid owner index ({1} for battle type {2}v{3}, trainers {4}v{5})",
requireds.length - 1, @sideSizes[0], @sideSizes[1], side1counts.length, side2counts.length)
requireds.length - 1, @sideSizes[0], @sideSizes[1], side1counts.length, side2counts.length)
end
sideCounts.each_with_index do |_count, i|
if !requireds[i] || requireds[i] == 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1]) if side == 0
i + 1, @sideSizes[0], @sideSizes[1]) if side == 0
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1]) if side == 1
i + 1, @sideSizes[0], @sideSizes[1]) if side == 1
end
next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i] == 1
@@ -166,10 +166,10 @@ class Battle
pbDisplayPaused(_INTL("Oh! A wild {1} appeared!", foeParty[0].name))
when 2
pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!", foeParty[0].name,
foeParty[1].name))
foeParty[1].name))
when 3
pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!", foeParty[0].name,
foeParty[1].name, foeParty[2].name))
foeParty[1].name, foeParty[2].name))
end
else # Trainer battle
case @opponent.length
@@ -177,10 +177,10 @@ class Battle
pbDisplayPaused(_INTL("You are challenged by {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You are challenged by {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You are challenged by {1}, {2} and {3}!",
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Send out Pokémon (opposing trainers first)
@@ -199,10 +199,10 @@ class Battle
msg += _INTL("{1} sent out {2}!", t.full_name, @battlers[sent[0]].name)
when 2
msg += _INTL("{1} sent out {2} and {3}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name)
@battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("{1} sent out {2}, {3} and {4}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name, @battlers[sent[2]].name)
@battlers[sent[0]].name, @battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
@@ -217,7 +217,7 @@ class Battle
msg += _INTL("Go! {1} and {2}!", @battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("Go! {1}, {2} and {3}!", @battlers[sent[0]].name,
@battlers[sent[1]].name, @battlers[sent[2]].name)
@battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
@@ -403,10 +403,10 @@ class Battle
pbDisplayPaused(_INTL("You defeated {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You defeated {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!", @opponent[0].full_name,
@opponent[1].full_name, @opponent[2].full_name))
@opponent[1].full_name, @opponent[2].full_name))
end
@opponent.each_with_index do |_t, i|
@scene.pbShowOpponent(i)
@@ -431,10 +431,10 @@ class Battle
pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You lost against {1} and {2}!",
@opponent[0].full_name, @opponent[1].full_name))
@opponent[0].full_name, @opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!",
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Lose money from losing a battle

View File

@@ -174,7 +174,7 @@ class Battle
if newLevel < curLevel
debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
raise _INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
pkmn.name, debugInfo)
pkmn.name, debugInfo)
end
# Give Exp
if pkmn.shadowPokemon?
@@ -219,7 +219,7 @@ class Battle
@scene.pbRefreshOne(battler.index) if battler
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed)
oldSpAtk, oldSpDef, oldSpeed)
# Learn all moves learned at this level
moveList = pkmn.getMoveList
moveList.each { |m| pbLearnMove(idxParty, m[1]) if m[0] == curLevel }
@@ -249,7 +249,7 @@ class Battle
end
# Pokémon already knows the maximum number of moves; try to forget one to learn the new move
pbDisplayPaused(_INTL("{1} wants to learn {2}, but it already knows {3} moves.",
pkmnName, moveName, pkmn.numMoves.to_word))
pkmnName, moveName, pkmn.numMoves.to_word))
if pbDisplayConfirm(_INTL("Should {1} forget a move to learn {2}?", pkmnName, moveName))
loop do
forgetMove = @scene.pbForgetMove(pkmn, newMove)

View File

@@ -19,18 +19,16 @@ class Battle
if partyScene
owner = pbGetOwnerFromPartyIndex(idxBattler, idxParty)
partyScene.pbDisplay(_INTL("You can't switch {1}'s Pokémon with one of yours!",
owner.name))
owner.name))
end
return false
end
if party[idxParty].fainted?
partyScene.pbDisplay(_INTL("{1} has no energy left to battle!",
party[idxParty].name)) if partyScene
partyScene.pbDisplay(_INTL("{1} has no energy left to battle!", party[idxParty].name)) if partyScene
return false
end
if pbFindBattler(idxParty, idxBattler)
partyScene.pbDisplay(_INTL("{1} is already in battle!",
party[idxParty].name)) if partyScene
partyScene.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name)) if partyScene
return false
end
return true
@@ -48,7 +46,7 @@ class Battle
allSameSideBattlers(idxBattler).each do |b|
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
partyScene.pbDisplay(_INTL("{1} has already been selected.",
pbParty(idxBattler)[idxParty].name)) if partyScene
pbParty(idxBattler)[idxParty].name)) if partyScene
return false
end
# Check whether battler can switch out
@@ -77,7 +75,7 @@ class Battle
next if !b.abilityActive?
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis, b.abilityName)) if partyScene
b.pbThis, b.abilityName)) if partyScene
return false
end
end
@@ -85,7 +83,7 @@ class Battle
next if !b.itemActive?
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis, b.itemName)) if partyScene
b.pbThis, b.itemName)) if partyScene
return false
end
end
@@ -172,7 +170,7 @@ class Battle
idxPartyForName = new_index if new_index >= 0 && new_index != idxPartyNew
end
if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?",
opponent.full_name, enemyParty[idxPartyForName].name))
opponent.full_name, enemyParty[idxPartyForName].name))
idxPlayerPartyNew = pbSwitchInBetween(0, false, true)
if idxPlayerPartyNew >= 0
pbMessageOnRecall(@battlers[0])

View File

@@ -10,7 +10,7 @@ class Battle
# Embargo
if battler && battler.effects[PBEffects::Embargo] > 0
scene.pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",
battler.pbThis(true))) if showMessages
battler.pbThis(true))) if showMessages
return false
end
return true

View File

@@ -140,7 +140,7 @@ class Battle
pbDisplay(_INTL("{1}'s fervent wish has reached {2}!", trainerName, battler.pbThis))
else
pbDisplay(_INTL("{1}'s {2} is reacting to {3}'s {4}!",
battler.pbThis, battler.itemName, trainerName, pbGetMegaRingName(idxBattler)))
battler.pbThis, battler.itemName, trainerName, pbGetMegaRingName(idxBattler)))
end
pbCommonAnimation("MegaEvolution", battler)
battler.pokemon.makeMega

View File

@@ -128,8 +128,8 @@ class Battle
next false
end
next false if !pkmn
next false if !ItemHandlers.triggerCanUseInBattle(item,
pkmn, battler, idxMove, firstAction, self, itemScene)
next false if !ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, idxMove,
firstAction, self, itemScene)
next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove)
ret = true
next true

View File

@@ -231,7 +231,7 @@ class Battle
next if !moveUser # User is fainted
move = pos.effects[PBEffects::FutureSightMove]
pbDisplay(_INTL("{1} took the {2} attack!", @battlers[idxPos].pbThis,
GameData::Move.get(move).name))
GameData::Move.get(move).name))
# NOTE: Future Sight failing against the target here doesn't count towards
# Stomping Tantrum.
userLastMoveFailed = moveUser.lastMoveFailed
@@ -332,7 +332,7 @@ class Battle
pbCommonAnimation("LeechSeed", recipient, b)
b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost|
recipient.pbRecoverHPFromDrain(hp_lost, b,
_INTL("{1}'s health is sapped by Leech Seed!", b.pbThis))
_INTL("{1}'s health is sapped by Leech Seed!", b.pbThis))
recipient.pbAbilitiesOnDamageTaken
}
recipient.pbFaint if recipient.fainted?
@@ -519,53 +519,53 @@ class Battle
for side in 0...2
# Reflect
pbEORCountDownSideEffect(side, PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam))
_INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam))
# Light Screen
pbEORCountDownSideEffect(side, PBEffects::LightScreen,
_INTL("{1}'s Light Screen wore off!", @battlers[side].pbTeam))
_INTL("{1}'s Light Screen wore off!", @battlers[side].pbTeam))
# Safeguard
pbEORCountDownSideEffect(side, PBEffects::Safeguard,
_INTL("{1} is no longer protected by Safeguard!", @battlers[side].pbTeam))
_INTL("{1} is no longer protected by Safeguard!", @battlers[side].pbTeam))
# Mist
pbEORCountDownSideEffect(side, PBEffects::Mist,
_INTL("{1} is no longer protected by mist!", @battlers[side].pbTeam))
_INTL("{1} is no longer protected by mist!", @battlers[side].pbTeam))
# Tailwind
pbEORCountDownSideEffect(side, PBEffects::Tailwind,
_INTL("{1}'s Tailwind petered out!", @battlers[side].pbTeam))
_INTL("{1}'s Tailwind petered out!", @battlers[side].pbTeam))
# Lucky Chant
pbEORCountDownSideEffect(side, PBEffects::LuckyChant,
_INTL("{1}'s Lucky Chant wore off!", @battlers[side].pbTeam))
_INTL("{1}'s Lucky Chant wore off!", @battlers[side].pbTeam))
# Pledge Rainbow
pbEORCountDownSideEffect(side, PBEffects::Rainbow,
_INTL("The rainbow on {1}'s side disappeared!", @battlers[side].pbTeam(true)))
_INTL("The rainbow on {1}'s side disappeared!", @battlers[side].pbTeam(true)))
# Pledge Sea of Fire
pbEORCountDownSideEffect(side, PBEffects::SeaOfFire,
_INTL("The sea of fire around {1} disappeared!", @battlers[side].pbTeam(true)))
_INTL("The sea of fire around {1} disappeared!", @battlers[side].pbTeam(true)))
# Pledge Swamp
pbEORCountDownSideEffect(side, PBEffects::Swamp,
_INTL("The swamp around {1} disappeared!", @battlers[side].pbTeam(true)))
_INTL("The swamp around {1} disappeared!", @battlers[side].pbTeam(true)))
# Aurora Veil
pbEORCountDownSideEffect(side, PBEffects::AuroraVeil,
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam(true)))
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam(true)))
end
# Trick Room
pbEORCountDownFieldEffect(PBEffects::TrickRoom,
_INTL("The twisted dimensions returned to normal!"))
_INTL("The twisted dimensions returned to normal!"))
# Gravity
pbEORCountDownFieldEffect(PBEffects::Gravity,
_INTL("Gravity returned to normal!"))
_INTL("Gravity returned to normal!"))
# Water Sport
pbEORCountDownFieldEffect(PBEffects::WaterSportField,
_INTL("The effects of Water Sport have faded."))
_INTL("The effects of Water Sport have faded."))
# Mud Sport
pbEORCountDownFieldEffect(PBEffects::MudSportField,
_INTL("The effects of Mud Sport have faded."))
_INTL("The effects of Mud Sport have faded."))
# Wonder Room
pbEORCountDownFieldEffect(PBEffects::WonderRoom,
_INTL("Wonder Room wore off, and Defense and Sp. Def stats returned to normal!"))
_INTL("Wonder Room wore off, and Defense and Sp. Def stats returned to normal!"))
# Magic Room
pbEORCountDownFieldEffect(PBEffects::MagicRoom,
_INTL("Magic Room wore off, and held items' effects returned to normal!"))
_INTL("Magic Room wore off, and held items' effects returned to normal!"))
# End of terrains
pbEORTerrain
priority.each do |b|