Rewrote the random dungeon generator code

This commit is contained in:
Maruno17
2022-10-01 18:06:15 +01:00
parent 8c31ad994d
commit 1ccbafb499
15 changed files with 1618 additions and 559 deletions

View File

@@ -70,7 +70,32 @@ def toCelsius(fahrenheit)
return ((fahrenheit - 32) * 5.0 / 9.0).round
end
#===============================================================================
# This class is designed to favor different values more than a uniform
# random generator does.
#===============================================================================
class AntiRandom
def initialize(size)
@old = []
@new = Array.new(size) { |i| i }
end
def get
if @new.length == 0 # No new values
@new = @old.clone
@old.clear
end
if @old.length > 0 && rand(7) == 0 # Get old value
return @old[rand(@old.length)]
end
if @new.length > 0 # Get new value
ret = @new.delete_at(rand(@new.length))
@old.push(ret)
return ret
end
return @old[rand(@old.length)] # Get old value
end
end
#===============================================================================
# Constants utilities
@@ -125,8 +150,6 @@ def getConstantNameOrValue(mod, value)
return value.inspect
end
#===============================================================================
# Event utilities
#===============================================================================
@@ -196,8 +219,6 @@ def pbNoticePlayer(event)
pbMoveTowardPlayer(event)
end
#===============================================================================
# Player-related utilities, random name generator
#===============================================================================
@@ -339,8 +360,6 @@ def getRandomName(maxLength = 100)
return getRandomNameEx(2, nil, nil, maxLength)
end
#===============================================================================
# Regional and National Pokédexes utilities
#===============================================================================
@@ -387,8 +406,6 @@ def pbGetRegionalDexLength(region_dex)
return (dex_list) ? dex_list.length : 0
end
#===============================================================================
# Other utilities
#===============================================================================