mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Added class GameData::Stat
This commit is contained in:
@@ -1,68 +1,129 @@
|
||||
begin
|
||||
module PBStats
|
||||
# NOTE: You can change the order that the compiler expects Pokémon base
|
||||
# stats/EV yields (effort points) to be in, by simply renumbering the
|
||||
# stats here. The "main" stats (i.e. not accuracy/evasion) must still
|
||||
# use up numbers 0 to 5 inclusive, though. It's up to you to write the
|
||||
# base stats/EV yields in pokemon.txt and pokemonforms.txt in the
|
||||
# order expected.
|
||||
HP = 0
|
||||
ATTACK = 1
|
||||
DEFENSE = 2
|
||||
SPEED = 3
|
||||
SPATK = 4
|
||||
SPDEF = 5
|
||||
ACCURACY = 6
|
||||
EVASION = 7
|
||||
# The id_number value determines which order the stats are iterated through by
|
||||
# the "each" methods.
|
||||
# The pbs_order value determines the order in which the stats are written in
|
||||
# several PBS files, where base stats/IVs/EVs/EV yields are defined. Only stats
|
||||
# which are yielded by the "each_main" method can have stat numbers defined in
|
||||
# those places. The values of pbs_order defined below should start with 0 and
|
||||
# increase without skipping any numbers.
|
||||
module GameData
|
||||
class Stat
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
attr_reader :real_name
|
||||
attr_reader :real_name_brief
|
||||
attr_reader :type
|
||||
attr_reader :pbs_order
|
||||
|
||||
def self.getName(id)
|
||||
id = getID(PBStats,id)
|
||||
names = []
|
||||
names[HP] = _INTL("HP")
|
||||
names[ATTACK] = _INTL("Attack")
|
||||
names[DEFENSE] = _INTL("Defense")
|
||||
names[SPEED] = _INTL("Speed")
|
||||
names[SPATK] = _INTL("Special Attack")
|
||||
names[SPDEF] = _INTL("Special Defense")
|
||||
names[ACCURACY] = _INTL("accuracy")
|
||||
names[EVASION] = _INTL("evasiveness")
|
||||
return names[id]
|
||||
DATA = {}
|
||||
|
||||
extend ClassMethods
|
||||
include InstanceMethods
|
||||
|
||||
def self.load; end
|
||||
def self.save; end
|
||||
|
||||
# These stats are defined in PBS files, and should have the :pbs_order
|
||||
# property.
|
||||
def self.each_main
|
||||
self.each { |s| yield s if [:main, :main_battle].include?(s.type) }
|
||||
end
|
||||
|
||||
def self.getNameBrief(id)
|
||||
id = getID(PBStats,id)
|
||||
names = []
|
||||
names[HP] = _INTL("HP")
|
||||
names[ATTACK] = _INTL("Atk")
|
||||
names[DEFENSE] = _INTL("Def")
|
||||
names[SPEED] = _INTL("Spd")
|
||||
names[SPATK] = _INTL("SpAtk")
|
||||
names[SPDEF] = _INTL("SpDef")
|
||||
names[ACCURACY] = _INTL("acc")
|
||||
names[EVASION] = _INTL("eva")
|
||||
return names[id]
|
||||
def self.each_main_battle
|
||||
self.each { |s| yield s if [:main_battle].include?(s.type) }
|
||||
end
|
||||
|
||||
def self.eachStat
|
||||
[HP,ATTACK,DEFENSE,SPATK,SPDEF,SPEED].each { |s| yield s }
|
||||
# These stats have associated stat stages in battle.
|
||||
def self.each_battle
|
||||
self.each { |s| yield s if [:main_battle, :battle].include?(s.type) }
|
||||
end
|
||||
|
||||
def self.eachMainBattleStat
|
||||
[ATTACK,DEFENSE,SPATK,SPDEF,SPEED].each { |s| yield s }
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@id_number = hash[:id_number] || -1
|
||||
@real_name = hash[:name] || "Unnamed"
|
||||
@real_name_brief = hash[:name_brief] || "None"
|
||||
@type = hash[:type] || :none
|
||||
@pbs_order = hash[:pbs_order] || -1
|
||||
end
|
||||
|
||||
def self.eachBattleStat
|
||||
[ATTACK,DEFENSE,SPATK,SPDEF,SPEED,ACCURACY,EVASION].each { |s| yield s }
|
||||
# @return [String] the translated name of this stat
|
||||
def name
|
||||
return _INTL(@real_name)
|
||||
end
|
||||
|
||||
def self.validBattleStat?(stat)
|
||||
self.eachBattleStat { |s| return true if s==stat }
|
||||
return false
|
||||
# @return [String] the translated brief name of this stat
|
||||
def name_brief
|
||||
return _INTL(@real_name_brief)
|
||||
end
|
||||
end
|
||||
|
||||
rescue Exception
|
||||
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
|
||||
raise $!
|
||||
end
|
||||
end
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :HP,
|
||||
:id_number => 0,
|
||||
:name => _INTL("HP"),
|
||||
:name_brief => _INTL("HP"),
|
||||
:type => :main,
|
||||
:pbs_order => 0
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :ATTACK,
|
||||
:id_number => 1,
|
||||
:name => _INTL("Attack"),
|
||||
:name_brief => _INTL("Atk"),
|
||||
:type => :main_battle,
|
||||
:pbs_order => 1
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :DEFENSE,
|
||||
:id_number => 2,
|
||||
:name => _INTL("Defense"),
|
||||
:name_brief => _INTL("Def"),
|
||||
:type => :main_battle,
|
||||
:pbs_order => 2
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :SPECIAL_ATTACK,
|
||||
:id_number => 3,
|
||||
:name => _INTL("Special Attack"),
|
||||
:name_brief => _INTL("SpAtk"),
|
||||
:type => :main_battle,
|
||||
:pbs_order => 4
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :SPECIAL_DEFENSE,
|
||||
:id_number => 4,
|
||||
:name => _INTL("Special Defense"),
|
||||
:name_brief => _INTL("SpDef"),
|
||||
:type => :main_battle,
|
||||
:pbs_order => 5
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :SPEED,
|
||||
:id_number => 5,
|
||||
:name => _INTL("Speed"),
|
||||
:name_brief => _INTL("Spd"),
|
||||
:type => :main_battle,
|
||||
:pbs_order => 3
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :ACCURACY,
|
||||
:id_number => 6,
|
||||
:name => _INTL("accuracy"),
|
||||
:name_brief => _INTL("Acc"),
|
||||
:type => :battle
|
||||
})
|
||||
|
||||
GameData::Stat.register({
|
||||
:id => :EVASION,
|
||||
:id_number => 7,
|
||||
:name => _INTL("evasiveness"),
|
||||
:name_brief => _INTL("Eva"),
|
||||
:type => :battle
|
||||
})
|
||||
|
||||
@@ -37,35 +37,35 @@ GameData::Nature.register({
|
||||
:id => :LONELY,
|
||||
:id_number => 1,
|
||||
:name => _INTL("Lonely"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::DEFENSE, -10]]
|
||||
:stat_changes => [[:ATTACK, 10], [:DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :BRAVE,
|
||||
:id_number => 2,
|
||||
:name => _INTL("Brave"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPEED, -10]]
|
||||
:stat_changes => [[:ATTACK, 10], [:SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :ADAMANT,
|
||||
:id_number => 3,
|
||||
:name => _INTL("Adamant"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPATK, -10]]
|
||||
:stat_changes => [[:ATTACK, 10], [:SPECIAL_ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :NAUGHTY,
|
||||
:id_number => 4,
|
||||
:name => _INTL("Naughty"),
|
||||
:stat_changes => [[PBStats::ATTACK, 10], [PBStats::SPDEF, -10]]
|
||||
:stat_changes => [[:ATTACK, 10], [:SPECIAL_DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :BOLD,
|
||||
:id_number => 5,
|
||||
:name => _INTL("Bold"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::ATTACK, -10]]
|
||||
:stat_changes => [[:DEFENSE, 10], [:ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
@@ -78,35 +78,35 @@ GameData::Nature.register({
|
||||
:id => :RELAXED,
|
||||
:id_number => 7,
|
||||
:name => _INTL("Relaxed"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPEED, -10]]
|
||||
:stat_changes => [[:DEFENSE, 10], [:SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :IMPISH,
|
||||
:id_number => 8,
|
||||
:name => _INTL("Impish"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPATK, -10]]
|
||||
:stat_changes => [[:DEFENSE, 10], [:SPECIAL_ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :LAX,
|
||||
:id_number => 9,
|
||||
:name => _INTL("Lax"),
|
||||
:stat_changes => [[PBStats::DEFENSE, 10], [PBStats::SPDEF, -10]]
|
||||
:stat_changes => [[:DEFENSE, 10], [:SPECIAL_DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :TIMID,
|
||||
:id_number => 10,
|
||||
:name => _INTL("Timid"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::ATTACK, -10]]
|
||||
:stat_changes => [[:SPEED, 10], [:ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :HASTY,
|
||||
:id_number => 11,
|
||||
:name => _INTL("Hasty"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::DEFENSE, -10]]
|
||||
:stat_changes => [[:SPEED, 10], [:DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
@@ -119,35 +119,35 @@ GameData::Nature.register({
|
||||
:id => :JOLLY,
|
||||
:id_number => 13,
|
||||
:name => _INTL("Jolly"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::SPATK, -10]]
|
||||
:stat_changes => [[:SPEED, 10], [:SPECIAL_ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :NAIVE,
|
||||
:id_number => 14,
|
||||
:name => _INTL("Naive"),
|
||||
:stat_changes => [[PBStats::SPEED, 10], [PBStats::SPDEF, -10]]
|
||||
:stat_changes => [[:SPEED, 10], [:SPECIAL_DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :MODEST,
|
||||
:id_number => 15,
|
||||
:name => _INTL("Modest"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::ATTACK, -10]]
|
||||
:stat_changes => [[:SPECIAL_ATTACK, 10], [:ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :MILD,
|
||||
:id_number => 16,
|
||||
:name => _INTL("Mild"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::DEFENSE, -10]]
|
||||
:stat_changes => [[:SPECIAL_ATTACK, 10], [:DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :QUIET,
|
||||
:id_number => 17,
|
||||
:name => _INTL("Quiet"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::SPEED, -10]]
|
||||
:stat_changes => [[:SPECIAL_ATTACK, 10], [:SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
@@ -160,35 +160,35 @@ GameData::Nature.register({
|
||||
:id => :RASH,
|
||||
:id_number => 19,
|
||||
:name => _INTL("Rash"),
|
||||
:stat_changes => [[PBStats::SPATK, 10], [PBStats::SPDEF, -10]]
|
||||
:stat_changes => [[:SPECIAL_ATTACK, 10], [:SPECIAL_DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :CALM,
|
||||
:id_number => 20,
|
||||
:name => _INTL("Calm"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::ATTACK, -10]]
|
||||
:stat_changes => [[:SPECIAL_DEFENSE, 10], [:ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :GENTLE,
|
||||
:id_number => 21,
|
||||
:name => _INTL("Gentle"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::DEFENSE, -10]]
|
||||
:stat_changes => [[:SPECIAL_DEFENSE, 10], [:DEFENSE, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :SASSY,
|
||||
:id_number => 22,
|
||||
:name => _INTL("Sassy"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::SPEED, -10]]
|
||||
:stat_changes => [[:SPECIAL_DEFENSE, 10], [:SPEED, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
:id => :CAREFUL,
|
||||
:id_number => 23,
|
||||
:name => _INTL("Careful"),
|
||||
:stat_changes => [[PBStats::SPDEF, 10], [PBStats::SPATK, -10]]
|
||||
:stat_changes => [[:SPECIAL_DEFENSE, 10], [:SPECIAL_ATTACK, -10]]
|
||||
})
|
||||
|
||||
GameData::Nature.register({
|
||||
|
||||
Reference in New Issue
Block a user