Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -3,18 +3,18 @@ class Battle::Scene
# The player chooses a main command for a Pokémon
# Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
def pbCommandMenu(idxBattler, firstAction)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
_INTL("What will\n{1} do?",@battle.battlers[idxBattler].name),
_INTL("What will\n{1} do?", @battle.battlers[idxBattler].name),
_INTL("Fight"),
_INTL("Bag"),
_INTL("Pokémon"),
(shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel")
]
ret = pbCommandMenuEx(idxBattler,cmds,(shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret==3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret==3 && !firstAction # Convert "Run" to "Cancel"
ret = pbCommandMenuEx(idxBattler, cmds, (shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret == 3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret == 3 && !firstAction # Convert "Run" to "Cancel"
return ret
end
@@ -23,11 +23,11 @@ class Battle::Scene
# 2 = regular battle with "Call" (for Shadow Pokémon battles)
# 3 = Safari Zone
# 4 = Bug Catching Contest
def pbCommandMenuEx(idxBattler,texts,mode = 0)
def pbCommandMenuEx(idxBattler, texts, mode = 0)
pbShowWindow(COMMAND_BOX)
cw = @sprites["commandWindow"]
cw.setTexts(texts)
cw.setIndexAndMode(@lastCmd[idxBattler],mode)
cw.setIndexAndMode(@lastCmd[idxBattler], mode)
pbSelectBattler(idxBattler)
ret = -1
loop do
@@ -35,22 +35,22 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
cw.index += 1 if (cw.index&1)==0
cw.index += 1 if (cw.index & 1) == 0
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
cw.index += 2 if (cw.index&2)==0
cw.index += 2 if (cw.index & 2) == 0
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
ret = cw.index
@lastCmd[idxBattler] = ret
break
elsif Input.trigger?(Input::BACK) && mode==1 # Cancel
elsif Input.trigger?(Input::BACK) && mode == 1 # Cancel
pbPlayCancelSE
break
elsif Input.trigger?(Input::F9) && $DEBUG # Debug menu
@@ -65,7 +65,7 @@ class Battle::Scene
#=============================================================================
# The player chooses a move for a Pokémon to use
#=============================================================================
def pbFightMenu(idxBattler,megaEvoPossible = false)
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
cw = @sprites["fightWindow"]
cw.battler = battler
@@ -74,7 +74,7 @@ class Battle::Scene
moveIndex = @lastMove[idxBattler]
end
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
cw.setIndexAndMode(moveIndex,(megaEvoPossible) ? 1 : 0)
cw.setIndexAndMode(moveIndex, (megaEvoPossible) ? 1 : 0)
needFullRefresh = true
needRefresh = false
loop do
@@ -87,7 +87,7 @@ class Battle::Scene
if needRefresh
if megaEvoPossible
newMode = (@battle.pbRegisteredMegaEvolution?(idxBattler)) ? 2 : 1
cw.mode = newMode if newMode!=cw.mode
cw.mode = newMode if newMode != cw.mode
end
needRefresh = false
end
@@ -96,19 +96,19 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
if battler.moves[cw.index+1] && battler.moves[cw.index+1].id
cw.index += 1 if (cw.index&1)==0
if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id
cw.index += 1 if (cw.index & 1) == 0
end
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
if battler.moves[cw.index+2] && battler.moves[cw.index+2].id
cw.index += 2 if (cw.index&2)==0
if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id
cw.index += 2 if (cw.index & 2) == 0
end
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
@@ -126,7 +126,7 @@ class Battle::Scene
needRefresh = true
end
elsif Input.trigger?(Input::SPECIAL) # Shift
if cw.shiftMode>0
if cw.shiftMode > 0
pbPlayDecisionSE
break if yield -3
needRefresh = true
@@ -140,7 +140,7 @@ class Battle::Scene
# Opens the party screen to choose a Pokémon to switch in (or just view its
# summary screens)
#=============================================================================
def pbPartyScreen(idxBattler,canCancel = false)
def pbPartyScreen(idxBattler, canCancel = false)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Get player's party
@@ -149,14 +149,14 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
scene = PokemonParty_Scene.new
switchScreen = PokemonPartyScreen.new(scene,modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."),@battle.pbNumPositions(0,0))
switchScreen = PokemonPartyScreen.new(scene, modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."), @battle.pbNumPositions(0, 0))
# Loop while in party screen
loop do
# Select a Pokémon
scene.pbSetHelpText(_INTL("Choose a Pokémon."))
idxParty = switchScreen.pbChoosePokemon
if idxParty<0
if idxParty < 0
next if !canCancel
break
end
@@ -167,29 +167,29 @@ class Battle::Scene
commands[cmdSwitch = commands.length] = _INTL("Switch In") if modParty[idxParty].able?
commands[cmdSummary = commands.length] = _INTL("Summary")
commands[commands.length] = _INTL("Cancel")
command = scene.pbShowCommands(_INTL("Do what with {1}?",modParty[idxParty].name),commands)
if cmdSwitch>=0 && command==cmdSwitch # Switch In
command = scene.pbShowCommands(_INTL("Do what with {1}?", modParty[idxParty].name), commands)
if cmdSwitch >= 0 && command == cmdSwitch # Switch In
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
break if yield idxPartyRet, switchScreen
elsif cmdSummary>=0 && command==cmdSummary # Summary
scene.pbSummary(idxParty,true)
elsif cmdSummary >= 0 && command == cmdSummary # Summary
scene.pbSummary(idxParty, true)
end
end
# Close party screen
switchScreen.pbEndScene
# Fade back into battle screen
pbFadeInAndShow(@sprites,visibleSprites)
pbFadeInAndShow(@sprites, visibleSprites)
end
#=============================================================================
# Opens the Bag screen and chooses an item to use
#=============================================================================
def pbItemMenu(idxBattler,_firstAction)
def pbItemMenu(idxBattler, _firstAction)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Set Bag starting positions
@@ -216,10 +216,10 @@ class Battle::Scene
useType = item.battle_use
cmdUse = -1
commands = []
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType != 0
commands[commands.length] = _INTL("Cancel")
command = itemScene.pbShowCommands(_INTL("{1} is selected.",itemName),commands)
next unless cmdUse>=0 && command==cmdUse # Use
command = itemScene.pbShowCommands(_INTL("{1} is selected.", itemName), commands)
next unless cmdUse >= 0 && command == cmdUse # Use
# Use types:
# 0 = not usable in battle
# 1 = use on Pokémon (lots of items, Blue Flute)
@@ -233,11 +233,11 @@ class Battle::Scene
# are the only available Pokémon/battler to use the item on
case useType
when 1 # Use on Pokémon
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1
if @battle.pbTeamLengthFromBattlerIndex(idxBattler) == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
when 3 # Use on battler
if @battle.pbPlayerBattlerCount==1
if @battle.pbPlayerBattlerCount == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
end
@@ -250,38 +250,38 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
pkmnScene = PokemonParty_Scene.new
pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.pbNumPositions(0,0))
pkmnScreen = PokemonPartyScreen.new(pkmnScene, modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"), @battle.pbNumPositions(0, 0))
idxParty = -1
# Loop while in party screen
loop do
# Select a Pokémon
pkmnScene.pbSetHelpText(_INTL("Use on which Pokémon?"))
idxParty = pkmnScreen.pbChoosePokemon
break if idxParty<0
break if idxParty < 0
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
next if idxPartyRet<0
next if idxPartyRet < 0
pkmn = party[idxPartyRet]
next if !pkmn || pkmn.egg?
idxMove = -1
if useType==2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
next if idxMove<0
if useType == 2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn, _INTL("Restore which move?"))
next if idxMove < 0
end
break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
end
pkmnScene.pbEndScene
break if idxParty>=0
break if idxParty >= 0
# Cancelled choosing a Pokémon; show the Bag screen again
itemScene.pbFadeInScene
when 4 # Use on opposing battler (Poké Balls)
idxTarget = -1
if @battle.pbOpposingBattlerCount(idxBattler)==1
if @battle.pbOpposingBattlerCount(idxBattler) == 1
@battle.allOtherSideBattlers(idxBattler).each { |b| idxTarget = b.index }
break if yield item.id, useType, idxTarget, -1, itemScene
else
@@ -292,8 +292,8 @@ class Battle::Scene
tempVisibleSprites = visibleSprites.clone
tempVisibleSprites["commandWindow"] = false
tempVisibleSprites["targetWindow"] = true
idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)
if idxTarget>=0
idxTarget = pbChooseTarget(idxBattler, GameData::Target.get(:Foe), tempVisibleSprites)
if idxTarget >= 0
break if yield item.id, useType, idxTarget, -1, self
end
# Target invalid/cancelled choosing a target; show the Bag screen again
@@ -312,7 +312,7 @@ class Battle::Scene
# Close Bag screen
itemScene.pbEndScene
# Fade back into battle screen (if not already showing it)
pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting
pbFadeInAndShow(@sprites, visibleSprites) if !wasTargeting
end
#=============================================================================
@@ -322,7 +322,7 @@ class Battle::Scene
# target.
# nil means can't select that position, "" means can select that position but
# there is no battler there, otherwise is a battler's name.
def pbCreateTargetTexts(idxBattler,target_data)
def pbCreateTargetTexts(idxBattler, target_data)
texts = Array.new(@battle.battlers.length) do |i|
next nil if !@battle.battlers[i]
showName = false
@@ -331,15 +331,15 @@ class Battle::Scene
# other targets are handled by the "else" part.
case target_data.id
when :None, :User, :RandomNearFoe
showName = (i==idxBattler)
showName = (i == idxBattler)
when :UserSide
showName = !@battle.opposes?(i,idxBattler)
showName = !@battle.opposes?(i, idxBattler)
when :FoeSide
showName = @battle.opposes?(i,idxBattler)
showName = @battle.opposes?(i, idxBattler)
when :BothSides
showName = true
else
showName = @battle.pbMoveCanTarget?(i,idxBattler,target_data)
showName = @battle.pbMoveCanTarget?(i, idxBattler, target_data)
end
next nil if !showName
next (@battle.battlers[i].fainted?) ? "" : @battle.battlers[i].name
@@ -349,22 +349,22 @@ class Battle::Scene
# Returns the initial position of the cursor when choosing a target for a move
# in a non-single battle.
def pbFirstTarget(idxBattler,target_data)
def pbFirstTarget(idxBattler, target_data)
case target_data.id
when :NearAlly
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
next if b.fainted?
return b.index
end
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
return b.index
end
when :NearFoe, :NearOther
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) }
when :Foe, :Other
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if !@battle.battlers[i].fainted? }
@@ -373,37 +373,37 @@ class Battle::Scene
return idxBattler # Target the user initially
end
def pbChooseTarget(idxBattler,target_data,visibleSprites = nil)
def pbChooseTarget(idxBattler, target_data, visibleSprites = nil)
pbShowWindow(TARGET_BOX)
cw = @sprites["targetWindow"]
# Create an array of battler names (only valid targets are named)
texts = pbCreateTargetTexts(idxBattler,target_data)
texts = pbCreateTargetTexts(idxBattler, target_data)
# Determine mode based on target_data
mode = (target_data.num_targets == 1) ? 0 : 1
cw.setDetails(texts,mode)
cw.index = pbFirstTarget(idxBattler,target_data)
pbSelectBattler((mode==0) ? cw.index : texts,2) # Select initial battler/data box
pbFadeInAndShow(@sprites,visibleSprites) if visibleSprites
cw.setDetails(texts, mode)
cw.index = pbFirstTarget(idxBattler, target_data)
pbSelectBattler((mode == 0) ? cw.index : texts, 2) # Select initial battler/data box
pbFadeInAndShow(@sprites, visibleSprites) if visibleSprites
ret = -1
loop do
oldIndex = cw.index
pbUpdate(cw)
# Update selected command
if mode==0 # Choosing just one target, can change index
if mode == 0 # Choosing just one target, can change index
if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
inc = ((cw.index%2)==0) ? -2 : 2
inc = ((cw.index % 2) == 0) ? -2 : 2
inc *= -1 if Input.trigger?(Input::RIGHT)
indexLength = @battle.sideSizes[cw.index%2]*2
indexLength = @battle.sideSizes[cw.index % 2] * 2
newIndex = cw.index
loop do
newIndex += inc
break if newIndex<0 || newIndex>=indexLength
break if newIndex < 0 || newIndex >= indexLength
next if texts[newIndex].nil?
cw.index = newIndex
break
end
elsif (Input.trigger?(Input::UP) && (cw.index%2)==0) ||
(Input.trigger?(Input::DOWN) && (cw.index%2)==1)
elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) ||
(Input.trigger?(Input::DOWN) && (cw.index % 2) == 1)
tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index)
tryIndex.each do |idxBattlerTry|
next if texts[idxBattlerTry].nil?
@@ -411,9 +411,9 @@ class Battle::Scene
break
end
end
if cw.index!=oldIndex
if cw.index != oldIndex
pbPlayCursorSE
pbSelectBattler(cw.index,2) # Select the new battler/data box
pbSelectBattler(cw.index, 2) # Select the new battler/data box
end
end
if Input.trigger?(Input::USE) # Confirm
@@ -436,12 +436,12 @@ class Battle::Scene
# Called whenever a Pokémon should forget a move. It should return -1 if the
# selection is canceled, or 0 to 3 to indicate the move to forget. It should
# not allow HM moves to be forgotten.
def pbForgetMove(pkmn,moveToLearn)
def pbForgetMove(pkmn, moveToLearn)
ret = -1
pbFadeOutIn {
scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene)
ret = screen.pbStartForgetScreen([pkmn],0,moveToLearn)
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
}
return ret
end
@@ -449,7 +449,7 @@ class Battle::Scene
#=============================================================================
# Opens the nicknaming screen for a newly caught Pokémon
#=============================================================================
def pbNameEntry(helpText,pkmn)
def pbNameEntry(helpText, pkmn)
return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn)
end