Added class GameData::BodyColor

This commit is contained in:
Maruno17
2021-02-06 22:40:41 +00:00
parent a5af35beb1
commit 2e125019a9
7 changed files with 119 additions and 56 deletions

View File

@@ -96,7 +96,7 @@ module GameData
"StepsToHatch" => [0, "v"],
"Height" => [0, "f"],
"Weight" => [0, "f"],
"Color" => [0, "e", :PBColors],
"Color" => [0, "e", :BodyColor],
"Shape" => [0, "u"],
"Habitat" => [0, "e", :Habitat],
"Generation" => [0, "i"],
@@ -159,7 +159,7 @@ module GameData
@evolutions = hash[:evolutions] || []
@height = hash[:height] || 1
@weight = hash[:weight] || 1
@color = hash[:color] || PBColors::Red
@color = hash[:color] || :Red
@shape = hash[:shape] || 1
@habitat = hash[:habitat] || :None
@generation = hash[:generation] || 0

View File

@@ -0,0 +1,88 @@
# NOTE: The id_number is only used to determine the order that body colors are
# listed in the Pokédex search screen.
module GameData
class BodyColor
attr_reader :id
attr_reader :id_number
attr_reader :real_name
DATA = {}
extend ClassMethods
include InstanceMethods
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
end
# @return [String] the translated name of this body color
def name
return _INTL(@real_name)
end
end
end
GameData::BodyColor.register({
:id => :Red,
:id_number => 0,
:name => _INTL("Red")
})
GameData::BodyColor.register({
:id => :Blue,
:id_number => 1,
:name => _INTL("Blue")
})
GameData::BodyColor.register({
:id => :Yellow,
:id_number => 2,
:name => _INTL("Yellow")
})
GameData::BodyColor.register({
:id => :Green,
:id_number => 3,
:name => _INTL("Green")
})
GameData::BodyColor.register({
:id => :Black,
:id_number => 4,
:name => _INTL("Black")
})
GameData::BodyColor.register({
:id => :Brown,
:id_number => 5,
:name => _INTL("Brown")
})
GameData::BodyColor.register({
:id => :Purple,
:id_number => 6,
:name => _INTL("Purple")
})
GameData::BodyColor.register({
:id => :Gray,
:id_number => 7,
:name => _INTL("Gray")
})
GameData::BodyColor.register({
:id => :White,
:id_number => 8,
:name => _INTL("White")
})
GameData::BodyColor.register({
:id => :Pink,
:id_number => 9,
:name => _INTL("Pink")
})

View File

@@ -1,32 +0,0 @@
# Colors must begin at 0 and have no missing numbers
module PBColors
Red = 0
Blue = 1
Yellow = 2
Green = 3
Black = 4
Brown = 5
Purple = 6
Gray = 7
White = 8
Pink = 9
def self.maxValue; 9; end
def self.getName(id)
id = getID(PBColors,id)
names = [
_INTL("Red"),
_INTL("Blue"),
_INTL("Yellow"),
_INTL("Green"),
_INTL("Black"),
_INTL("Brown"),
_INTL("Purple"),
_INTL("Gray"),
_INTL("White"),
_INTL("Pink")
]
return names[id]
end
end

View File

@@ -16,7 +16,7 @@ module GameData
@real_name = hash[:name] || "Unnamed"
end
# @return [String] the translated name of this egg group
# @return [String] the translated name of this habitat
def name
return _INTL(@real_name)
end