mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-24 23:35:59 +00:00
More Rubocopping
This commit is contained in:
@@ -120,7 +120,7 @@ module RPG
|
||||
return if @max == value
|
||||
@max = value.clamp(0, MAX_SPRITES)
|
||||
ensureSprites
|
||||
for i in 0...MAX_SPRITES
|
||||
MAX_SPRITES.times do |i|
|
||||
@sprites[i].visible = (i < @max) if @sprites[i]
|
||||
end
|
||||
end
|
||||
@@ -149,7 +149,7 @@ module RPG
|
||||
weather_data = GameData::Weather.get(new_type)
|
||||
bitmap_names = weather_data.graphics
|
||||
@weatherTypes[new_type] = [weather_data, [], []]
|
||||
for i in 0...2 # 0=particles, 1=tiles
|
||||
2.times do |i| # 0=particles, 1=tiles
|
||||
next if !bitmap_names[i]
|
||||
bitmap_names[i].each do |name|
|
||||
bitmap = RPG::Cache.load_bitmap("Graphics/Weather/", name)
|
||||
@@ -160,7 +160,7 @@ module RPG
|
||||
|
||||
def ensureSprites
|
||||
if @sprites.length < MAX_SPRITES && @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
|
||||
for i in 0...MAX_SPRITES
|
||||
MAX_SPRITES.times do |i|
|
||||
if !@sprites[i]
|
||||
sprite = Sprite.new(@origViewport)
|
||||
sprite.z = 1000
|
||||
@@ -175,7 +175,7 @@ module RPG
|
||||
end
|
||||
if @fading && @new_sprites.length < MAX_SPRITES && @weatherTypes[@target_type] &&
|
||||
@weatherTypes[@target_type][1].length > 0
|
||||
for i in 0...MAX_SPRITES
|
||||
MAX_SPRITES.times do |i|
|
||||
if !@new_sprites[i]
|
||||
sprite = Sprite.new(@origViewport)
|
||||
sprite.z = 1000
|
||||
@@ -192,7 +192,7 @@ module RPG
|
||||
|
||||
def ensureTiles
|
||||
return if @tiles.length >= @tiles_wide * @tiles_tall
|
||||
for i in 0...(@tiles_wide * @tiles_tall)
|
||||
(@tiles_wide * @tiles_tall).times do |i|
|
||||
if !@tiles[i]
|
||||
sprite = Sprite.new(@origViewport)
|
||||
sprite.z = 1000
|
||||
@@ -497,7 +497,7 @@ module RPG
|
||||
# Update weather particles (raindrops, snowflakes, etc.)
|
||||
if @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
|
||||
ensureSprites
|
||||
for i in 0...MAX_SPRITES
|
||||
MAX_SPRITES.times do |i|
|
||||
update_sprite_position(@sprites[i], i, false)
|
||||
end
|
||||
elsif @sprites.length > 0
|
||||
@@ -507,7 +507,7 @@ module RPG
|
||||
# Update new weather particles (while fading in only)
|
||||
if @fading && @weatherTypes[@target_type] && @weatherTypes[@target_type][1].length > 0
|
||||
ensureSprites
|
||||
for i in 0...MAX_SPRITES
|
||||
MAX_SPRITES.times do |i|
|
||||
update_sprite_position(@new_sprites[i], i, true)
|
||||
end
|
||||
elsif @new_sprites.length > 0
|
||||
|
||||
@@ -74,8 +74,8 @@ class DarknessSprite < SpriteWrapper
|
||||
cy = Graphics.height / 2
|
||||
cradius = @radius
|
||||
numfades = 5
|
||||
for i in 1..numfades
|
||||
for j in cx - cradius..cx + cradius
|
||||
(1..numfades).each do |i|
|
||||
(cx - cradius..cx + cradius).each do |j|
|
||||
diff2 = (cradius * cradius) - ((j - cx) * (j - cx))
|
||||
diff = Math.sqrt(diff2)
|
||||
@darkness.fill_rect(j, cy - diff, 1, diff * 2, Color.new(0, 0, 0, 255.0 * (numfades - i) / numfades))
|
||||
@@ -209,7 +209,7 @@ 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)
|
||||
for i in map.events.keys
|
||||
map.events.keys.each do |i|
|
||||
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
|
||||
filename = $~[1].to_s
|
||||
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map, filename))
|
||||
|
||||
@@ -18,7 +18,7 @@ def pbCaveEntranceEx(exiting)
|
||||
x = 0
|
||||
y = 0
|
||||
# Calculate color of each band
|
||||
for k in 0...totalBands
|
||||
totalBands.times do |k|
|
||||
next if k >= totalBands * j / totalFrames
|
||||
inc = increment
|
||||
inc *= -1 if exiting
|
||||
@@ -28,7 +28,7 @@ def pbCaveEntranceEx(exiting)
|
||||
# Draw gray rectangles
|
||||
rectwidth = Graphics.width
|
||||
rectheight = Graphics.height
|
||||
for i in 0...totalBands
|
||||
totalBands.times do |i|
|
||||
currentGray = grays[i]
|
||||
sprite.bitmap.fill_rect(Rect.new(x, y, rectwidth, rectheight),
|
||||
Color.new(currentGray, currentGray, currentGray))
|
||||
@@ -47,7 +47,7 @@ def pbCaveEntranceEx(exiting)
|
||||
pbToneChangeAll(Tone.new(-255, -255, -255), 0)
|
||||
end
|
||||
# Animate fade to white (if exiting) or black (if entering)
|
||||
for j in 0...totalFrames
|
||||
totalFrames.times do |j|
|
||||
if exiting
|
||||
sprite.color = Color.new(255, 255, 255, j * increment)
|
||||
else
|
||||
|
||||
@@ -7,7 +7,7 @@ Events.onMapUpdate += proc { |_sender, _e|
|
||||
last = $PokemonGlobal.pokerusTime
|
||||
now = pbGetTimeNow
|
||||
if !last || last.year != now.year || last.month != now.month || last.day != now.day
|
||||
for i in $player.pokemon_party
|
||||
$player.pokemon_party.each do |i|
|
||||
i.lowerPokerusCount
|
||||
end
|
||||
$PokemonGlobal.pokerusTime = now
|
||||
@@ -18,7 +18,7 @@ Events.onMapUpdate += proc { |_sender, _e|
|
||||
# healed Pokémon has it.
|
||||
def pbPokerus?
|
||||
return false if $game_switches[Settings::SEEN_POKERUS_SWITCH]
|
||||
for i in $player.party
|
||||
$player.party.each do |i|
|
||||
return true if i.pokerusStage == 1
|
||||
end
|
||||
return false
|
||||
@@ -78,7 +78,7 @@ Events.onStepTaken += proc {
|
||||
$PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps
|
||||
$PokemonGlobal.happinessSteps += 1
|
||||
if $PokemonGlobal.happinessSteps >= 128
|
||||
for pkmn in $player.able_party
|
||||
$player.able_party.each do |pkmn|
|
||||
pkmn.changeHappiness("walking") if rand(2) == 0
|
||||
end
|
||||
$PokemonGlobal.happinessSteps = 0
|
||||
@@ -91,7 +91,7 @@ Events.onStepTakenTransferPossible += proc { |_sender, e|
|
||||
next if handled[0]
|
||||
if $PokemonGlobal.stepcount % 4 == 0 && Settings::POISON_IN_FIELD
|
||||
flashed = false
|
||||
for i in $player.able_party
|
||||
$player.able_party.each do |i|
|
||||
if i.status == :POISON && !i.hasAbility?(:IMMUNITY)
|
||||
if !flashed
|
||||
pbFlash(Color.new(255, 0, 0, 128), 8)
|
||||
@@ -131,7 +131,7 @@ Events.onStepTakenFieldMovement += proc { |_sender, e|
|
||||
event = e[0] # Get the event affected by field movement
|
||||
thistile = $map_factory.getRealTilePos(event.map.map_id, event.x, event.y)
|
||||
map = $map_factory.getMap(thistile[0])
|
||||
for i in [2, 1, 0]
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[thistile[1], thistile[2], i]
|
||||
next if tile_id == nil
|
||||
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
|
||||
@@ -284,7 +284,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
if mapChanged && map_metadata && map_metadata.announce_location
|
||||
nosignpost = false
|
||||
if $PokemonGlobal.mapTrail[1]
|
||||
for i in 0...Settings::NO_SIGNPOSTS.length / 2
|
||||
(Settings::NO_SIGNPOSTS.length / 2).times do |i|
|
||||
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] &&
|
||||
Settings::NO_SIGNPOSTS[(2 * i) + 1] == $game_map.map_id
|
||||
nosignpost = true if Settings::NO_SIGNPOSTS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] &&
|
||||
@@ -691,7 +691,7 @@ def pbRegisterPartner(tr_type, tr_name, tr_id = 0)
|
||||
pbCancelVehicles
|
||||
trainer = pbLoadTrainer(tr_type, tr_name, tr_id)
|
||||
Events.onTrainerPartyLoad.trigger(nil, trainer)
|
||||
for i in trainer.party
|
||||
trainer.party.each do |i|
|
||||
i.owner = Pokemon::Owner.new_from_trainer(trainer)
|
||||
i.calc_stats
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ end
|
||||
|
||||
def setBattleRule(*args)
|
||||
r = nil
|
||||
for arg in args
|
||||
args.each do |arg|
|
||||
if r
|
||||
$game_temp.add_battle_rule(r, arg)
|
||||
r = nil
|
||||
@@ -234,7 +234,7 @@ def pbWildBattleCore(*args)
|
||||
# Generate wild Pokémon based on the species and level
|
||||
foeParty = []
|
||||
sp = nil
|
||||
for arg in args
|
||||
args.each do |arg|
|
||||
if arg.is_a?(Pokemon)
|
||||
foeParty.push(arg)
|
||||
elsif arg.is_a?(Array)
|
||||
@@ -382,7 +382,7 @@ def pbTrainerBattleCore(*args)
|
||||
foeEndSpeeches = []
|
||||
foeParty = []
|
||||
foePartyStarts = []
|
||||
for arg in args
|
||||
args.each do |arg|
|
||||
case arg
|
||||
when NPCTrainer
|
||||
foeTrainers.push(arg)
|
||||
@@ -483,7 +483,7 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech = nil,
|
||||
# Find all other triggered trainer events
|
||||
triggeredEvents = $game_player.pbTriggeredTrainerEvents([2], false)
|
||||
otherEvent = []
|
||||
for i in triggeredEvents
|
||||
triggeredEvents.each do |i|
|
||||
next if i.id == thisEvent.id
|
||||
next if $game_self_switches[[$game_map.map_id, i.id, "A"]]
|
||||
otherEvent.push(i)
|
||||
@@ -632,9 +632,7 @@ end
|
||||
|
||||
def pbDynamicItemList(*args)
|
||||
ret = []
|
||||
for i in 0...args.length
|
||||
ret.push(args[i]) if GameData::Item.exists?(args[i])
|
||||
end
|
||||
args.each { |arg| ret.push(arg) if GameData::Item.exists?(arg) }
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -685,10 +683,10 @@ def pbPickup(pkmn)
|
||||
pkmnLevel = [100, pkmn.level].min
|
||||
itemStartIndex = (pkmnLevel - 1) / 10
|
||||
itemStartIndex = 0 if itemStartIndex < 0
|
||||
for i in 0...9
|
||||
9.times do |i|
|
||||
items.push(pickupList[itemStartIndex + i])
|
||||
end
|
||||
for i in 0...2
|
||||
2.times do |i|
|
||||
items.push(pickupListRare[itemStartIndex + i])
|
||||
end
|
||||
# Probabilities of choosing each item in turn from the pool
|
||||
|
||||
@@ -109,7 +109,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
|
||||
alphaDiff = (255.0 / halfFlashTime).ceil
|
||||
2.times do
|
||||
viewport.color.alpha = 0
|
||||
for i in 0...halfFlashTime * 2
|
||||
(halfFlashTime * 2).times do |i|
|
||||
if i < halfFlashTime
|
||||
viewport.color.alpha += alphaDiff
|
||||
else
|
||||
@@ -238,7 +238,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
|
||||
flash.opacity = 0
|
||||
# Animate bars sliding in from either side
|
||||
slideInTime = (Graphics.frame_rate * 0.25).floor
|
||||
for i in 0...slideInTime
|
||||
slideInTime.times do |i|
|
||||
bar1.x = xoffset * (i + 1 - slideInTime) / slideInTime
|
||||
bar2.x = xoffset * (slideInTime - i - 1) / slideInTime
|
||||
pbWait(1)
|
||||
@@ -263,7 +263,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
|
||||
trainer.tone = Tone.new(-255, -255, -255)
|
||||
# Dim the flash and make the trainer sprites appear, while animating bars
|
||||
animTime = (Graphics.frame_rate * 1.2).floor
|
||||
for i in 0...animTime
|
||||
animTime.times do |i|
|
||||
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
|
||||
bar1.ox -= 32 * 20 / Graphics.frame_rate
|
||||
bar2.ox += 32 * 20 / Graphics.frame_rate
|
||||
@@ -294,7 +294,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
|
||||
shudderTime = (Graphics.frame_rate * 1.75).floor
|
||||
zoomTime = (Graphics.frame_rate * 2.5).floor
|
||||
shudderDelta = [4 * 20 / Graphics.frame_rate, 1].max
|
||||
for i in 0...animTime
|
||||
animTime.times do |i|
|
||||
if i < shudderTime # Fade out the white flash
|
||||
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
|
||||
elsif i == shudderTime # Make the flash black
|
||||
|
||||
@@ -18,7 +18,7 @@ end
|
||||
# Resets all roaming Pokemon that were defeated without having been caught.
|
||||
def pbResetAllRoamers
|
||||
return if !$PokemonGlobal.roamPokemon
|
||||
for i in 0...$PokemonGlobal.roamPokemon.length
|
||||
$PokemonGlobal.roamPokemon.length.times do |i|
|
||||
next if $PokemonGlobal.roamPokemon[i] != true || !$PokemonGlobal.roamPokemonCaught[i]
|
||||
$PokemonGlobal.roamPokemon[i] = nil
|
||||
end
|
||||
@@ -45,14 +45,14 @@ def pbRoamPokemon
|
||||
# Start all roamers off in random maps
|
||||
if !$PokemonGlobal.roamPosition
|
||||
$PokemonGlobal.roamPosition = {}
|
||||
for i in 0...Settings::ROAMING_SPECIES.length
|
||||
Settings::ROAMING_SPECIES.length.times do |i|
|
||||
next if !GameData::Species.exists?(Settings::ROAMING_SPECIES[i][0])
|
||||
keys = pbRoamingAreas(i).keys
|
||||
$PokemonGlobal.roamPosition[i] = keys[rand(keys.length)]
|
||||
end
|
||||
end
|
||||
# Roam each Pokémon in turn
|
||||
for i in 0...Settings::ROAMING_SPECIES.length
|
||||
Settings::ROAMING_SPECIES.length.times do |i|
|
||||
pbRoamPokemonOne(i)
|
||||
end
|
||||
end
|
||||
@@ -77,7 +77,7 @@ def pbRoamPokemonOne(idxRoamer)
|
||||
newMapChoices = []
|
||||
nextMaps = pbRoamingAreas(idxRoamer)[currentMap]
|
||||
return if !nextMaps
|
||||
for map in nextMaps
|
||||
nextMaps.each do |map|
|
||||
# Only add map as a choice if the player hasn't been there recently
|
||||
newMapChoices.push(map)
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ class PokemonGlobalMetadata
|
||||
@pokedexDex = (numRegions == 0) ? -1 : 0
|
||||
@pokedexIndex = []
|
||||
@pokedexMode = 0
|
||||
for i in 0...numRegions + 1 # National Dex isn't a region, but is included
|
||||
(numRegions + 1).times do |i| # National Dex isn't a region, but is included
|
||||
@pokedexIndex[i] = 0
|
||||
end
|
||||
# Day Care
|
||||
@@ -153,13 +153,13 @@ class PokemonMapMetadata
|
||||
end
|
||||
|
||||
def updateMap
|
||||
for i in @erasedEvents
|
||||
@erasedEvents.each do |i|
|
||||
if i[0][0] == $game_map.map_id && i[1]
|
||||
event = $game_map.events[i[0][1]]
|
||||
event.erase if event
|
||||
end
|
||||
end
|
||||
for i in @movedEvents
|
||||
@movedEvents.each do |i|
|
||||
if i[0][0] == $game_map.map_id && i[1]
|
||||
next if !$game_map.events[i[0][1]]
|
||||
$game_map.events[i[0][1]].moveto(i[1][0], i[1][1])
|
||||
|
||||
@@ -154,7 +154,7 @@ def moonphase(time = nil) # in UTC
|
||||
v = (j - 2451550.1) / 29.530588853
|
||||
v = ((v - v.floor) + (v < 0 ? 1 : 0))
|
||||
ag = v * 29.53
|
||||
for i in 0...transitions.length
|
||||
transitions.length.times do |i|
|
||||
return i if ag <= transitions[i]
|
||||
end
|
||||
return 0
|
||||
@@ -177,7 +177,7 @@ def zodiac(month, day)
|
||||
1, 20, 2, 18, # Aquarius
|
||||
2, 19, 3, 20 # Pisces
|
||||
]
|
||||
for i in 0...12
|
||||
(time.length / 4).times do |i|
|
||||
return i if month == time[i * 4] && day >= time[(i * 4) + 1]
|
||||
return i if month == time[(i * 4) + 2] && day <= time[(i * 4) + 3]
|
||||
end
|
||||
@@ -207,7 +207,7 @@ def pbIsWeekday(wdayVariable, *arg)
|
||||
timenow = pbGetTimeNow
|
||||
wday = timenow.wday
|
||||
ret = false
|
||||
for wd in arg
|
||||
arg.each do |wd|
|
||||
ret = true if wd == wday
|
||||
end
|
||||
if wdayVariable > 0
|
||||
@@ -232,7 +232,7 @@ def pbIsMonth(monVariable, *arg)
|
||||
timenow = pbGetTimeNow
|
||||
thismon = timenow.mon
|
||||
ret = false
|
||||
for wd in arg
|
||||
arg.each do |wd|
|
||||
ret = true if wd == thismon
|
||||
end
|
||||
if monVariable > 0
|
||||
@@ -282,7 +282,7 @@ end
|
||||
def pbIsSeason(seasonVariable, *arg)
|
||||
thisseason = pbGetSeason
|
||||
ret = false
|
||||
for wd in arg
|
||||
arg.each do |wd|
|
||||
ret = true if wd == thisseason
|
||||
end
|
||||
if seasonVariable > 0
|
||||
|
||||
@@ -155,7 +155,7 @@ def pbHiddenMoveAnimation(pokemon)
|
||||
phase = 6 if interp.done?
|
||||
end
|
||||
# Constantly stream the strobes across the screen
|
||||
for strobe in strobes
|
||||
strobes.each do |strobe|
|
||||
strobe.ox = strobe.viewport.rect.x
|
||||
strobe.oy = strobe.viewport.rect.y
|
||||
if !strobe.visible # Initial placement of strobes
|
||||
@@ -175,7 +175,7 @@ def pbHiddenMoveAnimation(pokemon)
|
||||
break if phase == 6
|
||||
end
|
||||
sprite.dispose
|
||||
for strobe in strobes
|
||||
strobes.each do |strobe|
|
||||
strobe.dispose
|
||||
end
|
||||
strobes.clear
|
||||
|
||||
@@ -91,9 +91,9 @@ module RandomDungeonGenerator
|
||||
tiles = []
|
||||
x_offset = (CELL_WIDTH - CORRIDOR_WIDTH) / 2
|
||||
y_offset = (CELL_HEIGHT - CORRIDOR_WIDTH) / 2
|
||||
for combo in 0...16
|
||||
16.times do |combo|
|
||||
tiles[combo] = []
|
||||
for i in 0...CELL_WIDTH * CELL_HEIGHT
|
||||
(CELL_WIDTH * CELL_HEIGHT).times do |i|
|
||||
tiles[combo][i] = DungeonTile::VOID
|
||||
end
|
||||
if (combo & EdgeMasks::NORTH) == 0
|
||||
@@ -116,8 +116,8 @@ module RandomDungeonGenerator
|
||||
|
||||
# Makes all tiles in a particular area corridor tiles.
|
||||
def paint_corridor(tile, x, y, width, height)
|
||||
for j in 0...height
|
||||
for i in 0...width
|
||||
timesheight.times do |j|
|
||||
timeswidth.times do |i|
|
||||
tile[((y + j) * CELL_WIDTH) + (x + i)] = DungeonTile::CORRIDOR
|
||||
end
|
||||
end
|
||||
@@ -127,26 +127,26 @@ module RandomDungeonGenerator
|
||||
def paint_tile_layout(dungeon, dstX, dstY, tile_layout, rotation)
|
||||
case rotation
|
||||
when TURN_NONE
|
||||
for y in 0...CELL_HEIGHT
|
||||
for x in 0...CELL_WIDTH
|
||||
CELL_HEIGHT.times do |y|
|
||||
CELL_WIDTH.times do |x|
|
||||
dungeon[x + dstX, y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
|
||||
end
|
||||
end
|
||||
when TURN_LEFT
|
||||
for y in 0...CELL_HEIGHT
|
||||
for x in 0...CELL_WIDTH
|
||||
CELL_HEIGHT.times do |y|
|
||||
CELL_WIDTH.times do |x|
|
||||
dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
|
||||
end
|
||||
end
|
||||
when TURN_RIGHT
|
||||
for y in 0...CELL_HEIGHT
|
||||
for x in 0...CELL_WIDTH
|
||||
CELL_HEIGHT.times do |y|
|
||||
CELL_WIDTH.times do |x|
|
||||
dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
|
||||
end
|
||||
end
|
||||
when TURN_BACK
|
||||
for y in 0...CELL_HEIGHT
|
||||
for x in 0...CELL_WIDTH
|
||||
CELL_HEIGHT.times do |y|
|
||||
CELL_WIDTH.times do |x|
|
||||
dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
|
||||
end
|
||||
end
|
||||
@@ -258,7 +258,7 @@ module RandomDungeonGenerator
|
||||
end
|
||||
|
||||
def clearAllCells
|
||||
for c in 0...cellWidth * cellHeight
|
||||
(cellWidth * cellHeight).times do |c|
|
||||
@cells[c] = 0
|
||||
end
|
||||
end
|
||||
@@ -295,7 +295,7 @@ module RandomDungeonGenerator
|
||||
end
|
||||
|
||||
def setAllEdges
|
||||
for c in 0...nodeWidth * nodeHeight
|
||||
(nodeWidth * nodeHeight).times do |c|
|
||||
@nodes[c].set
|
||||
end
|
||||
end
|
||||
@@ -327,7 +327,7 @@ module RandomDungeonGenerator
|
||||
end
|
||||
|
||||
def clearAllEdges
|
||||
for c in 0...nodeWidth * nodeHeight
|
||||
(nodeWidth * nodeHeight).times do |c|
|
||||
@nodes[c].clear
|
||||
end
|
||||
end
|
||||
@@ -373,8 +373,8 @@ module RandomDungeonGenerator
|
||||
|
||||
def buildNodeList
|
||||
list = []
|
||||
for x in 0...nodeWidth
|
||||
for y in 0...nodeHeight
|
||||
nodeWidth.times do |x|
|
||||
nodeHeight.times do |y|
|
||||
list.push(NodeListElement.new(x, y))
|
||||
end
|
||||
end
|
||||
@@ -386,7 +386,7 @@ module RandomDungeonGenerator
|
||||
maxWall = cellWidth if !maxWall
|
||||
nlist = buildNodeList
|
||||
return if nlist.length == 0
|
||||
for c in 0...nlist.length
|
||||
nlist.length.times do |c|
|
||||
d = randomDir
|
||||
len = rand(maxWall + 1)
|
||||
x = nlist[c].x
|
||||
@@ -398,7 +398,7 @@ module RandomDungeonGenerator
|
||||
def recurseDepthFirst(x, y, depth)
|
||||
setVisited(x, y)
|
||||
dirs = DIRECTIONS.shuffle
|
||||
for c in 0...4
|
||||
4.times do |c|
|
||||
d = dirs[c]
|
||||
cx = x
|
||||
cy = y
|
||||
@@ -464,7 +464,7 @@ module RandomDungeonGenerator
|
||||
end
|
||||
|
||||
def clear
|
||||
for i in 0...width * height
|
||||
(width * height).times do |i|
|
||||
@array[i] = DungeonTile::VOID
|
||||
end
|
||||
end
|
||||
@@ -472,8 +472,8 @@ module RandomDungeonGenerator
|
||||
def write
|
||||
ret = ""
|
||||
i = 0
|
||||
for y in 0...@height
|
||||
for x in 0...@width
|
||||
@height.times do |y|
|
||||
@width.times do |x|
|
||||
ret += DungeonTile.to_text(value(x, y))
|
||||
i += 1
|
||||
end
|
||||
@@ -544,8 +544,8 @@ module RandomDungeonGenerator
|
||||
end
|
||||
|
||||
def paint_room(rect, offsetX, offsetY)
|
||||
for y in (rect[1] + offsetY)...(rect[1] + offsetY + rect[3])
|
||||
for x in (rect[0] + offsetX)...(rect[0] + offsetX + rect[2])
|
||||
((rect[1] + offsetY)...(rect[1] + offsetY + rect[3])).each do |y|
|
||||
((rect[0] + offsetX)...(rect[0] + offsetX + rect[2])).each do |x|
|
||||
self[x, y] = DungeonTile::ROOM
|
||||
end
|
||||
end
|
||||
@@ -559,8 +559,8 @@ module RandomDungeonGenerator
|
||||
cellHeight = DungeonMaze::CELL_HEIGHT
|
||||
return if maxWidth < 0 || maxHeight < 0
|
||||
if maxWidth < cellWidth || maxHeight < cellHeight # Map is too small
|
||||
for x in 0...maxWidth
|
||||
for y in 0...maxHeight
|
||||
maxWidth.times do |x|
|
||||
maxHeight.times do |y|
|
||||
self[x + BUFFER_X, y + BUFFER_Y] = DungeonTile::ROOM
|
||||
end
|
||||
end
|
||||
@@ -572,8 +572,8 @@ module RandomDungeonGenerator
|
||||
# Draw each cell's contents in turn (room and corridors)
|
||||
corridor_patterns = DungeonMaze.generate_corridor_patterns
|
||||
roomcount = 0
|
||||
for y in 0...maxHeight / cellHeight
|
||||
for x in 0...maxWidth / cellWidth
|
||||
(maxHeight / cellHeight).times do |y|
|
||||
(maxWidth / cellWidth).times do |x|
|
||||
pattern = maze.getEdgePattern(x, y)
|
||||
next if !DungeonMaze.paint_cell_contents(
|
||||
self, BUFFER_X + (x * cellWidth), BUFFER_Y + (y * cellHeight),
|
||||
@@ -584,15 +584,15 @@ module RandomDungeonGenerator
|
||||
end
|
||||
# If no rooms were generated, make the whole map a room
|
||||
if roomcount == 0
|
||||
for x in 0...maxWidth
|
||||
for y in 0...maxHeight
|
||||
maxWidth.times do |x|
|
||||
maxHeight.times do |y|
|
||||
self[x + BUFFER_X, y + BUFFER_Y] = DungeonTile::ROOM
|
||||
end
|
||||
end
|
||||
end
|
||||
# Generate walls
|
||||
for y in 0...@height
|
||||
for x in 0...@width
|
||||
@height.times do |y|
|
||||
@width.times do |x|
|
||||
self[x, y] = DungeonTile::WALL if isWall?(x, y) # Make appropriate tiles wall tiles
|
||||
end
|
||||
end
|
||||
@@ -601,8 +601,8 @@ module RandomDungeonGenerator
|
||||
# Convert dungeon layout into proper map tiles
|
||||
def generateMapInPlace(map)
|
||||
tbl = DungeonTable.new(self)
|
||||
for i in 0...map.width
|
||||
for j in 0...map.height
|
||||
map.width.times do |i|
|
||||
map.height.times do |j|
|
||||
nb = TileDrawingHelper.tableNeighbors(tbl, i, j)
|
||||
tile = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX[nb]
|
||||
map.data[i, j, 0] = tile + (48 * (tbl[i, j]))
|
||||
@@ -655,7 +655,7 @@ Events.onMapCreate += proc { |_sender, e|
|
||||
dungeon.generateMapInPlace(map)
|
||||
roomtiles = []
|
||||
# Reposition events
|
||||
for event in map.events.values
|
||||
map.events.values.each do |event|
|
||||
tile = RandomDungeonGenerator.pbRandomRoomTile(dungeon, roomtiles)
|
||||
if tile
|
||||
event.x = tile[0]
|
||||
|
||||
Reference in New Issue
Block a user