mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added def count to all GameData variants, and one that returns the number of species for Species, removed all uses of ID numbers for GameData::Status, made more use of GameData::X.keys
This commit is contained in:
@@ -58,6 +58,10 @@ module GameData
|
||||
keys.each { |key| yield self::DATA[key] if !key.is_a?(Integer) }
|
||||
end
|
||||
|
||||
def count
|
||||
return self::DATA.length / 2
|
||||
end
|
||||
|
||||
def load
|
||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||
end
|
||||
@@ -125,6 +129,10 @@ module GameData
|
||||
keys.each { |key| yield self::DATA[key] }
|
||||
end
|
||||
|
||||
def count
|
||||
return self::DATA.length
|
||||
end
|
||||
|
||||
def load
|
||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||
end
|
||||
@@ -182,6 +190,10 @@ module GameData
|
||||
keys.each { |key| yield self::DATA[key] }
|
||||
end
|
||||
|
||||
def count
|
||||
return self::DATA.length
|
||||
end
|
||||
|
||||
def load
|
||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||
end
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
# NOTE: The id_number is only used to determine the order of the status icons in
|
||||
# the graphics containing them. Number 0 (:NONE) is ignored; they start
|
||||
# with status 1.
|
||||
# "Graphics/Pictures/statuses.png" also contains icons for being fainted
|
||||
# NOTE: "Graphics/Pictures/statuses.png" also contains icons for being fainted
|
||||
# and for having Pokérus, in that order, at the bottom of the graphic.
|
||||
# "Graphics/Pictures/Battle/icon_statuses.png" also contains an icon for
|
||||
# bad poisoning (toxic), at the bottom of the graphic.
|
||||
# Both graphics automatically handle varying numbers of defined statuses.
|
||||
# Both graphics automatically handle varying numbers of defined statuses,
|
||||
# as long as their extra icons remain at the bottom of them.
|
||||
module GameData
|
||||
class Status
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
attr_reader :real_name
|
||||
attr_reader :animation
|
||||
attr_reader :icon_position # Where this status's icon is within statuses.png
|
||||
|
||||
DATA = {}
|
||||
|
||||
extend ClassMethods
|
||||
extend ClassMethodsSymbols
|
||||
include InstanceMethods
|
||||
|
||||
def self.load; end
|
||||
def self.save; end
|
||||
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@id_number = hash[:id_number]
|
||||
@real_name = hash[:name] || "Unnamed"
|
||||
@animation = hash[:animation]
|
||||
@id = hash[:id]
|
||||
@real_name = hash[:name] || "Unnamed"
|
||||
@animation = hash[:animation]
|
||||
@icon_position = hash[:icon_position] || -1 # -1 means "no icon"
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this status condition
|
||||
@@ -38,42 +36,41 @@ end
|
||||
#===============================================================================
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :NONE,
|
||||
:id_number => 0,
|
||||
:name => _INTL("None")
|
||||
:id => :NONE,
|
||||
:name => _INTL("None")
|
||||
})
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :SLEEP,
|
||||
:id_number => 1,
|
||||
:name => _INTL("Sleep"),
|
||||
:animation => "Sleep"
|
||||
:id => :SLEEP,
|
||||
:name => _INTL("Sleep"),
|
||||
:animation => "Sleep",
|
||||
:icon_position => 0
|
||||
})
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :POISON,
|
||||
:id_number => 2,
|
||||
:name => _INTL("Poison"),
|
||||
:animation => "Poison"
|
||||
:id => :POISON,
|
||||
:name => _INTL("Poison"),
|
||||
:animation => "Poison",
|
||||
:icon_position => 1
|
||||
})
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :BURN,
|
||||
:id_number => 3,
|
||||
:name => _INTL("Burn"),
|
||||
:animation => "Burn"
|
||||
:id => :BURN,
|
||||
:name => _INTL("Burn"),
|
||||
:animation => "Burn",
|
||||
:icon_position => 2
|
||||
})
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :PARALYSIS,
|
||||
:id_number => 4,
|
||||
:name => _INTL("Paralysis"),
|
||||
:animation => "Paralysis"
|
||||
:id => :PARALYSIS,
|
||||
:name => _INTL("Paralysis"),
|
||||
:animation => "Paralysis",
|
||||
:icon_position => 3
|
||||
})
|
||||
|
||||
GameData::Status.register({
|
||||
:id => :FROZEN,
|
||||
:id_number => 5,
|
||||
:name => _INTL("Frozen"),
|
||||
:animation => "Frozen"
|
||||
:id => :FROZEN,
|
||||
:name => _INTL("Frozen"),
|
||||
:animation => "Frozen",
|
||||
:icon_position => 4
|
||||
})
|
||||
|
||||
@@ -53,10 +53,6 @@ module GameData
|
||||
extend ClassMethodsSymbols
|
||||
include InstanceMethods
|
||||
|
||||
def self.each_species
|
||||
DATA.each_value { |species| yield species if species.form == 0 }
|
||||
end
|
||||
|
||||
# @param species [Symbol, self, String, Integer]
|
||||
# @param form [Integer]
|
||||
# @return [self, nil]
|
||||
@@ -75,6 +71,16 @@ module GameData
|
||||
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
|
||||
end
|
||||
|
||||
def self.each_species
|
||||
DATA.each_value { |species| yield species if species.form == 0 }
|
||||
end
|
||||
|
||||
def self.species_count
|
||||
ret = 0
|
||||
self.species_count { |species| ret += 1 }
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.schema(compiling_forms = false)
|
||||
ret = {
|
||||
"FormName" => [0, "q"],
|
||||
|
||||
@@ -137,7 +137,7 @@ module GameData
|
||||
else # Make the nature random but consistent for the same species used by the same trainer type
|
||||
species_num = GameData::Species.keys.index(species) || 1
|
||||
tr_type_num = GameData::TrainerType.keys.index(@trainer_type) || 1
|
||||
pkmn.nature = (species_num + tr_type_num) % (GameData::Nature::DATA.length / 2)
|
||||
pkmn.nature = (species_num + tr_type_num) % GameData::Nature.count
|
||||
end
|
||||
GameData::Stat.each_main do |s|
|
||||
if pkmn_data[:iv]
|
||||
|
||||
Reference in New Issue
Block a user