More Rubocopping

This commit is contained in:
Maruno17
2021-12-20 17:18:21 +00:00
parent db4acd3369
commit 33fcbf623b
154 changed files with 1388 additions and 1420 deletions

View File

@@ -106,7 +106,7 @@ class PokemonDuel
else
num = rand(total)
cumtotal = 0
for i in 0...4
4.times do |i|
cumtotal += scores[i]
if num < cumtotal
action = i
@@ -385,7 +385,7 @@ def pbDuel(trainer_id, trainer_name, event, speeches)
pbGetMessageFromHash(MessageTypes::TrainerNames, trainer_name), trainer_id
)
speech_texts = []
for i in 0...12
12.times do |i|
speech_texts.push(_I(speeches[i]))
end
duel.pbDuel(opponent, event, speech_texts)

View File

@@ -172,7 +172,7 @@ class TriadScene
@sprites["helpwindow"] = Window_AdvancedTextPokemon.newWithSize(
"", 0, Graphics.height - 64, Graphics.width, 64, @viewport
)
for i in 0...@battle.width * @battle.height
(@battle.width * @battle.height).times do |i|
@sprites["sprite#{i}"] = SpriteWrapper.new(@viewport)
@sprites["sprite#{i}"].x = (Graphics.width / 2) - 118 + ((i % 3) * 78)
@sprites["sprite#{i}"].y = 36 + ((i / 3) * 94)
@@ -187,7 +187,7 @@ class TriadScene
@opponentCardIndexes = []
@boardSprites = []
@boardCards = []
for i in 0...@battle.maxCards
@battle.maxCards.times do |i|
@sprites["player#{i}"] = Sprite.new(@viewport)
@sprites["player#{i}"].x = Graphics.width - 92
@sprites["player#{i}"].y = 44 + (44 * i)
@@ -258,7 +258,7 @@ class TriadScene
def pbChooseTriadCard(cardStorage)
commands = []
chosenCards = []
for item in cardStorage
cardStorage.each do |item|
commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1]))
end
command = Window_CommandPokemonEx.newWithSize(commands, 0, 0, Graphics.width / 2, Graphics.height - 64, @viewport)
@@ -268,7 +268,7 @@ class TriadScene
preview.y = 60
preview.z = 4
index = -1
for i in 0...@battle.maxCards
@battle.maxCards.times do |i|
@sprites["player#{i}"] = Sprite.new(@viewport)
@sprites["player#{i}"].x = Graphics.width - 92
@sprites["player#{i}"].y = 44 + (44 * i)
@@ -292,7 +292,7 @@ class TriadScene
item = chosenCards.pop
@battle.pbAdd(cardStorage, item)
commands = []
for item in cardStorage
cardStorage.each do |item|
commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1]))
end
command.commands = commands
@@ -314,7 +314,7 @@ class TriadScene
chosenCards.push(item[0])
@battle.pbSubtract(cardStorage, item[0])
commands = []
for item in cardStorage
cardStorage.each do |item|
commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1]))
end
command.commands = commands
@@ -323,7 +323,7 @@ class TriadScene
end
end
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
for i in 0...@battle.maxCards
@battle.maxCards.times do |i|
@sprites["player#{i}"].visible = (i < chosenCards.length)
end
if chosenCards.length == @battle.maxCards
@@ -346,7 +346,7 @@ class TriadScene
end
def pbShowPlayerCards(cards)
for i in 0...@battle.maxCards
@battle.maxCards.times do |i|
@sprites["player#{i}"] = Sprite.new(@viewport)
@sprites["player#{i}"].x = Graphics.width - 92
@sprites["player#{i}"].y = 44 + (44 * i)
@@ -357,7 +357,7 @@ class TriadScene
end
def pbShowOpponentCards(cards)
for i in 0...@battle.maxCards
@battle.maxCards.times do |i|
@sprites["opponent#{i}"] = Sprite.new(@viewport)
@sprites["opponent#{i}"].x = 12
@sprites["opponent#{i}"].y = 44 + (44 * i)
@@ -375,7 +375,7 @@ class TriadScene
loop do
if lastChoice != choice
y = 44
for i in 0...@opponentCardIndexes.length
@opponentCardIndexes.length.times do |i|
@sprites["opponent#{@opponentCardIndexes[i]}"].bitmap = @opponentCardBitmaps[@opponentCardIndexes[i]]
@sprites["opponent#{@opponentCardIndexes[i]}"].x = (i == choice) ? 28 : 12
@sprites["opponent#{@opponentCardIndexes[i]}"].y = y
@@ -415,7 +415,7 @@ class TriadScene
loop do
if lastChoice != choice
y = 44
for i in 0...@cardIndexes.length
@cardIndexes.length.times do |i|
@sprites["player#{@cardIndexes[i]}"].bitmap = @cardBitmaps[@cardIndexes[i]]
@sprites["player#{@cardIndexes[i]}"].x = (i == choice) ? Graphics.width - 108 : Graphics.width - 92
@sprites["player#{@cardIndexes[i]}"].y = y
@@ -457,7 +457,7 @@ class TriadScene
loop do
if doRefresh
y = 44
for i in 0...@cardIndexes.length
@cardIndexes.length.times do |i|
if i == cardIndex # Card being placed
@sprites["player#{@cardIndexes[i]}"].x = (Graphics.width / 2) - 118 + (boardX * 78)
@sprites["player#{@cardIndexes[i]}"].y = 36 + (boardY * 94)
@@ -521,7 +521,7 @@ class TriadScene
def pbOpponentPlaceCard(triadCard, position, cardIndex)
y = 44
for i in 0...@opponentCardIndexes.length
@opponentCardIndexes.length.times do |i|
sprite = @sprites["opponent#{@opponentCardIndexes[i]}"]
if i == cardIndex
@opponentCardBitmaps[@opponentCardIndexes[i]] = triadCard.createBitmap(2)
@@ -550,7 +550,7 @@ class TriadScene
end
def pbRefresh
for i in 0...@battle.width * @battle.height
(@battle.width * @battle.height).times do |i|
x = i % @battle.width
y = i / @battle.width
if @boardSprites[i]
@@ -566,7 +566,7 @@ class TriadScene
bitmap.clear
playerscore = 0
oppscore = 0
for i in 0...@battle.width * @battle.height
(@battle.width * @battle.height).times do |i|
if @boardSprites[i]
playerscore += 1 if @battle.board[i].owner == 1
oppscore += 1 if @battle.board[i].owner == 2
@@ -657,7 +657,7 @@ class TriadScreen
flips = []
return nil if attackerParam != nil && @board[(y * @width) + x].owner != 0
return nil if !attacker.card || attacker.owner == 0
for i in 0...4
4.times do |i|
defenderX = panels[i * 2]
defenderY = panels[(i * 2) + 1]
defender = @board[(defenderY * @width) + defenderX]
@@ -705,7 +705,7 @@ class TriadScreen
raise _INTL("Maximum level must be 0 through 9.") if maxLevel < 0 || maxLevel > 9
raise _INTL("Maximum level shouldn't be less than the minimum level.") if maxLevel < minLevel
if rules && rules.is_a?(Array) && rules.length > 0
for rule in rules
rules.each do |rule|
@sameWins = true if rule == "samewins"
@openHand = true if rule == "openhand"
@wrapAround = true if rule == "wrap"
@@ -719,7 +719,7 @@ class TriadScreen
end
@triadCards = []
count = 0
for i in 0...$PokemonGlobal.triads.length
$PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i]
ItemStorageHelper.add(@triadCards, $PokemonGlobal.triads.maxSize,
TriadStorage::MAX_PER_SLOT, item[0], item[1])
@@ -729,7 +729,7 @@ class TriadScreen
@playerName = $player ? $player.name : "Trainer"
@opponentName = opponentName
type_keys = GameData::Type.keys
for i in 0...@width * @height
(@width * @height).times do |i|
square = TriadSquare.new
if @elements
loop do
@@ -764,7 +764,7 @@ class TriadScreen
# Set the opponent's cards.
if oppdeck && oppdeck.is_a?(Array) && oppdeck.length == self.maxCards # Preset
opponentCards = []
for i in oppdeck
oppdeck.each do |i|
species_data = GameData::Species.try_get(i)
if !species_data
@scene.pbDisplayPaused(_INTL("Opponent has an illegal card, \"{1}\".", i))
@@ -806,7 +806,7 @@ class TriadScreen
@scene.pbUpdateScore
playerTurn = (rand(2) == 0)
@scene.pbDisplay(_INTL("{1} will go first.", (playerTurn) ? @playerName : @opponentName))
for i in 0...@width * @height
(@width * @height).times do |i|
position = nil
triadCard = nil
cardIndex = 0
@@ -821,11 +821,11 @@ class TriadScreen
# Opponent's turn
@scene.pbDisplay(_INTL("{1} is making a move...", @opponentName))
scores = []
for cardIndex in 0...opponentCards.length
opponentCards.length.times do |cardIndex|
square = TriadSquare.new
square.card = TriadCard.new(opponentCards[cardIndex])
square.owner = 2
for i in 0...@width * @height
(@width * @height).times do |i|
x = i % @width
y = i / @width
square.type = @board[i].type
@@ -865,7 +865,7 @@ class TriadScreen
# Determine the winner
playerCount = 0
opponentCount = 0
for i in 0...@width * @height
(@width * @height).times do |i|
playerCount += 1 if board[i].owner == 1
opponentCount += 1 if board[i].owner == 2
end
@@ -879,13 +879,13 @@ class TriadScreen
result = 3
if @trade == 1
# Keep only cards of your color
for card in originalCards
originalCards.each do |card|
$PokemonGlobal.triads.remove(card)
end
for i in cards
cards.each do |i|
$PokemonGlobal.triads.add(i)
end
for i in 0...@width * @height
(@width * @height).times do |i|
if board[i].owner == 1
card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id
$PokemonGlobal.triads.add(card)
@@ -910,13 +910,13 @@ class TriadScreen
@scene.pbDisplayPaused(_INTL("Got opponent's {1} card.", cardname))
end
when 1 # Keep only cards of your color
for card in originalCards
originalCards.each do |card|
$PokemonGlobal.triads.remove(card)
end
for i in cards
cards.each do |i|
$PokemonGlobal.triads.add(i)
end
for i in 0...@width * @height
(@width * @height).times do |i|
if board[i].owner == 1
card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id
$PokemonGlobal.triads.add(card)
@@ -924,7 +924,7 @@ class TriadScreen
end
@scene.pbDisplayPaused(_INTL("Kept all cards of your color."))
when 2 # Gain all opponent's cards
for card in originalOpponentCards
originalOpponentCards.each do |card|
$PokemonGlobal.triads.add(card)
end
@scene.pbDisplayPaused(_INTL("Got all opponent's cards."))
@@ -940,13 +940,13 @@ class TriadScreen
cardname = GameData::Species.get(card).name
@scene.pbDisplayPaused(_INTL("Opponent won your {1} card.", cardname))
when 1 # Keep only cards of your color
for card in originalCards
originalCards.each do |card|
$PokemonGlobal.triads.remove(card)
end
for i in cards
cards.each do |i|
$PokemonGlobal.triads.add(i)
end
for i in 0...@width * @height
(@width * @height).times do |i|
if board[i].owner == 1
card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id
$PokemonGlobal.triads.add(card)
@@ -954,7 +954,7 @@ class TriadScreen
end
@scene.pbDisplayPaused(_INTL("Kept all cards of your color.", cardname))
when 2 # Lose all your cards
for card in originalCards
originalCards.each do |card|
$PokemonGlobal.triads.remove(card)
end
@scene.pbDisplayPaused(_INTL("Opponent won all your cards."))
@@ -1071,7 +1071,7 @@ def pbBuyTriads
return
end
commands.sort! { |a, b| a[1] <=> b[1] } # Sort alphabetically
for command in commands
commands.each do |command|
realcommands.push(command[2])
end
# Scroll right before showing screen
@@ -1152,7 +1152,7 @@ end
def pbSellTriads
commands = []
for i in 0...$PokemonGlobal.triads.length
$PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i]
speciesname = GameData::Species.get(item[0]).name
commands.push(_INTL("{1} x{2}", speciesname, item[1]))
@@ -1234,7 +1234,7 @@ def pbSellTriads
$PokemonGlobal.triads.remove(item, quantity)
pbMessage(_INTL("Turned over the {1} card and received ${2}.\\se[Mart buy item]", itemname, price.to_s_formatted))
commands = []
for i in 0...$PokemonGlobal.triads.length
$PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i]
speciesname = GameData::Species.get(item[0]).name
commands.push(_INTL("{1} x{2}", speciesname, item[1]))
@@ -1258,7 +1258,7 @@ end
def pbTriadList
commands = []
for i in 0...$PokemonGlobal.triads.length
$PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i]
speciesname = GameData::Species.get(item[0]).name
commands.push(_INTL("{1} x{2}", speciesname, item[1]))

View File

@@ -23,7 +23,7 @@ class SlotMachineReel < BitmapSprite
@viewport.z = 99999
super(64, 144, @viewport)
@reel = []
for i in 0...ICONSPOOL[difficulty].length
ICONSPOOL[difficulty].length.times do |i|
@reel.push(ICONSPOOL[difficulty][i])
end
@reel.shuffle!
@@ -49,7 +49,7 @@ class SlotMachineReel < BitmapSprite
def showing
array = []
for i in 0...3
3.times do |i|
num = @index - i
num += @reel.length if num < 0
array.push(@reel[num])
@@ -70,7 +70,7 @@ class SlotMachineReel < BitmapSprite
@slipping -= 1 if @slipping > 0
end
end
for i in 0...4
4.times do |i|
num = @index - i
num += @reel.length if num < 0
self.bitmap.blt(0, @toppos + (i * 48), @images.bitmap, Rect.new(@reel[num] * 64, 0, 64, 48))
@@ -100,7 +100,7 @@ class SlotMachineScore < BitmapSprite
def refresh
self.bitmap.clear
for i in 0...5
5.times do |i|
digit = (@score / (10**i)) % 10 # Least significant digit first
self.bitmap.blt(14 * (4 - i), 0, @numbers.bitmap, Rect.new(digit * 14, 0, 14, 22))
end
@@ -133,7 +133,7 @@ class SlotMachineScene
[reel1[2], reel2[2], reel3[2]], # Bottom row
[reel1[0], reel2[1], reel3[2]], # Diagonal top left -> bottom right
[reel1[2], reel2[1], reel3[0]]] # Diagonal bottom left -> top right
for i in 0...combinations.length
combinations.length.times do |i|
break if i >= 1 && @wager <= 1 # One coin = centre row only
break if i >= 3 && @wager <= 2 # Two coins = three rows only
wonRow[i] = true
@@ -191,7 +191,7 @@ class SlotMachineScene
@sprites["light1"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26)
@sprites["light2"].visible = true
@sprites["light2"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26)
for i in 1..5
(1..5).each do |i|
if wonRow[i - 1]
@sprites["row#{i}"].visible = (frame / timePerFrame).even?
else
@@ -245,12 +245,12 @@ class SlotMachineScene
@sprites["reel1"] = SlotMachineReel.new(64, 112, difficulty)
@sprites["reel2"] = SlotMachineReel.new(144, 112, difficulty)
@sprites["reel3"] = SlotMachineReel.new(224, 112, difficulty)
for i in 1..3
(1..3).each do |i|
@sprites["button#{i}"] = IconSprite.new(68 + (80 * (i - 1)), 260, @viewport)
@sprites["button#{i}"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/button"))
@sprites["button#{i}"].visible = false
end
for i in 1..5
(1..5).each do |i|
y = [170, 122, 218, 82, 82][i - 1]
@sprites["row#{i}"] = IconSprite.new(2, y, @viewport)
@sprites["row#{i}"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/line%1d%s",
@@ -317,7 +317,7 @@ class SlotMachineScene
@sprites["button1"].visible = false
@sprites["button2"].visible = false
@sprites["button3"].visible = false
for i in 1..5
(1..5).each do |i|
@sprites["row#{i}"].visible = false
end
@gameEnd = false
@@ -345,7 +345,7 @@ class SlotMachineScene
(Input.trigger?(Input::USE) && @wager > 0) || @replay
if @replay
@wager = 3
for i in 1..5
(1..5).each do |i|
@sprites["row#{i}"].visible = true
end
end

View File

@@ -35,7 +35,7 @@ class VoltorbFlip
squareValues = []
total = 1
voltorbs = 0
for i in 0...25
25.times do |i|
# Sets the value to 1 by default
squareValues[i] = 1
# Sets the value to 0 (a voltorb) if # for that level hasn't been reached
@@ -54,7 +54,7 @@ class VoltorbFlip
end
end
# Randomize the values a little
for i in 0...25
25.times do |i|
temp = squareValues[i]
if squareValues[i] > 1
if rand(10) > 8
@@ -72,7 +72,7 @@ class VoltorbFlip
end
end
# Populate @squares array
for i in 0...25
25.times do |i|
x = i if i % 5 == 0
r = rand(squareValues.length)
@squares[i] = [((i - x).abs * 64) + 128, (i / 5).abs * 64, squareValues[r], false]
@@ -80,7 +80,7 @@ class VoltorbFlip
end
pbCreateSprites
# Display numbers (all zeroes, as no values have been calculated yet)
for i in 0...5
5.times do |i|
pbUpdateRowNumbers(0, 0, i)
pbUpdateColumnNumbers(0, 0, i)
end
@@ -122,12 +122,12 @@ class VoltorbFlip
@voltorbNumbers = []
@numbers = []
# Draw numbers for each row (precautionary)
for i in 0...@squares.length
@squares.length.times do |i|
if i % 5 == 0
num = 0
voltorbs = 0
j = i + 5
for k in i...j
(i...j).each do |k|
num += @squares[k][2]
if @squares[k][2] == 0
voltorbs += 1
@@ -140,10 +140,10 @@ class VoltorbFlip
@voltorbNumbers = []
@numbers = []
# Draw numbers for each column
for i in 0...5
5.times do |i|
num = 0
voltorbs = 0
for j in 0...5
5.times do |j|
num += @squares[i + (j * 5)][2]
if @squares[i + (j * 5)][2] == 0
voltorbs += 1
@@ -193,7 +193,7 @@ class VoltorbFlip
@sprites["currentCoins"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites["animation"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites["animation"].z = 99999
for i in 0...6
6.times do |i|
@sprites[i] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites[i].z = 99996
@sprites[i].visible = false
@@ -201,8 +201,8 @@ class VoltorbFlip
# Creates images ahead of time for the display-all animation (reduces lag)
icons = []
points = 0
for i in 0...3
for j in 0...25
3.times do |i|
25.times do |j|
points = @squares[j][2] if i == 2
icons[j] = [@directory + "tiles", @squares[j][0], @squares[j][1], 320 + (i * 64) + (points * 64), 0, 64, 64]
end
@@ -210,7 +210,7 @@ class VoltorbFlip
pbDrawImagePositions(@sprites[i].bitmap, icons)
end
icons = []
for i in 0...25
25.times do |i|
icons[i] = [@directory + "tiles", @squares[i][0], @squares[i][1], @squares[i][2] * 64, 0, 64, 64]
end
pbDrawImagePositions(@sprites[5].bitmap, icons)
@@ -257,12 +257,12 @@ class VoltorbFlip
end
elsif Input.trigger?(Input::USE)
if @cursor[0][3] == 64 # If in mark mode
for i in 0...@squares.length
@squares.length.times do |i|
if (@index[0] * 64) + 128 == @squares[i][0] && @index[1] * 64 == @squares[i][1] && @squares[i][3] == false
pbSEPlay("Voltorb Flip mark")
end
end
for i in 0...@marks.length + 1
(@marks.length + 1).times do |i|
if @marks[i] == nil
@marks[i] = [@directory + "tiles", (@index[0] * 64) + 128, @index[1] * 64, 256, 0, 64, 64]
elsif @marks[i][1] == (@index[0] * 64) + 128 && @marks[i][2] == @index[1] * 64
@@ -277,7 +277,7 @@ class VoltorbFlip
else
# Display the tile for the selected spot
icons = []
for i in 0...@squares.length
@squares.length.times do |i|
if (@index[0] * 64) + 128 == @squares[i][0] && @index[1] * 64 == @squares[i][1] && @squares[i][3] == false
pbAnimateTile((@index[0] * 64) + 128, @index[1] * 64, @squares[i][2])
@squares[i][3] = true
@@ -287,7 +287,7 @@ class VoltorbFlip
# Play explosion animation
# Part1
animation = []
for j in 0...3
3.times do |j|
animation[0] = icons[0] = [@directory + "tiles", (@index[0] * 64) + 128, @index[1] * 64, 704 + (64 * j), 0, 64, 64]
pbDrawImagePositions(@sprites["animation"].bitmap, animation)
pbWait(Graphics.frame_rate / 20)
@@ -295,7 +295,7 @@ class VoltorbFlip
end
# Part2
animation = []
for j in 0...6
6.times do |j|
animation[0] = [@directory + "explosion", (@index[0] * 64) - 32 + 128, (@index[1] * 64) - 32, j * 128, 0, 128, 128]
pbDrawImagePositions(@sprites["animation"].bitmap, animation)
pbWait(Graphics.frame_rate / 10)
@@ -308,7 +308,7 @@ class VoltorbFlip
if @level > 1
# Determine how many levels to reduce by
newLevel = 0
for j in 0...@squares.length
@squares.length.times do |j|
newLevel += 1 if @squares[j][3] == true && @squares[j][2] > 1
end
newLevel = @level if newLevel > @level
@@ -325,7 +325,7 @@ class VoltorbFlip
pbUpdateCoins
# Revert numbers to 0s
@sprites["numbers"].bitmap.clear
for i in 0...5
5.times do |i|
pbUpdateRowNumbers(0, 0, i)
pbUpdateColumnNumbers(0, 0, i)
end
@@ -335,7 +335,7 @@ class VoltorbFlip
else
# Play tile animation
animation = []
for j in 0...4
4.times do |j|
animation[0] = [@directory + "flipAnimation", (@index[0] * 64) - 14 + 128, (@index[1] * 64) - 16, j * 92, 0, 92, 96]
pbDrawImagePositions(@sprites["animation"].bitmap, animation)
pbWait(Graphics.frame_rate / 20)
@@ -354,7 +354,7 @@ class VoltorbFlip
end
end
count = 0
for i in 0...@squares.length
@squares.length.times do |i|
if @squares[i][3] == false && @squares[i][2] > 1
count += 1
end
@@ -379,7 +379,7 @@ class VoltorbFlip
pbShowAndDispose
# Revert numbers to 0s
@sprites["numbers"].bitmap.clear
for i in 0...5
5.times do |i|
pbUpdateRowNumbers(0, 0, i)
pbUpdateColumnNumbers(0, 0, i)
end
@@ -440,7 +440,7 @@ class VoltorbFlip
end
numText += num.to_s
numImages = numText.split(//)[0...2]
for j in 0...2
2.times do |j|
@numbers[j] = [@directory + "numbersSmall", 472 + (j * 16), (i * 64) + 8, numImages[j].to_i * 16, 0, 16, 16]
end
@voltorbNumbers[i] = [@directory + "numbersSmall", 488, (i * 64) + 34, voltorbs * 16, 0, 16, 16]
@@ -458,7 +458,7 @@ class VoltorbFlip
end
numText += num.to_s
numImages = numText.split(//)[0...2]
for j in 0...2
2.times do |j|
@numbers[j] = [@directory + "numbersSmall", (i * 64) + 152 + (j * 16), 328, numImages[j].to_i * 16, 0, 16, 16]
end
@voltorbNumbers[i] = [@directory + "numbersSmall", (i * 64) + 168, 354, voltorbs * 16, 0, 16, 16]
@@ -475,7 +475,7 @@ class VoltorbFlip
end
coinText += source.to_s
coinImages = coinText.split(//)[0...5]
for i in 0...5
5.times do |i|
@coins[i] = [@directory + "numbersScore", 6 + (i * 24), y, coinImages[i].to_i * 24, 0, 24, 38]
end
end
@@ -494,7 +494,7 @@ class VoltorbFlip
def pbAnimateTile(x, y, tile)
icons = []
points = 0
for i in 0...3
3.times do |i|
points = tile if i == 2
icons[i] = [@directory + "tiles", x, y, 320 + (i * 64) + (points * 64), 0, 64, 64]
pbDrawImagePositions(@sprites["icon"].bitmap, icons)
@@ -507,7 +507,7 @@ class VoltorbFlip
def pbShowAndDispose
# Make pre-rendered sprites visible (this approach reduces lag)
for i in 0...5
5.times do |i|
@sprites[i].visible = true
pbWait(Graphics.frame_rate / 20) if i < 3
@sprites[i].bitmap.clear
@@ -527,32 +527,32 @@ class VoltorbFlip
end
end
# "Dispose" of tiles by column
for i in 0...5
5.times do |i|
icons = []
pbSEPlay("Voltorb Flip tile")
for j in 0...5
5.times do |j|
icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 448 + (@squares[i + (j * 5)][2] * 64), 0, 64, 64]
end
pbDrawImagePositions(@sprites[i].bitmap, icons)
pbWait(Graphics.frame_rate / 20)
for j in 0...5
5.times do |j|
icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 384, 0, 64, 64]
end
pbDrawImagePositions(@sprites[i].bitmap, icons)
pbWait(Graphics.frame_rate / 20)
for j in 0...5
5.times do |j|
icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 320, 0, 64, 64]
end
pbDrawImagePositions(@sprites[i].bitmap, icons)
pbWait(Graphics.frame_rate / 20)
for j in 0...5
5.times do |j|
icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 896, 0, 64, 64]
end
pbDrawImagePositions(@sprites[i].bitmap, icons)
pbWait(Graphics.frame_rate / 20)
end
@sprites["icon"].bitmap.clear
for i in 0...6
6.times do |i|
@sprites[i].bitmap.clear
end
@sprites["cursor"].bitmap.clear

View File

@@ -16,10 +16,10 @@ def pbLottery(winnum, nameVar = 2, positionVar = 3, matchedVar = 4)
winpoke = nil
winpos = 0
winmatched = 0
for i in $player.party
$player.party.each do |i|
thismatched = 0
id = i.owner.public_id
for j in 0...5
5.times do |j|
if (id / (10**j)) % 10 == (winnum / (10**j)) % 10
thismatched += 1
else
@@ -35,7 +35,7 @@ def pbLottery(winnum, nameVar = 2, positionVar = 3, matchedVar = 4)
pbEachPokemon { |poke, _box|
thismatched = 0
id = poke.owner.public_id
for j in 0...5
5.times do |j|
if (id / (10**j)) % 10 == (winnum / (10**j)) % 10
thismatched += 1
else

View File

@@ -239,8 +239,8 @@ class MiningGameScene
@iron = []
pbDistributeItems
pbDistributeIron
for i in 0...BOARD_HEIGHT
for j in 0...BOARD_WIDTH
BOARD_HEIGHT.times do |i|
BOARD_WIDTH.times do |j|
@sprites["tile#{j + (i * BOARD_WIDTH)}"] = MiningGameTile.new(32 * j, 64 + (32 * i))
end
end
@@ -256,7 +256,7 @@ class MiningGameScene
def pbDistributeItems
# Set items to be buried (index in ITEMS, x coord, y coord)
ptotal = 0
for i in ITEMS
ITEMS.each do |i|
ptotal += i[1]
end
numitems = rand(2..4)
@@ -264,7 +264,7 @@ class MiningGameScene
while numitems > 0
rnd = rand(ptotal)
added = false
for i in 0...ITEMS.length
ITEMS.length.times do |i|
rnd -= ITEMS[i][1]
if rnd < 0
if pbNoDuplicateItems(ITEMS[i][0])
@@ -288,7 +288,7 @@ class MiningGameScene
end
# Draw items on item layer
layer = @sprites["itemlayer"].bitmap
for i in @items
@items.each do |i|
ox = ITEMS[i[0]][2]
oy = ITEMS[i[0]][3]
rectx = ITEMS[i[0]][4]
@@ -314,7 +314,7 @@ class MiningGameScene
end
# Draw items on item layer
layer = @sprites["itemlayer"].bitmap
for i in @iron
@iron.each do |i|
ox = IRON[i[0]][0]
oy = IRON[i[0]][1]
rectx = IRON[i[0]][2]
@@ -330,7 +330,7 @@ class MiningGameScene
plates = [:INSECTPLATE, :DREADPLATE, :DRACOPLATE, :ZAPPLATE, :FISTPLATE,
:FLAMEPLATE, :MEADOWPLATE, :EARTHPLATE, :ICICLEPLATE, :TOXICPLATE,
:MINDPLATE, :STONEPLATE, :SKYPLATE, :SPOOKYPLATE, :IRONPLATE, :SPLASHPLATE]
for i in @items
@items.each do |i|
preitem = ITEMS[i[0]][0]
return false if preitem == newitem # No duplicate items
return false if fossils.include?(preitem) && fossils.include?(newitem)
@@ -340,7 +340,7 @@ class MiningGameScene
end
def pbCheckOverlaps(checkiron, provx, provy, provwidth, provheight, provpattern)
for i in @items
@items.each do |i|
prex = i[1]
prey = i[2]
prewidth = ITEMS[i[0]][4]
@@ -348,7 +348,7 @@ class MiningGameScene
prepattern = ITEMS[i[0]][6]
next if provx + provwidth <= prex || provx >= prex + prewidth ||
provy + provheight <= prey || provy >= prey + preheight
for j in 0...prepattern.length
prepattern.length.times do |j|
next if prepattern[j] == 0
xco = prex + (j % prewidth)
yco = prey + (j / prewidth).floor
@@ -358,7 +358,7 @@ class MiningGameScene
end
end
if checkiron # Check other irons as well
for i in @iron
@iron.each do |i|
prex = i[1]
prey = i[2]
prewidth = IRON[i[0]][2]
@@ -366,7 +366,7 @@ class MiningGameScene
prepattern = IRON[i[0]][4]
next if provx + provwidth <= prex || provx >= prex + prewidth ||
provy + provheight <= prey || provy >= prey + preheight
for j in 0...prepattern.length
prepattern.length.times do |j|
next if prepattern[j] == 0
xco = prex + (j % prewidth)
yco = prey + (j / prewidth).floor
@@ -398,10 +398,10 @@ class MiningGameScene
pbSEPlay("Mining iron")
hittype = 2
else
for i in 0..2
3.times do |i|
ytile = i - 1 + (position / BOARD_WIDTH)
next if ytile < 0 || ytile >= BOARD_HEIGHT
for j in 0..2
3.times do |j|
xtile = j - 1 + (position % BOARD_WIDTH)
next if xtile < 0 || xtile >= BOARD_WIDTH
@sprites["tile#{xtile + (ytile * BOARD_WIDTH)}"].layer -= pattern[j + (i * 3)]
@@ -430,7 +430,7 @@ class MiningGameScene
def pbIsItemThere?(position)
posx = position % BOARD_WIDTH
posy = position / BOARD_WIDTH
for i in @items
@items.each do |i|
index = i[0]
width = ITEMS[index][4]
height = ITEMS[index][5]
@@ -447,7 +447,7 @@ class MiningGameScene
def pbIsIronThere?(position)
posx = position % BOARD_WIDTH
posy = position / BOARD_WIDTH
for i in @iron
@iron.each do |i|
index = i[0]
width = IRON[index][2]
height = IRON[index][3]
@@ -463,15 +463,15 @@ class MiningGameScene
def pbCheckRevealed
ret = []
for i in 0...@items.length
@items.length.times do |i|
next if @items[i][3]
revealed = true
index = @items[i][0]
width = ITEMS[index][4]
height = ITEMS[index][5]
pattern = ITEMS[index][6]
for j in 0...height
for k in 0...width
height.times do |j|
width.times do |k|
layer = @sprites["tile#{@items[i][1] + k + ((@items[i][2] + j) * BOARD_WIDTH)}"].layer
revealed = false if layer > 0 && pattern[k + (j * width)] > 0
break if !revealed
@@ -488,8 +488,8 @@ class MiningGameScene
revealeditems = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
halfFlashTime = Graphics.frame_rate / 8
alphaDiff = (255.0 / halfFlashTime).ceil
for i in 1..halfFlashTime * 2
for index in revealed
(1..halfFlashTime * 2).each do |i|
revealed.each do |index|
burieditem = @items[index]
revealeditems.bitmap.blt(32 * burieditem[1], 64 + (32 * burieditem[2]),
@itembitmap.bitmap,
@@ -505,7 +505,7 @@ class MiningGameScene
Graphics.update
end
revealeditems.dispose
for index in revealed
revealed.each do |index|
@items[index][3] = true
item = ITEMS[@items[index][0]][0]
@itemswon.push(item)
@@ -529,7 +529,7 @@ class MiningGameScene
@sprites["collapse"] = BitmapSprite.new(Graphics.width, Graphics.height, collapseviewport)
collapseTime = Graphics.frame_rate * 8 / 10
collapseFraction = (Graphics.height.to_f / collapseTime).ceil
for i in 1..collapseTime
(1..collapseTime).each do |i|
@sprites["collapse"].bitmap.fill_rect(0, collapseFraction * (i - 1),
Graphics.width, collapseFraction * i, Color.new(0, 0, 0))
Graphics.update
@@ -538,7 +538,7 @@ class MiningGameScene
break
end
foundall = true
for i in @items
@items.each do |i|
foundall = false if !i[3]
break if !foundall
end
@@ -587,7 +587,7 @@ class MiningGameScene
def pbGiveItems
if @itemswon.length > 0
for i in @itemswon
@itemswon.each do |i|
if $bag.add(i)
pbMessage(_INTL("One {1} was obtained.\\se[Mining item get]\\wtnp[30]",
GameData::Item.get(i).name))

View File

@@ -55,7 +55,7 @@ class TilePuzzleCursor < BitmapSprite
# Cursor
if @game != 3
expand = (@holding) ? 0 : 4
for i in 0...4
4.times do |i|
self.bitmap.blt(
x + ((i % 2) * (@tilewidth - (@cursorbitmap.width / 4))) + (expand * (((i % 2) * 2) - 1)),
y + ((i / 2) * (@tileheight - (@cursorbitmap.height / 2))) + (expand * (((i / 2) * 2) - 1)),
@@ -72,7 +72,7 @@ class TilePuzzleCursor < BitmapSprite
@tilewidth - (@cursorbitmap.width / 4) + expand, (@tilewidth - (@cursorbitmap.width / 4)) / 2]
yin = [@tileheight - (@cursorbitmap.height / 2) + expand, (@tileheight - (@cursorbitmap.height / 2)) / 2,
(@tileheight - (@cursorbitmap.height / 2)) / 2, -expand]
for i in 0...4
4.times do |i|
if @arrows[i]
self.bitmap.blt(x + xin[i], y + yin[i], @cursorbitmap.bitmap,
Rect.new((@cursorbitmap.width / 2) + ((i % 2) * (@cursorbitmap.width / 4)),
@@ -97,9 +97,9 @@ class TilePuzzleScene
def update
xtop = (Graphics.width - (@tilewidth * @boardwidth)) / 2
ytop = ((Graphics.height - (@tileheight * @boardheight)) / 2) + (@tileheight / 2) - 32
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
pos = -1
for j in 0...@tiles.length
@tiles.length.times do |j|
pos = j if @tiles[j] == i
end
@sprites["tile#{i}"].z = 0
@@ -139,7 +139,7 @@ class TilePuzzleScene
def updateCursor
arrows = []
for i in 0...4
4.times do |i|
arrows.push(pbCanMoveInDir?(@sprites["cursor"].position, (i + 1) * 2, @game == 6))
end
@sprites["cursor"].arrows = arrows
@@ -169,7 +169,7 @@ class TilePuzzleScene
end
@tilewidth = @tilebitmap.width / @boardwidth
@tileheight = @tilebitmap.height / @boardheight
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
@sprites["tile#{i}"] = BitmapSprite.new(@tilewidth, @tileheight, @viewport)
@sprites["tile#{i}"].ox = @tilewidth / 2
@sprites["tile#{i}"].oy = @tileheight / 2
@@ -188,7 +188,7 @@ class TilePuzzleScene
def pbShuffleTiles
ret = []
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
ret.push(i)
@angles.push(0)
end
@@ -209,9 +209,9 @@ class TilePuzzleScene
if @game == 3 # Make sure only solvable Mystic Squares are allowed.
num = 0
blank = -1
for i in 0...ret.length - 1
(ret.length - 1).times do |i|
blank = i if ret[i] == (@boardwidth * @boardheight) - 1
for j in i...ret.length
(i...ret.length).each do |j|
num += 1 if ret[j] < ret[i] && ret[i] != (@boardwidth * @boardheight) - 1 &&
ret[j] != (@boardwidth * @boardheight) - 1
end
@@ -224,13 +224,13 @@ class TilePuzzleScene
end
if @game == 1 || @game == 2
ret2 = []
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
ret2.push(-1)
end
ret = ret2 + ret
end
if @game == 2 || @game == 5
for i in 0...@angles.length
@angles.length.times do |i|
@angles[i] = rand(4)
end
end
@@ -240,7 +240,7 @@ class TilePuzzleScene
def pbDefaultCursorPosition
if @game == 3
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
return i if @tiles[i] == (@boardwidth * @boardheight) - 1
end
end
@@ -330,27 +330,27 @@ class TilePuzzleScene
if anim
@sprites["cursor"].visible = false
oldAngles = []
for i in group
group.each do |i|
@sprites["tile#{@tiles[i]}"].z = 1
oldAngles[i] = @sprites["tile#{@tiles[i]}"].angle
end
rotateTime = Graphics.frame_rate / 4
angleDiff = 90.0 / rotateTime
rotateTime.times do
for i in group
group.each do |i|
@sprites["tile#{@tiles[i]}"].angle -= angleDiff
end
pbUpdateSpriteHash(@sprites)
Graphics.update
Input.update
end
for i in group
group.each do |i|
@sprites["tile#{@tiles[i]}"].z = 0
@sprites["tile#{@tiles[i]}"].angle = oldAngles[i] - 90
end
@sprites["cursor"].visible = true if !pbCheckWin
end
for i in group
group.each do |i|
tile = @tiles[i]
@angles[tile] -= 1
@angles[tile] += 4 if @angles[tile] < 0
@@ -361,7 +361,7 @@ class TilePuzzleScene
def pbGetNearTiles(pos)
ret = [pos]
if @game == 7
for i in [2, 4, 6, 8]
[2, 4, 6, 8].each do |i|
ret.push(pbMoveCursor(pos, i)) if pbCanMoveInDir?(pos, i, true)
end
end
@@ -414,7 +414,7 @@ class TilePuzzleScene
(dist < 0 && cursor >= @boardwidth)
cursor += (@boardwidth * dist)
end
for i in 0...@boardheight
@boardheight.times do |i|
tiles.push(cursor - (i * dist * @boardwidth))
end
else
@@ -423,7 +423,7 @@ class TilePuzzleScene
(dist < 0 && cursor % @boardwidth < @boardwidth - 1)
cursor -= dist
end
for i in 0...@boardwidth
@boardwidth.times do |i|
tiles.push(cursor + (i * dist))
end
end
@@ -441,7 +441,7 @@ class TilePuzzleScene
if [2, 8].include?(dir)
distancePerFrame = (@tileheight.to_f / shiftTime).ceil
shiftTime.times do
for i in tiles
tiles.each do |i|
@sprites["tile#{@tiles[i]}"].y -= dist * distancePerFrame
end
pbUpdateSpriteHash(@sprites)
@@ -451,7 +451,7 @@ class TilePuzzleScene
else
distancePerFrame = (@tilewidth.to_f / shiftTime).ceil
shiftTime.times do
for i in tiles
tiles.each do |i|
@sprites["tile#{@tiles[i]}"].x += dist * distancePerFrame
end
pbUpdateSpriteHash(@sprites)
@@ -461,10 +461,10 @@ class TilePuzzleScene
end
end
temp = []
for i in tiles
tiles.each do |i|
temp.push(@tiles[i])
end
for i in 0...temp.length
temp.length.times do |i|
@tiles[tiles[(i + 1) % (temp.length)]] = temp[i]
end
if anim
@@ -487,7 +487,7 @@ class TilePuzzleScene
end
def pbCheckWin
for i in 0...@boardwidth * @boardheight
(@boardwidth * @boardheight).times do |i|
return false if @tiles[i] != i
return false if @angles[i] != 0
end