More Rubocop

This commit is contained in:
Maruno17
2021-12-27 00:26:45 +00:00
parent 4a6324389b
commit aa643a6049
51 changed files with 346 additions and 323 deletions

View File

@@ -8,7 +8,7 @@ class Sprite_Reflection
@event = event
@height = 0
@fixedheight = false
if @event != $game_player && @event&.name[/reflection\((\d+)\)/i]
if @event && @event != $game_player && @event.name[/reflection\((\d+)\)/i]
@height = $~[1].to_i || 0
@fixedheight = true
end

View File

@@ -1,38 +1,38 @@
class PictureOrigin
TopLeft = 0
Center = 1
TopRight = 2
BottomLeft = 3
LowerLeft = 3
BottomRight = 4
LowerRight = 4
Top = 5
Bottom = 6
Left = 7
Right = 8
TOP_LEFT = 0
CENTER = 1
TOP_RIGHT = 2
BOTTOM_LEFT = 3
LOWER_LEFT = 3
BOTTOM_RIGHT = 4
LOWER_RIGHT = 4
TOP = 5
BOTTOM = 6
LEFT = 7
RIGHT = 8
end
class Processes
XY = 0
DeltaXY = 1
Z = 2
Curve = 3
Zoom = 4
Angle = 5
Tone = 6
Color = 7
Hue = 8
Opacity = 9
Visible = 10
BlendType = 11
SE = 12
Name = 13
Origin = 14
Src = 15
SrcSize = 16
CropBottom = 17
XY = 0
DELTA_XY = 1
Z = 2
CURVE = 3
ZOOM = 4
ANGLE = 5
TONE = 6
COLOR = 7
HUE = 8
OPACITY = 9
VISIBLE = 10
BLEND_TYPE = 11
SE = 12
NAME = 13
ORIGIN = 14
SRC = 15
SRC_SIZE = 16
CROP_BOTTOM = 17
end
@@ -114,7 +114,7 @@ class PictureEx
@visible = true
@blend_type = 0
@name = ""
@origin = PictureOrigin::TopLeft
@origin = PictureOrigin::TOP_LEFT
@src_rect = Rect.new(0, 0, -1, -1)
@cropBottom = -1
@frameUpdates = []
@@ -213,12 +213,12 @@ class PictureEx
def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Curve, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
@processes.push([Processes::CURVE, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
end
def moveDelta(delay, duration, x, y, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::DeltaXY, delay, duration, 0, cb, @x, @y, x, y])
@processes.push([Processes::DELTA_XY, delay, duration, 0, cb, @x, @y, x, y])
end
def setDelta(delay, x, y, cb = nil)
@@ -236,7 +236,7 @@ class PictureEx
def moveZoomXY(delay, duration, zoom_x, zoom_y, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Zoom, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
@processes.push([Processes::ZOOM, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
end
def setZoomXY(delay, zoom_x, zoom_y, cb = nil)
@@ -253,7 +253,7 @@ class PictureEx
def moveAngle(delay, duration, angle, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Angle, delay, duration, 0, cb, @angle, angle])
@processes.push([Processes::ANGLE, delay, duration, 0, cb, @angle, angle])
end
def setAngle(delay, angle, cb = nil)
@@ -263,7 +263,7 @@ class PictureEx
def moveTone(delay, duration, tone, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
target = (tone) ? tone.clone : Tone.new(0, 0, 0, 0)
@processes.push([Processes::Tone, delay, duration, 0, cb, @tone.clone, target])
@processes.push([Processes::TONE, delay, duration, 0, cb, @tone.clone, target])
end
def setTone(delay, tone, cb = nil)
@@ -273,7 +273,7 @@ class PictureEx
def moveColor(delay, duration, color, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
target = (color) ? color.clone : Color.new(0, 0, 0, 0)
@processes.push([Processes::Color, delay, duration, 0, cb, @color.clone, target])
@processes.push([Processes::COLOR, delay, duration, 0, cb, @color.clone, target])
end
def setColor(delay, color, cb = nil)
@@ -283,7 +283,7 @@ class PictureEx
# Hue changes don't actually work.
def moveHue(delay, duration, hue, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Hue, delay, duration, 0, cb, @hue, hue])
@processes.push([Processes::HUE, delay, duration, 0, cb, @hue, hue])
end
# Hue changes don't actually work.
@@ -293,7 +293,7 @@ class PictureEx
def moveOpacity(delay, duration, opacity, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Opacity, delay, duration, 0, cb, @opacity, opacity])
@processes.push([Processes::OPACITY, delay, duration, 0, cb, @opacity, opacity])
end
def setOpacity(delay, opacity, cb = nil)
@@ -302,13 +302,13 @@ class PictureEx
def setVisible(delay, visible, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Visible, delay, 0, 0, cb, visible])
@processes.push([Processes::VISIBLE, delay, 0, 0, cb, visible])
end
# Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed.
def setBlendType(delay, blend, cb = nil)
delay = ensureDelayAndDuration(delay)
@processes.push([Processes::BlendType, delay, 0, 0, cb, blend])
@processes.push([Processes::BLEND_TYPE, delay, 0, 0, cb, blend])
end
def setSE(delay, seFile, volume = nil, pitch = nil, cb = nil)
@@ -318,28 +318,28 @@ class PictureEx
def setName(delay, name, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Name, delay, 0, 0, cb, name])
@processes.push([Processes::NAME, delay, 0, 0, cb, name])
end
def setOrigin(delay, origin, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Origin, delay, 0, 0, cb, origin])
@processes.push([Processes::ORIGIN, delay, 0, 0, cb, origin])
end
def setSrc(delay, srcX, srcY, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Src, delay, 0, 0, cb, srcX, srcY])
@processes.push([Processes::SRC, delay, 0, 0, cb, srcX, srcY])
end
def setSrcSize(delay, srcWidth, srcHeight, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::SrcSize, delay, 0, 0, cb, srcWidth, srcHeight])
@processes.push([Processes::SRC_SIZE, delay, 0, 0, cb, srcWidth, srcHeight])
end
# Used to cut Pokémon sprites off when they faint and sink into the ground.
def setCropBottom(delay, y, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::CropBottom, delay, 0, 0, cb, y])
@processes.push([Processes::CROP_BOTTOM, delay, 0, 0, cb, y])
end
def update
@@ -354,28 +354,28 @@ class PictureEx
when Processes::XY
process[5] = @x
process[6] = @y
when Processes::DeltaXY
when Processes::DELTA_XY
process[5] = @x
process[6] = @y
process[7] += @x
process[8] += @y
when Processes::Curve
when Processes::CURVE
process[5][0] = @x
process[5][1] = @y
when Processes::Z
process[5] = @z
when Processes::Zoom
when Processes::ZOOM
process[5] = @zoom_x
process[6] = @zoom_y
when Processes::Angle
when Processes::ANGLE
process[5] = @angle
when Processes::Tone
when Processes::TONE
process[5] = @tone.clone
when Processes::Color
when Processes::COLOR
process[5] = @color.clone
when Processes::Hue
when Processes::HUE
process[5] = @hue
when Processes::Opacity
when Processes::OPACITY
process[5] = @opacity
end
end
@@ -389,49 +389,49 @@ class PictureEx
fra = (process[2] == 0) ? 1 : process[3] # Frame counter
dur = (process[2] == 0) ? 1 : process[2] # Total duration of process
case process[0]
when Processes::XY, Processes::DeltaXY
when Processes::XY, Processes::DELTA_XY
@x = process[5] + (fra * (process[7] - process[5]) / dur)
@y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Curve
when Processes::CURVE
@x, @y = getCubicPoint2(process[5], fra.to_f / dur)
when Processes::Z
@z = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Zoom
when Processes::ZOOM
@zoom_x = process[5] + (fra * (process[7] - process[5]) / dur)
@zoom_y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Angle
when Processes::ANGLE
@angle = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Tone
when Processes::TONE
@tone.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@tone.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@tone.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@tone.gray = process[5].gray + (fra * (process[6].gray - process[5].gray) / dur)
when Processes::Color
when Processes::COLOR
@color.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@color.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@color.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@color.alpha = process[5].alpha + (fra * (process[6].alpha - process[5].alpha) / dur)
when Processes::Hue
when Processes::HUE
@hue = (process[6] - process[5]).to_f / dur
when Processes::Opacity
when Processes::OPACITY
@opacity = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Visible
when Processes::VISIBLE
@visible = process[5]
when Processes::BlendType
when Processes::BLEND_TYPE
@blend_type = process[5]
when Processes::SE
pbSEPlay(process[5], process[6], process[7])
when Processes::Name
when Processes::NAME
@name = process[5]
when Processes::Origin
when Processes::ORIGIN
@origin = process[5]
when Processes::Src
when Processes::SRC
@src_rect.x = process[5]
@src_rect.y = process[6]
when Processes::SrcSize
when Processes::SRC_SIZE
@src_rect.width = process[5]
@src_rect.height = process[6]
when Processes::CropBottom
when Processes::CROP_BOTTOM
@cropBottom = process[5]
end
# Increase frame counter
@@ -447,7 +447,7 @@ class PictureEx
@processes.compact! if procEnded
# Add the constant rotation speed
if @rotate_speed != 0
@frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle)
@frameUpdates.push(Processes::ANGLE) if !@frameUpdates.include?(Processes::ANGLE)
@angle += @rotate_speed
while @angle < 0
@angle += 360
@@ -466,52 +466,52 @@ def setPictureSprite(sprite, picture, iconSprite = false)
return if picture.frameUpdates.length == 0
picture.frameUpdates.each do |type|
case type
when Processes::XY, Processes::DeltaXY
when Processes::XY, Processes::DELTA_XY
sprite.x = picture.x.round
sprite.y = picture.y.round
when Processes::Z
sprite.z = picture.z
when Processes::Zoom
when Processes::ZOOM
sprite.zoom_x = picture.zoom_x / 100.0
sprite.zoom_y = picture.zoom_y / 100.0
when Processes::Angle
when Processes::ANGLE
sprite.angle = picture.angle
when Processes::Tone
when Processes::TONE
sprite.tone = picture.tone
when Processes::Color
when Processes::COLOR
sprite.color = picture.color
when Processes::Hue
when Processes::HUE
# This doesn't do anything.
when Processes::BlendType
when Processes::BLEND_TYPE
sprite.blend_type = picture.blend_type
when Processes::Opacity
when Processes::OPACITY
sprite.opacity = picture.opacity
when Processes::Visible
when Processes::VISIBLE
sprite.visible = picture.visible
when Processes::Name
when Processes::NAME
sprite.name = picture.name if iconSprite && sprite.name != picture.name
when Processes::Origin
when Processes::ORIGIN
case picture.origin
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
sprite.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width / 2 : 0
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0
end
case picture.origin
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
sprite.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height / 2 : 0
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0
end
when Processes::Src
when Processes::SRC
next unless iconSprite && sprite.src_rect
sprite.src_rect.x = picture.src_rect.x
sprite.src_rect.y = picture.src_rect.y
when Processes::SrcSize
when Processes::SRC_SIZE
next unless iconSprite && sprite.src_rect
sprite.src_rect.width = picture.src_rect.width
sprite.src_rect.height = picture.src_rect.height