mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Implemented GameData::Nature, improved registration of GameData entries
This commit is contained in:
@@ -4,6 +4,10 @@ module GameData
|
||||
# Assumes the data class's data is stored in a class constant hash called DATA.
|
||||
# For data that is known by a symbol or an ID number.
|
||||
module ClassMethods
|
||||
def register(hash)
|
||||
self::DATA[hash[:id]] = self::DATA[hash[:id_number]] = self.new(hash)
|
||||
end
|
||||
|
||||
# @param other [Symbol, self, String, Integer]
|
||||
# @return [Boolean] whether the given other is defined as a self
|
||||
def exists?(other)
|
||||
@@ -60,6 +64,10 @@ module GameData
|
||||
# Assumes the data class's data is stored in a class constant hash called DATA.
|
||||
# For data that is only known by an ID number.
|
||||
module ClassMethodsIDNumbers
|
||||
def register(hash)
|
||||
self::DATA[hash[:id]] = self.new(hash)
|
||||
end
|
||||
|
||||
# @param other [self, Integer]
|
||||
# @return [Boolean] whether the given other is defined as a self
|
||||
def exists?(other)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module GameData
|
||||
class Trainer
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
attr_reader :trainer_type
|
||||
attr_reader :real_name
|
||||
@@ -22,7 +23,7 @@ module GameData
|
||||
"Item" => [:item, "e", :Item],
|
||||
"Gender" => [:gender, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
|
||||
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }],
|
||||
"Nature" => [:nature, "e", :PBNatures],
|
||||
"Nature" => [:nature, "e", :Nature],
|
||||
"IV" => [:iv, "uUUUUU"],
|
||||
"EV" => [:ev, "uUUUUU"],
|
||||
"Happiness" => [:happiness, "u"],
|
||||
@@ -67,7 +68,8 @@ module GameData
|
||||
end
|
||||
|
||||
def initialize(hash)
|
||||
@id_number = hash[:id]
|
||||
@id = hash[:id]
|
||||
@id_number = hash[:id_number]
|
||||
@trainer_type = hash[:trainer_type]
|
||||
@real_name = hash[:name] || "Unnamed"
|
||||
@version = hash[:version] || 0
|
||||
@@ -132,7 +134,7 @@ module GameData
|
||||
pkmn.nature = pkmn_data[:nature]
|
||||
else
|
||||
nature = pkmn.species_data.id_number + GameData::TrainerType.get(trainer.trainer_type).id_number
|
||||
pkmn.nature = nature % (PBNatures.maxValue + 1)
|
||||
pkmn.nature = nature % (GameData::Nature::DATA.length / 2)
|
||||
end
|
||||
PBStats.eachStat do |s|
|
||||
if pkmn_data[:iv] && pkmn_data[:iv].length > 0
|
||||
|
||||
198
Data/Scripts/011_Data/Hardcoded game data/003_Nature.rb
Normal file
198
Data/Scripts/011_Data/Hardcoded game data/003_Nature.rb
Normal file
@@ -0,0 +1,198 @@
|
||||
module GameData
|
||||
class Nature
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
attr_reader :real_name
|
||||
attr_reader :stat_changes
|
||||
|
||||
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"
|
||||
@stat_changes = hash[:stat_changes] || []
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this nature
|
||||
def name
|
||||
return _INTL(@real_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :HARDY,
|
||||
:id_number => 0,
|
||||
:name => _INTL("Hardy")
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :LONELY,
|
||||
:id_number => 1,
|
||||
:name => _INTL("Lonely"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :BRAVE,
|
||||
:id_number => 2,
|
||||
:name => _INTL("Brave"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :ADAMANT,
|
||||
:id_number => 3,
|
||||
:name => _INTL("Adamant"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPATK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :NAUGHTY,
|
||||
:id_number => 4,
|
||||
:name => _INTL("Naughty"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPDEF, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :BOLD,
|
||||
:id_number => 5,
|
||||
:name => _INTL("Bold"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :DOCILE,
|
||||
:id_number => 6,
|
||||
:name => _INTL("Docile")
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :RELAXED,
|
||||
:id_number => 7,
|
||||
:name => _INTL("Relaxed"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :IMPISH,
|
||||
:id_number => 8,
|
||||
:name => _INTL("Impish"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPATK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :LAX,
|
||||
:id_number => 9,
|
||||
:name => _INTL("Lax"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPDEF, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :TIMID,
|
||||
:id_number => 10,
|
||||
:name => _INTL("Timid"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :HASTY,
|
||||
:id_number => 11,
|
||||
:name => _INTL("Hasty"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :SERIOUS,
|
||||
:id_number => 12,
|
||||
:name => _INTL("Serious")
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :JOLLY,
|
||||
:id_number => 13,
|
||||
:name => _INTL("Jolly"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::SPATK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :NAIVE,
|
||||
:id_number => 14,
|
||||
:name => _INTL("Naive"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::SPDEF, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :MODEST,
|
||||
:id_number => 15,
|
||||
:name => _INTL("Modest"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :MILD,
|
||||
:id_number => 16,
|
||||
:name => _INTL("Mild"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :QUIET,
|
||||
:id_number => 17,
|
||||
:name => _INTL("Quiet"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :BASHFUL,
|
||||
:id_number => 18,
|
||||
:name => _INTL("Bashful")
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :RASH,
|
||||
:id_number => 19,
|
||||
:name => _INTL("Rash"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::SPDEF, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :CALM,
|
||||
:id_number => 20,
|
||||
:name => _INTL("Calm"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :GENTLE,
|
||||
:id_number => 21,
|
||||
:name => _INTL("Gentle"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :SASSY,
|
||||
:id_number => 22,
|
||||
:name => _INTL("Sassy"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :CAREFUL,
|
||||
:id_number => 23,
|
||||
:name => _INTL("Careful"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::SPATK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :QUIRKY,
|
||||
:id_number => 24,
|
||||
:name => _INTL("Quirky")
|
||||
})
|
||||
@@ -1,88 +0,0 @@
|
||||
module PBNatures
|
||||
HARDY = 0
|
||||
LONELY = 1
|
||||
BRAVE = 2
|
||||
ADAMANT = 3
|
||||
NAUGHTY = 4
|
||||
BOLD = 5
|
||||
DOCILE = 6
|
||||
RELAXED = 7
|
||||
IMPISH = 8
|
||||
LAX = 9
|
||||
TIMID = 10
|
||||
HASTY = 11
|
||||
SERIOUS = 12
|
||||
JOLLY = 13
|
||||
NAIVE = 14
|
||||
MODEST = 15
|
||||
MILD = 16
|
||||
QUIET = 17
|
||||
BASHFUL = 18
|
||||
RASH = 19
|
||||
CALM = 20
|
||||
GENTLE = 21
|
||||
SASSY = 22
|
||||
CAREFUL = 23
|
||||
QUIRKY = 24
|
||||
|
||||
def self.maxValue; 24; end
|
||||
|
||||
def self.getName(id)
|
||||
id = getID(PBNatures, id)
|
||||
names = [
|
||||
_INTL("Hardy"),
|
||||
_INTL("Lonely"),
|
||||
_INTL("Brave"),
|
||||
_INTL("Adamant"),
|
||||
_INTL("Naughty"),
|
||||
_INTL("Bold"),
|
||||
_INTL("Docile"),
|
||||
_INTL("Relaxed"),
|
||||
_INTL("Impish"),
|
||||
_INTL("Lax"),
|
||||
_INTL("Timid"),
|
||||
_INTL("Hasty"),
|
||||
_INTL("Serious"),
|
||||
_INTL("Jolly"),
|
||||
_INTL("Naive"),
|
||||
_INTL("Modest"),
|
||||
_INTL("Mild"),
|
||||
_INTL("Quiet"),
|
||||
_INTL("Bashful"),
|
||||
_INTL("Rash"),
|
||||
_INTL("Calm"),
|
||||
_INTL("Gentle"),
|
||||
_INTL("Sassy"),
|
||||
_INTL("Careful"),
|
||||
_INTL("Quirky")
|
||||
]
|
||||
return names[id]
|
||||
end
|
||||
|
||||
def self.getStatRaised(id)
|
||||
stats = [PBStats::ATTACK, PBStats::DEFENSE, PBStats::SPEED,
|
||||
PBStats::SPATK, PBStats::SPDEF]
|
||||
m = (id % (stats.length ** 2)) / stats.length
|
||||
return stats[m]
|
||||
end
|
||||
|
||||
def self.getStatLowered(id)
|
||||
stats = [PBStats::ATTACK, PBStats::DEFENSE, PBStats::SPEED,
|
||||
PBStats::SPATK, PBStats::SPDEF]
|
||||
m = id % stats.length
|
||||
return stats[m]
|
||||
end
|
||||
|
||||
def self.getStatChanges(id)
|
||||
id = getID(PBNatures,id)
|
||||
up = PBNatures.getStatRaised(id)
|
||||
dn = PBNatures.getStatLowered(id)
|
||||
ret = []
|
||||
PBStats.eachStat do |s|
|
||||
ret[s] = 100
|
||||
ret[s] += 10 if s==up
|
||||
ret[s] -= 10 if s==dn
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user