Removed all uses of ID numbers for types, Shape property in pokemon.txt must now be a name and not a number

This commit is contained in:
Maruno17
2021-06-16 20:32:30 +01:00
parent 0e8b1e70b1
commit 8c67127f06
15 changed files with 119 additions and 101 deletions

View File

@@ -8,6 +8,7 @@ module GameData
attr_reader :weaknesses
attr_reader :resistances
attr_reader :immunities
attr_reader :icon_position # Where this type's icon is within types.png
DATA = {}
DATA_FILENAME = "types.dat"
@@ -19,29 +20,34 @@ module GameData
"IsSpecialType" => [4, "b"],
"Weaknesses" => [5, "*s"],
"Resistances" => [6, "*s"],
"Immunities" => [7, "*s"]
"Immunities" => [7, "*s"],
"IconPosition" => [8, "u"]
}
extend ClassMethods
extend ClassMethodsSymbols
include InstanceMethods
def self.each
DATA.each_value { |type| yield type }
end
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@pseudo_type = hash[:pseudo_type] || false
@special_type = hash[:special_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@pseudo_type = hash[:pseudo_type] || false
@special_type = hash[:special_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
@icon_position = hash[:icon_position] || 0
end
# @return [String] the translated name of this item
def name
return pbGetMessage(MessageTypes::Types, @id_number)
return pbGetMessageFromHash(MessageTypes::Types, @real_name)
end
def physical?; return !@special_type; end

View File

@@ -97,7 +97,7 @@ module GameData
"Height" => [0, "f"],
"Weight" => [0, "f"],
"Color" => [0, "e", :BodyColor],
"Shape" => [0, "y", :BodyShape],
"Shape" => [0, "e", :BodyShape],
"Habitat" => [0, "e", :Habitat],
"Generation" => [0, "i"],
"BattlerPlayerX" => [0, "i"],