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) }
|
keys.each { |key| yield self::DATA[key] if !key.is_a?(Integer) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
return self::DATA.length / 2
|
||||||
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||||
end
|
end
|
||||||
@@ -125,6 +129,10 @@ module GameData
|
|||||||
keys.each { |key| yield self::DATA[key] }
|
keys.each { |key| yield self::DATA[key] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
return self::DATA.length
|
||||||
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||||
end
|
end
|
||||||
@@ -182,6 +190,10 @@ module GameData
|
|||||||
keys.each { |key| yield self::DATA[key] }
|
keys.each { |key| yield self::DATA[key] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
return self::DATA.length
|
||||||
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
const_set(:DATA, load_data("Data/#{self::DATA_FILENAME}"))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
# NOTE: The id_number is only used to determine the order of the status icons in
|
# NOTE: "Graphics/Pictures/statuses.png" also contains icons for being fainted
|
||||||
# the graphics containing them. Number 0 (:NONE) is ignored; they start
|
|
||||||
# with status 1.
|
|
||||||
# "Graphics/Pictures/statuses.png" also contains icons for being fainted
|
|
||||||
# and for having Pokérus, in that order, at the bottom of the graphic.
|
# 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
|
# "Graphics/Pictures/Battle/icon_statuses.png" also contains an icon for
|
||||||
# bad poisoning (toxic), at the bottom of the graphic.
|
# 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
|
module GameData
|
||||||
class Status
|
class Status
|
||||||
attr_reader :id
|
attr_reader :id
|
||||||
attr_reader :id_number
|
|
||||||
attr_reader :real_name
|
attr_reader :real_name
|
||||||
attr_reader :animation
|
attr_reader :animation
|
||||||
|
attr_reader :icon_position # Where this status's icon is within statuses.png
|
||||||
|
|
||||||
DATA = {}
|
DATA = {}
|
||||||
|
|
||||||
extend ClassMethods
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
def self.load; end
|
def self.load; end
|
||||||
def self.save; end
|
def self.save; end
|
||||||
|
|
||||||
def initialize(hash)
|
def initialize(hash)
|
||||||
@id = hash[:id]
|
@id = hash[:id]
|
||||||
@id_number = hash[:id_number]
|
@real_name = hash[:name] || "Unnamed"
|
||||||
@real_name = hash[:name] || "Unnamed"
|
@animation = hash[:animation]
|
||||||
@animation = hash[:animation]
|
@icon_position = hash[:icon_position] || -1 # -1 means "no icon"
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [String] the translated name of this status condition
|
# @return [String] the translated name of this status condition
|
||||||
@@ -38,42 +36,41 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :NONE,
|
:id => :NONE,
|
||||||
:id_number => 0,
|
:name => _INTL("None")
|
||||||
:name => _INTL("None")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :SLEEP,
|
:id => :SLEEP,
|
||||||
:id_number => 1,
|
:name => _INTL("Sleep"),
|
||||||
:name => _INTL("Sleep"),
|
:animation => "Sleep",
|
||||||
:animation => "Sleep"
|
:icon_position => 0
|
||||||
})
|
})
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :POISON,
|
:id => :POISON,
|
||||||
:id_number => 2,
|
:name => _INTL("Poison"),
|
||||||
:name => _INTL("Poison"),
|
:animation => "Poison",
|
||||||
:animation => "Poison"
|
:icon_position => 1
|
||||||
})
|
})
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :BURN,
|
:id => :BURN,
|
||||||
:id_number => 3,
|
:name => _INTL("Burn"),
|
||||||
:name => _INTL("Burn"),
|
:animation => "Burn",
|
||||||
:animation => "Burn"
|
:icon_position => 2
|
||||||
})
|
})
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :PARALYSIS,
|
:id => :PARALYSIS,
|
||||||
:id_number => 4,
|
:name => _INTL("Paralysis"),
|
||||||
:name => _INTL("Paralysis"),
|
:animation => "Paralysis",
|
||||||
:animation => "Paralysis"
|
:icon_position => 3
|
||||||
})
|
})
|
||||||
|
|
||||||
GameData::Status.register({
|
GameData::Status.register({
|
||||||
:id => :FROZEN,
|
:id => :FROZEN,
|
||||||
:id_number => 5,
|
:name => _INTL("Frozen"),
|
||||||
:name => _INTL("Frozen"),
|
:animation => "Frozen",
|
||||||
:animation => "Frozen"
|
:icon_position => 4
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ module GameData
|
|||||||
extend ClassMethodsSymbols
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
def self.each_species
|
|
||||||
DATA.each_value { |species| yield species if species.form == 0 }
|
|
||||||
end
|
|
||||||
|
|
||||||
# @param species [Symbol, self, String, Integer]
|
# @param species [Symbol, self, String, Integer]
|
||||||
# @param form [Integer]
|
# @param form [Integer]
|
||||||
# @return [self, nil]
|
# @return [self, nil]
|
||||||
@@ -75,6 +71,16 @@ module GameData
|
|||||||
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
|
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
|
||||||
end
|
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)
|
def self.schema(compiling_forms = false)
|
||||||
ret = {
|
ret = {
|
||||||
"FormName" => [0, "q"],
|
"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
|
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
|
species_num = GameData::Species.keys.index(species) || 1
|
||||||
tr_type_num = GameData::TrainerType.keys.index(@trainer_type) || 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
|
end
|
||||||
GameData::Stat.each_main do |s|
|
GameData::Stat.each_main do |s|
|
||||||
if pkmn_data[:iv]
|
if pkmn_data[:iv]
|
||||||
|
|||||||
@@ -1665,7 +1665,7 @@ class PokeBattle_Move_0B6 < PokeBattle_Move
|
|||||||
|
|
||||||
def pbMoveFailed?(user,targets)
|
def pbMoveFailed?(user,targets)
|
||||||
@metronomeMove = nil
|
@metronomeMove = nil
|
||||||
move_keys = GameData::Move::DATA.keys
|
move_keys = GameData::Move.keys
|
||||||
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
|
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
|
||||||
# a row. This is too unlikely to care about, though.
|
# a row. This is too unlikely to care about, though.
|
||||||
1000.times do
|
1000.times do
|
||||||
|
|||||||
@@ -247,12 +247,13 @@ class PokemonDataBox < SpriteWrapper
|
|||||||
end
|
end
|
||||||
# Draw status icon
|
# Draw status icon
|
||||||
if @battler.status != :NONE
|
if @battler.status != :NONE
|
||||||
s = GameData::Status.get(@battler.status).id_number
|
if @battler.status == :POISON && @battler.statusCount > 0 # Badly poisoned
|
||||||
if s == :POISON && @battler.statusCount > 0 # Badly poisoned
|
s = GameData::Status.count
|
||||||
s = GameData::Status::DATA.keys.length / 2
|
else
|
||||||
|
s = GameData::Status.get(@battler.status).icon_position
|
||||||
end
|
end
|
||||||
imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36,
|
imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36,
|
||||||
0,(s-1)*STATUS_ICON_HEIGHT,-1,STATUS_ICON_HEIGHT])
|
0,(s-1)*STATUS_ICON_HEIGHT,-1,STATUS_ICON_HEIGHT]) if s >= 0
|
||||||
end
|
end
|
||||||
pbDrawImagePositions(self.bitmap,imagePos)
|
pbDrawImagePositions(self.bitmap,imagePos)
|
||||||
refreshHP
|
refreshHP
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ class Pokemon
|
|||||||
|
|
||||||
# @return [GameData::Nature, nil] a Nature object corresponding to this Pokémon's nature
|
# @return [GameData::Nature, nil] a Nature object corresponding to this Pokémon's nature
|
||||||
def nature
|
def nature
|
||||||
@nature = GameData::Nature.get(@personalID % (GameData::Nature::DATA.keys.length / 2)).id if !@nature
|
@nature = GameData::Nature.get(@personalID % GameData::Nature.count).id if !@nature
|
||||||
return GameData::Nature.try_get(@nature)
|
return GameData::Nature.try_get(@nature)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
|
|||||||
trainer = [tr_type, tr_name, [], party, tr_version]
|
trainer = [tr_type, tr_name, [], party, tr_version]
|
||||||
if save_changes
|
if save_changes
|
||||||
trainer_hash = {
|
trainer_hash = {
|
||||||
:id_number => GameData::Trainer::DATA.keys.length / 2,
|
:id_number => GameData::Trainer.count,
|
||||||
:trainer_type => tr_type,
|
:trainer_type => tr_type,
|
||||||
:name => tr_name,
|
:name => tr_name,
|
||||||
:version => tr_version,
|
:version => tr_version,
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ class IntroEventScene < EventScene
|
|||||||
onUpdate.clear
|
onUpdate.clear
|
||||||
onCTrigger.clear
|
onCTrigger.clear
|
||||||
# Play random cry
|
# Play random cry
|
||||||
species_keys = GameData::Species::DATA.keys
|
species_keys = GameData::Species.keys
|
||||||
species_data = GameData::Species.get(species_keys[rand(species_keys.length)])
|
species_data = GameData::Species.get(species_keys.sample)
|
||||||
Pokemon.play_cry(species_data.species, species_data.form)
|
Pokemon.play_cry(species_data.species, species_data.form)
|
||||||
@pic.moveXY(0, 20, 0, 0) # Adds 20 ticks (1 second) pause
|
@pic.moveXY(0, 20, 0, 0) # Adds 20 ticks (1 second) pause
|
||||||
pictureWait
|
pictureWait
|
||||||
|
|||||||
@@ -374,15 +374,14 @@ class PokemonPartyPanel < SpriteWrapper
|
|||||||
@overlaysprite.bitmap.blt(128,52,@hpbar.bitmap,hprect)
|
@overlaysprite.bitmap.blt(128,52,@hpbar.bitmap,hprect)
|
||||||
end
|
end
|
||||||
# Draw status
|
# Draw status
|
||||||
status = 0
|
status = -1
|
||||||
if @pokemon.fainted?
|
if @pokemon.fainted?
|
||||||
status = GameData::Status::DATA.keys.length / 2
|
status = GameData::Status.count
|
||||||
elsif @pokemon.status != :NONE
|
elsif @pokemon.status != :NONE
|
||||||
status = GameData::Status.get(@pokemon.status).id_number
|
status = GameData::Status.get(@pokemon.status).icon_position
|
||||||
elsif @pokemon.pokerusStage == 1
|
elsif @pokemon.pokerusStage == 1
|
||||||
status = GameData::Status::DATA.keys.length / 2 + 1
|
status = GameData::Status.count + 1
|
||||||
end
|
end
|
||||||
status -= 1
|
|
||||||
if status >= 0
|
if status >= 0
|
||||||
statusrect = Rect.new(0,16*status,44,16)
|
statusrect = Rect.new(0,16*status,44,16)
|
||||||
@overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect)
|
@overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect)
|
||||||
|
|||||||
@@ -308,15 +308,14 @@ class PokemonSummary_Scene
|
|||||||
ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%s", @pokemon.poke_ball)
|
ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%s", @pokemon.poke_ball)
|
||||||
imagepos.push([ballimage,14,60])
|
imagepos.push([ballimage,14,60])
|
||||||
# Show status/fainted/Pokérus infected icon
|
# Show status/fainted/Pokérus infected icon
|
||||||
status = 0
|
status = -1
|
||||||
if @pokemon.fainted?
|
if @pokemon.fainted?
|
||||||
status = GameData::Status::DATA.keys.length / 2
|
status = GameData::Status.count
|
||||||
elsif @pokemon.status != :NONE
|
elsif @pokemon.status != :NONE
|
||||||
status = GameData::Status.get(@pokemon.status).id_number
|
status = GameData::Status.get(@pokemon.status).icon_position
|
||||||
elsif @pokemon.pokerusStage == 1
|
elsif @pokemon.pokerusStage == 1
|
||||||
status = GameData::Status::DATA.keys.length / 2 + 1
|
status = GameData::Status.count + 1
|
||||||
end
|
end
|
||||||
status -= 1
|
|
||||||
if status >= 0
|
if status >= 0
|
||||||
imagepos.push(["Graphics/Pictures/statuses",124,100,0,16*status,44,16])
|
imagepos.push(["Graphics/Pictures/statuses",124,100,0,16*status,44,16])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -720,12 +720,12 @@ class TriadScreen
|
|||||||
@board = []
|
@board = []
|
||||||
@playerName = $Trainer ? $Trainer.name : "Trainer"
|
@playerName = $Trainer ? $Trainer.name : "Trainer"
|
||||||
@opponentName = opponentName
|
@opponentName = opponentName
|
||||||
type_keys = GameData::Type::DATA.keys
|
type_keys = GameData::Type.keys
|
||||||
for i in 0...@width*@height
|
for i in 0...@width*@height
|
||||||
square = TriadSquare.new
|
square = TriadSquare.new
|
||||||
if @elements
|
if @elements
|
||||||
loop do
|
loop do
|
||||||
trial_type = type_keys[rand(type_keys.length)]
|
trial_type = type_keys[type_keys.sample]
|
||||||
type_data = GameData::Type.get(trial_type)
|
type_data = GameData::Type.get(trial_type)
|
||||||
next if type_data.pseudo_type
|
next if type_data.pseudo_type
|
||||||
square.type = type_data.id
|
square.type = type_data.id
|
||||||
@@ -766,10 +766,10 @@ class TriadScreen
|
|||||||
opponentCards.push(species_data.id)
|
opponentCards.push(species_data.id)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
species_keys = GameData::Species::DATA.keys
|
species_keys = GameData::Species.keys
|
||||||
candidates = []
|
candidates = []
|
||||||
while candidates.length < 200
|
while candidates.length < 200
|
||||||
card = species_keys[rand(species_keys.length)]
|
card = species_keys[species_keys.sample]
|
||||||
card_data = GameData::Species.get(card)
|
card_data = GameData::Species.get(card)
|
||||||
card = card_data.id # Make sure it's a symbol
|
card = card_data.id # Make sure it's a symbol
|
||||||
triad = TriadCard.new(card)
|
triad = TriadCard.new(card)
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Used to replace Sketch with any other move.
|
# Used to replace Sketch with any other move.
|
||||||
def pbRandomMove
|
def pbRandomMove
|
||||||
keys = GameData::Move::DATA.keys
|
keys = GameData::Move.keys
|
||||||
loop do
|
loop do
|
||||||
move_id = keys[rand(keys.length)]
|
move_id = keys[keys.sample]
|
||||||
move = GameData::Move.get(move_id)
|
move = GameData::Move.get(move_id)
|
||||||
next if move.id == :SKETCH || move.id == :STRUGGLE
|
next if move.id == :SKETCH || move.id == :STRUGGLE
|
||||||
return move.id
|
return move.id
|
||||||
@@ -151,10 +151,10 @@ def pbRandomPokemonFromRule(rules, trainer)
|
|||||||
iteration += 1
|
iteration += 1
|
||||||
species = nil
|
species = nil
|
||||||
level = rules.ruleset.suggestedLevel
|
level = rules.ruleset.suggestedLevel
|
||||||
keys = GameData::Species::DATA.keys
|
keys = GameData::Species.keys
|
||||||
loop do
|
loop do
|
||||||
loop do
|
loop do
|
||||||
species = keys[rand(keys.length)]
|
species = keys[keys.sample]
|
||||||
break if GameData::Species.get(species).form == 0
|
break if GameData::Species.get(species).form == 0
|
||||||
end
|
end
|
||||||
r = rand(20)
|
r = rand(20)
|
||||||
@@ -174,9 +174,9 @@ def pbRandomPokemonFromRule(rules, trainer)
|
|||||||
ev = []
|
ev = []
|
||||||
GameData::Stat.each_main { |s| ev.push(s.id) if rand(100) < 50 }
|
GameData::Stat.each_main { |s| ev.push(s.id) if rand(100) < 50 }
|
||||||
nature = nil
|
nature = nil
|
||||||
keys = GameData::Nature::DATA.keys
|
keys = GameData::Nature.keys
|
||||||
loop do
|
loop do
|
||||||
nature = keys[rand(keys.length)]
|
nature = keys[keys.sample]
|
||||||
nature_data = GameData::Nature.get(nature)
|
nature_data = GameData::Nature.get(nature)
|
||||||
if [:LAX, :GENTLE].include?(nature_data.id) || nature_data.stat_changes.length == 0
|
if [:LAX, :GENTLE].include?(nature_data.id) || nature_data.stat_changes.length == 0
|
||||||
next if rand(20) < 19
|
next if rand(20) < 19
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
|||||||
if GameData::TrainerType.exists?(:YOUNGSTER) && rand(30) == 0
|
if GameData::TrainerType.exists?(:YOUNGSTER) && rand(30) == 0
|
||||||
trainerid = :YOUNGSTER
|
trainerid = :YOUNGSTER
|
||||||
else
|
else
|
||||||
tr_typekeys = GameData::TrainerType::DATA.keys
|
tr_typekeys = GameData::TrainerType.keys
|
||||||
loop do
|
loop do
|
||||||
tr_type = tr_typekeys[rand(tr_typekeys.length)]
|
tr_type = tr_typekeys[tr_typekeys.sample]
|
||||||
tr_type_data = GameData::TrainerType.get(tr_type)
|
tr_type_data = GameData::TrainerType.get(tr_type)
|
||||||
next if tr_type_data.base_money >= 100
|
next if tr_type_data.base_money >= 100
|
||||||
trainerid = tr_type_data.id
|
trainerid = tr_type_data.id
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ def pbTrainerBattleEditor
|
|||||||
t = pbNewTrainer(tr_type, tr_name, tr_version, false)
|
t = pbNewTrainer(tr_type, tr_name, tr_version, false)
|
||||||
if t
|
if t
|
||||||
trainer_hash = {
|
trainer_hash = {
|
||||||
:id_number => GameData::Trainer::DATA.keys.length / 2,
|
:id_number => GameData::Trainer.count,
|
||||||
:trainer_type => tr_type,
|
:trainer_type => tr_type,
|
||||||
:name => tr_name,
|
:name => tr_name,
|
||||||
:version => tr_version,
|
:version => tr_version,
|
||||||
|
|||||||
Reference in New Issue
Block a user