Resolved many Rubocop warnings

This commit is contained in:
Maruno17
2020-09-06 17:31:12 +01:00
parent 6c4670eaa3
commit 681a8331ab
137 changed files with 921 additions and 1200 deletions

View File

@@ -173,7 +173,7 @@ end
# Constant checks
#===============================================================================
# Pokérus check
Events.onMapUpdate += proc { |sender,e|
Events.onMapUpdate += proc { |_sender,_e|
next if !$Trainer
last = $PokemonGlobal.pokerusTime
now = pbGetTimeNow
@@ -226,7 +226,7 @@ def pbBatteryLow?
return false
end
Events.onMapUpdate += proc { |sender,e|
Events.onMapUpdate += proc { |_sender,_e|
if !$PokemonTemp.batterywarning && pbBatteryLow?
if !$game_temp.in_menu && !$game_temp.in_battle &&
!$game_player.move_route_forcing && !$game_temp.message_window_showing &&
@@ -266,7 +266,7 @@ Events.onStepTaken += proc{
}
# Poison party Pokémon
Events.onStepTakenTransferPossible += proc { |sender,e|
Events.onStepTakenTransferPossible += proc { |_sender,e|
handled = e[0]
next if handled[0]
if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD
@@ -307,7 +307,7 @@ def pbCheckAllFainted
end
# Gather soot from soot grass
Events.onStepTakenFieldMovement += proc { |sender,e|
Events.onStepTakenFieldMovement += proc { |_sender,e|
event = e[0] # Get the event affected by field movement
thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y)
map = $MapFactory.getMap(thistile[0])
@@ -331,7 +331,7 @@ Events.onStepTakenFieldMovement += proc { |sender,e|
}
# Show grass rustle animation, and auto-move the player over waterfalls and ice
Events.onStepTakenFieldMovement += proc { |sender,e|
Events.onStepTakenFieldMovement += proc { |_sender,e|
event = e[0] # Get the event affected by field movement
if $scene.is_a?(Scene_Map)
currentTag = pbGetTerrainTag(event)
@@ -395,9 +395,8 @@ end
#===============================================================================
# Clears the weather of the old map, if the old and new maps have different
# names or defined weather
Events.onMapChanging += proc { |sender,e|
Events.onMapChanging += proc { |_sender,e|
newMapID = e[0]
newMap = e[1]
if newMapID>0
mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
oldWeather = pbGetMetadata($game_map.map_id,MetadataWeather)
@@ -411,7 +410,7 @@ Events.onMapChanging += proc { |sender,e|
}
# Set up various data related to the new map
Events.onMapChange += proc { |sender,e|
Events.onMapChange += proc { |_sender,e|
oldid = e[0] # previous map ID, 0 if no map ID
healing = pbGetMetadata($game_map.map_id,MetadataHealingSpot)
$PokemonGlobal.healingSpot = healing if healing
@@ -430,18 +429,12 @@ Events.onMapChange += proc { |sender,e|
end
}
Events.onMapSceneChange += proc { |sender,e|
Events.onMapSceneChange += proc { |_sender,e|
scene = e[0]
mapChanged = e[1]
next if !scene || !scene.spriteset
# Update map trail
if $game_map
lastmapdetails = $PokemonGlobal.mapTrail[0] ?
pbGetMetadata($PokemonGlobal.mapTrail[0],MetadataMapPosition) : [-1,0,0]
lastmapdetails = [-1,0,0] if !lastmapdetails
newmapdetails = $game_map.map_id ?
pbGetMetadata($game_map.map_id,MetadataMapPosition) : [-1,0,0]
newmapdetails = [-1,0,0] if !newmapdetails
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
if $PokemonGlobal.mapTrail[0]!=$game_map.map_id
$PokemonGlobal.mapTrail[3] = $PokemonGlobal.mapTrail[2] if $PokemonGlobal.mapTrail[2]
@@ -556,7 +549,8 @@ def pbMoveRoute(event,commands,waitComplete=false)
route.skippable = true
route.list.clear
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn))
i=0; while i<commands.length
i=0
while i<commands.length
case commands[i]
when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff,
PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity,
@@ -600,7 +594,7 @@ end
#===============================================================================
# Player/event movement in the field
#===============================================================================
def pbLedge(xOffset,yOffset)
def pbLedge(_xOffset,_yOffset)
if PBTerrain.isLedge?(pbFacingTerrainTag)
if pbJumpToward(2,true)
$scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1)
@@ -914,7 +908,7 @@ def pbEventFacesPlayer?(event,player,distance)
curx = event.x
cury = event.y
found = false
for i in 0...distance
distance.times do
curx += deltaX
cury += deltaY
if player.x==curx && player.y==cury
@@ -936,7 +930,7 @@ def pbEventCanReachPlayer?(event,player,distance)
cury = event.y
found = false
realdist = 0
for i in 0...distance
distance.times do
curx += deltaX
cury += deltaY
if player.x==curx && player.y==cury
@@ -949,7 +943,7 @@ def pbEventCanReachPlayer?(event,player,distance)
# Check passibility
curx = event.x
cury = event.y
for i in 0...realdist
realdist.times do
return false if !event.passable?(curx,cury,event.direction)
curx += deltaX
cury += deltaY
@@ -1059,11 +1053,12 @@ module InterpreterFieldMixin
$PokemonMap.addMovedEvent(@event_id) if $PokemonMap
if oldx!=event.x || oldy!=event.y
$game_player.lock
begin
loop do
Graphics.update
Input.update
pbUpdateSceneMap
end until !event.moving?
break if !event.moving?
end
$game_player.unlock
end
end

View File

@@ -200,7 +200,7 @@ end
Events.onSpritesetCreate += proc { |sender,e|
Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0] # Spriteset being created
viewport = e[1] # Viewport used for tilemap and characters
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
@@ -241,7 +241,6 @@ end
def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
$game_temp.in_battle = true
handled = false
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
# Set up audio

View File

@@ -134,7 +134,7 @@ module RPG
@blizzardBitmap2.fill_rect(0,4,10,2,snowColor)
@blizzardBitmap2.fill_rect(2,6,6,2,snowColor)
@blizzardBitmap2.fill_rect(4,8,2,2,snowColor)
for i in 0...540
540.times do
@blizzardBitmap3.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor)
@blizzardBitmap4.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor)
end
@@ -163,7 +163,7 @@ module RPG
bmHeight = 200
@sandstormBitmap1 = Bitmap.new(bmWidth,bmHeight)
@sandstormBitmap2 = Bitmap.new(bmWidth,bmHeight)
for i in 0...540
540.times do
@sandstormBitmap1.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,
sandstormColors[rand(sandstormColors.length)])
@sandstormBitmap2.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,

View File

@@ -43,7 +43,7 @@ class PokemonGlobalMetadata
# Events
attr_accessor :eventvars
# Affecting the map
attr_accessor :bridge
attr_writer :bridge
attr_accessor :repel
attr_accessor :flashUsed
# Map transfers

View File

@@ -189,7 +189,7 @@ def pbGetEnvironment
return ret
end
Events.onStartBattle += proc { |sender|
Events.onStartBattle += proc { |_sender|
# Record current levels of Pokémon in party, to see if they gain a level
# during battle and may need to evolve afterwards
$PokemonTemp.evolutionLevels = []
@@ -555,7 +555,7 @@ def pbAfterBattle(decision,canLose)
Events.onEndBattle.trigger(nil,decision,canLose)
end
Events.onEndBattle += proc { |sender,e|
Events.onEndBattle += proc { |_sender,e|
decision = e[0]
canLose = e[1]
if NEWEST_BATTLE_MECHANICS || (decision!=2 && decision!=5) # not a loss or a draw

View File

@@ -420,7 +420,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
end
# Shiny Charm makes shiny Pokémon more likely to generate
if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
for i in 0...2 # 3 times as likely
2.times do # 3 times as likely
break if genwildpoke.shiny?
genwildpoke.personalID = rand(65536)|(rand(65536)<<16)
end
@@ -454,7 +454,6 @@ def pbEncounter(enctype)
encounter1 = $PokemonEncounters.pbEncounteredPokemon(enctype)
encounter1 = EncounterModifier.trigger(encounter1)
return false if !encounter1
encounter2 = nil
if $PokemonGlobal.partner
encounter2 = $PokemonEncounters.pbEncounteredPokemon(enctype)
encounter2 = EncounterModifier.trigger(encounter2)

View File

@@ -6,7 +6,7 @@
################################################################################
# Make all wild Pokémon shiny while a certain Switch is ON (see Settings).
Events.onWildPokemonCreate += proc { |sender,e|
Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0]
if $game_switches[SHINY_WILD_POKEMON_SWITCH]
pokemon.makeShiny
@@ -17,14 +17,14 @@ Events.onWildPokemonCreate += proc { |sender,e|
# map depend on the levels of Pokémon in the player's party.
# This is a simple method, and can/should be modified to account for evolutions
# and other such details. Of course, you don't HAVE to use this code.
Events.onWildPokemonCreate += proc { |sender,e|
Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0]
if $game_map.map_id==51
mLevel = PBExperience.maxLevel
newlevel = pbBalancedLevel($Trainer.party) - 4 + rand(5) # For variety
newlevel = 1 if newlevel<1
newlevel = mLevel if newlevel>mLevel
pokemon.level = newlevel
if $game_map.map_id == 51
max_level = PBExperience.maxLevel
new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5) # For variety
new_level = 1 if new_level < 1
new_level = max_level if new_level > max_level
pokemon.level = new_level
pokemon.calcStats
pokemon.resetMoves
end
@@ -35,7 +35,7 @@ Events.onWildPokemonCreate += proc { |sender,e|
# Note that you can only modify a partner trainer's Pokémon, and not the trainer
# themselves nor their items this way, as those are generated from scratch
# before each battle.
#Events.onTrainerPartyLoad += proc { |sender,e|
#Events.onTrainerPartyLoad += proc { |_sender, e|
# if e[0] # Trainer data should exist to be loaded, but may not exist somehow
# trainer = e[0][0] # A PokeBattle_Trainer object of the loaded trainer
# items = e[0][1] # An array of the trainer's items they can use

View File

@@ -3,11 +3,10 @@ class PokemonGlobalMetadata
attr_accessor :roamedAlready # Whether a roamer has been encountered on current map
attr_accessor :roamEncounter
attr_accessor :roamPokemon
attr_accessor :roamPokemonCaught
attr_writer :roamPokemonCaught
def roamPokemonCaught
@roamPokemonCaught = [] if !@roamPokemonCaught
return @roamPokemonCaught
return @roamPokemonCaught || []
end
end
@@ -97,7 +96,7 @@ end
# When the player moves to a new map (with a different name), make all roaming
# Pokémon roam.
Events.onMapChange += proc { |sender,e|
Events.onMapChange += proc { |_sender,e|
oldMapID = e[0]
# Get and compare map names
mapInfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
@@ -206,7 +205,7 @@ EncounterModifier.register(proc { |encounter|
next [chosenRoamer[1],chosenRoamer[2]] # Species, level
})
Events.onWildBattleOverride += proc { |sender,e|
Events.onWildBattleOverride += proc { |_sender,e|
species = e[0]
level = e[1]
handled = e[2]

View File

@@ -19,20 +19,17 @@ class AntiRandom
# Get old value
value=rand(@old.length)
return @old[value]
else
if @new.length>0
# Get new value
value=rand(@new.length)
ret=@new.delete_at(value)
@old.push(ret)
return ret
else
# Get old value
value=rand(@old.length)
return @old[value]
end
end
return 0
if @new.length>0
# Get new value
value=rand(@new.length)
ret=@new.delete_at(value)
@old.push(ret)
return ret
end
# Get old value
value=rand(@old.length)
return @old[value]
end
end
@@ -310,7 +307,7 @@ class Maze
def buildMazeWall(x,y,dir,len)
wx=x;wy=y
return if isBlockedNode?(x,y)
for c in 0...len
len.times do
ox=wx;oy=wy
wy-=1 if dir==EdgeMasks::North
wx-=1 if dir==EdgeMasks::West
@@ -341,7 +338,6 @@ class Maze
def recurseDepthFirst(x,y,depth)
setVisited(x,y)
dirs=@@dirs.shuffle!
success=0
for c in 0...4
d=dirs[c]
cx=0;cy=0
@@ -543,7 +539,7 @@ end
def pbRandomRoomTile(dungeon,tiles)
ar1=AntiRandom.new(dungeon.width)
ar2=AntiRandom.new(dungeon.height)
for i in 0...(tiles.length+1)*1000
((tiles.length+1)*1000).times do
x=ar1.get()
y=ar2.get()
if dungeon.isRoom?(x,y) &&
@@ -556,10 +552,9 @@ def pbRandomRoomTile(dungeon,tiles)
return nil
end
Events.onMapCreate += proc { |sender, e|
Events.onMapCreate += proc { |_sender, e|
mapID=e[0]
map=e[1]
tileset=e[2]
if pbGetMetadata(mapID,MetadataDungeon)
# this map is a randomly generated dungeon
dungeon=Dungeon.new(map.width,map.height)

View File

@@ -104,7 +104,7 @@ def pbHiddenMoveAnimation(pokemon)
phase=1
frames=0
strobeSpeed = 64*20/Graphics.frame_rate
begin
loop do
Graphics.update
Input.update
sprite.update
@@ -176,7 +176,8 @@ def pbHiddenMoveAnimation(pokemon)
end
end
pbUpdateSceneMap
end while phase!=6
break if phase==6
end
sprite.dispose
for strobe in strobes
strobe.dispose
@@ -380,7 +381,7 @@ def pbTransferUnderwater(mapid,x,y,direction=$game_player.direction)
}
end
Events.onAction += proc { |sender,e|
Events.onAction += proc { |_sender,_e|
if $PokemonGlobal.diving
if DIVING_SURFACE_ANYWHERE
pbSurfacing
@@ -673,7 +674,7 @@ def pbStrength
return false
end
Events.onAction += proc { |sender,e|
Events.onAction += proc { |_sender,_e|
facingEvent = $game_player.pbFacingEvent
pbStrength if facingEvent && facingEvent.name.downcase=="boulder"
}
@@ -733,7 +734,7 @@ def pbStartSurfing
$game_player.check_event_trigger_here([1,2])
end
def pbEndSurf(xOffset,yOffset)
def pbEndSurf(_xOffset,_yOffset)
return false if !$PokemonGlobal.surfing
x = $game_player.x
y = $game_player.y
@@ -765,7 +766,7 @@ def pbTransferSurfing(mapid,xcoord,ycoord,direction=$game_player.direction)
}
end
Events.onAction += proc { |sender,e|
Events.onAction += proc { |_sender,_e|
next if $PokemonGlobal.surfing
next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
next if !PBTerrain.isSurfable?(pbFacingTerrainTag)
@@ -825,7 +826,7 @@ def pbSweetScent
viewport.color.blue = 0
viewport.color.alpha -= 10
alphaDiff = 12 * 20 / Graphics.frame_rate
begin
loop do
if count==0 && viewport.color.alpha<128
viewport.color.alpha += alphaDiff
elsif count>Graphics.frame_rate/4
@@ -836,9 +837,9 @@ def pbSweetScent
Graphics.update
Input.update
pbUpdateSceneMap
end until viewport.color.alpha<=0
break if viewport.color.alpha<=0
end
viewport.dispose
encounter = nil
enctype = $PokemonEncounters.pbEncounterType
if enctype<0 || !$PokemonEncounters.isEncounterPossibleHere? ||
!pbEncounter(enctype)
@@ -969,7 +970,7 @@ def pbWaterfall
return false
end
Events.onAction += proc { |sender,e|
Events.onAction += proc { |_sender,_e|
terrain = pbFacingTerrainTag
if terrain==PBTerrain::Waterfall
pbWaterfall

View File

@@ -28,7 +28,7 @@ def pbClearData
__berryPlant__pbClearData
end
Events.onSpritesetCreate += proc { |sender,e|
Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0]
viewport = e[1]
map = spriteset.map
@@ -105,7 +105,7 @@ end
class BerryPlantSprite
REPLANTS = 9
def initialize(event,map,viewport)
def initialize(event,map,_viewport)
@event=event
@map=map
@oldstage=0

View File

@@ -321,7 +321,7 @@ def pbDayCareGenerateEgg
ivinherit[i] = PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET)
end
num = 0; r = rand(2)
for i in 0...2
2.times do
if ivinherit[r]!=nil
parent = [mother,father][r]
ivs[ivinherit[r]] = parent.iv[ivinherit[r]]
@@ -355,7 +355,7 @@ def pbDayCareGenerateEgg
shinyretries += 5 if father.language!=mother.language
shinyretries += 2 if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
if shinyretries>0
for i in 0...shinyretries
shinyretries.times do
break if egg.shiny?
egg.personalID = rand(65536)|(rand(65536)<<16)
end
@@ -410,7 +410,7 @@ end
#===============================================================================
# Code that happens every step the player takes.
#===============================================================================
Events.onStepTaken += proc { |sender,e|
Events.onStepTaken += proc { |_sender,_e|
# Make an egg available at the Day Care
deposited = pbDayCareDeposited
if deposited==2 && $PokemonGlobal.daycareEgg==0

View File

@@ -1,5 +1,5 @@
class PokemonTemp
attr_accessor :dependentEvents
attr_writer :dependentEvents
def dependentEvents
@dependentEvents=DependentEvents.new if !@dependentEvents
@@ -38,11 +38,10 @@ end
class PokemonGlobalMetadata
attr_accessor :dependentEvents
attr_writer :dependentEvents
def dependentEvents
@dependentEvents=[] if !@dependentEvents
return @dependentEvents
return @dependentEvents || []
end
end
@@ -56,7 +55,7 @@ end
def pbTestPass(follower,x,y,direction=nil)
def pbTestPass(follower,x,y,_direction=nil)
return $MapFactory.isPassableStrict?(follower.map.map_id,x,y,follower)
end
@@ -176,7 +175,6 @@ class DependentEvents
def pbEnsureEvent(event, newMapID)
events=$PokemonGlobal.dependentEvents
found=-1
for i in 0...events.length
# Check original map ID and original event ID
if events[i][0]==event.map_id && events[i][1]==event.id
@@ -552,15 +550,14 @@ end
Events.onSpritesetCreate += proc { |sender,e|
Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0] # Spriteset being created
viewport = e[1] # Viewport used for tilemap and characters
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
spriteset.addUserSprite(DependentEventSprites.new(viewport,map))
}
Events.onMapSceneChange += proc { |sender,e|
scene = e[0]
Events.onMapSceneChange += proc { |_sender,e|
mapChanged = e[1]
if mapChanged
$PokemonTemp.dependentEvents.pbMapChangeMoveDependentEvents

View File

@@ -72,7 +72,7 @@ module PBDayNight
def self.getShade
time = pbGetDayNightMinutes
time = (24*60)-time if time>(12*60)
shade=255*time/(12*60)
return 255*time/(12*60)
end
# Gets a Tone object representing a suggested shading
@@ -97,7 +97,7 @@ module PBDayNight
# Internal function
def self.getToneInternal
def getToneInternal
# Calculates the tone for the current frame, used for day/night effects
realMinutes = pbGetDayNightMinutes
hour = realMinutes/60