Added class GameData::Habitat

This commit is contained in:
Maruno17
2021-02-06 22:06:55 +00:00
parent 033434807d
commit a5af35beb1
9 changed files with 183 additions and 103 deletions

View File

@@ -5,19 +5,9 @@ module GameData
DATA = {}
extend ClassMethods
extend ClassMethodsSymbols
include InstanceMethods
def register(hash)
self::DATA[hash[:id]] = self.new(hash)
end
# Yields all data in alphabetical order.
def each
keys = self::DATA.keys.sort { |a, b| self::DATA[a].real_name <=> self::DATA[b].real_name }
keys.each { |key| yield self::DATA[key] }
end
def self.load; end
def self.save; end

View File

@@ -0,0 +1,74 @@
module GameData
class Habitat
attr_reader :id
attr_reader :real_name
DATA = {}
extend ClassMethodsSymbols
include InstanceMethods
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
end
# @return [String] the translated name of this egg group
def name
return _INTL(@real_name)
end
end
end
GameData::Habitat.register({
:id => :None,
:name => _INTL("None")
})
GameData::Habitat.register({
:id => :Grassland,
:name => _INTL("Grassland")
})
GameData::Habitat.register({
:id => :Forest,
:name => _INTL("Forest")
})
GameData::Habitat.register({
:id => :WatersEdge,
:name => _INTL("Water's Edge")
})
GameData::Habitat.register({
:id => :Sea,
:name => _INTL("Sea")
})
GameData::Habitat.register({
:id => :Cave,
:name => _INTL("Cave")
})
GameData::Habitat.register({
:id => :Mountain,
:name => _INTL("Mountain")
})
GameData::Habitat.register({
:id => :RoughTerrain,
:name => _INTL("Rough Terrain")
})
GameData::Habitat.register({
:id => :Urban,
:name => _INTL("Urban")
})
GameData::Habitat.register({
:id => :Rare,
:name => _INTL("Rare")
})

View File

@@ -1,31 +0,0 @@
module PBHabitats
None = 0
Grassland = 1
Forest = 2
WatersEdge = 3
Sea = 4
Cave = 5
Mountain = 6
RoughTerrain = 7
Urban = 8
Rare = 9
def self.maxValue; 9; end
def self.getName(id)
id = getID(PBHabitats,id)
names = [
_INTL("None"),
_INTL("Grassland"),
_INTL("Forest"),
_INTL("Water's Edge"),
_INTL("Sea"),
_INTL("Cave"),
_INTL("Mountain"),
_INTL("Rough Terrain"),
_INTL("Urban"),
_INTL("Rare")
]
return names[id]
end
end