mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Implemented usage of GameData::Item
This commit is contained in:
@@ -194,9 +194,9 @@ module SpeciesData
|
||||
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
|
||||
:Ability, :Ability],
|
||||
"Habitat" => [HABITAT, "e", :PBHabitats],
|
||||
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems],
|
||||
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems],
|
||||
"WildItemRare" => [WILD_ITEM_RARE, "e", :PBItems],
|
||||
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :Item],
|
||||
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :Item],
|
||||
"WildItemRare" => [WILD_ITEM_RARE, "e", :Item],
|
||||
"BattlerPlayerX" => [METRIC_PLAYER_X, "i"],
|
||||
"BattlerPlayerY" => [METRIC_PLAYER_Y, "i"],
|
||||
"BattlerEnemyX" => [METRIC_ENEMY_X, "i"],
|
||||
@@ -210,12 +210,12 @@ module SpeciesData
|
||||
}
|
||||
if compilingForms
|
||||
ret["PokedexForm"] = [POKEDEX_FORM, "u"]
|
||||
ret["MegaStone"] = [MEGA_STONE, "e", :PBItems]
|
||||
ret["MegaStone"] = [MEGA_STONE, "e", :Item]
|
||||
ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves]
|
||||
ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
|
||||
ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
|
||||
else
|
||||
ret["Incense"] = [INCENSE, "e", :PBItems]
|
||||
ret["Incense"] = [INCENSE, "e", :Item]
|
||||
ret["RegionalNumbers"] = [0, "*u"]
|
||||
end
|
||||
return ret
|
||||
|
||||
@@ -102,3 +102,10 @@ class PBMoveData
|
||||
@flags = move_data[MoveData::FLAGS]
|
||||
end
|
||||
end
|
||||
|
||||
def pbIsHiddenMove?(move)
|
||||
GameData::Item.each do |i|
|
||||
return true if i.is_HM? && move == i.move
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
# A mixin module for data classes which provides common class methods (called
|
||||
# by PokemonData::Thing.method) that provide access to data held within.
|
||||
# by GameData::Thing.method) that provide access to data held within.
|
||||
# Assumes the data class's data is stored in a class constant hash called DATA.
|
||||
module ClassMethods
|
||||
# @param other [Symbol, self, Integer]
|
||||
# @param other [Symbol, self, String, Integer]
|
||||
# @return [Boolean] whether the given other is defined as a self
|
||||
def exists?(other)
|
||||
return false if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
other = other.id if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
other = other.id if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
return !self::DATA[other].nil?
|
||||
end
|
||||
|
||||
# @param other [Symbol, self, Integer]
|
||||
# @param other [Symbol, self, String, Integer]
|
||||
# @return [self]
|
||||
def get(other)
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
return other if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
return other if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
# if other.is_a?(Integer)
|
||||
# p "Please switch to symbols, thanks."
|
||||
# end
|
||||
@@ -26,8 +28,9 @@ module PokemonData
|
||||
|
||||
def try_get(other)
|
||||
return nil if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
return other if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
return other if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
# if other.is_a?(Integer)
|
||||
# p "Please switch to symbols, thanks."
|
||||
# end
|
||||
@@ -35,8 +38,7 @@ module PokemonData
|
||||
end
|
||||
|
||||
def each
|
||||
keys = self::DATA.keys
|
||||
keys.sort! { |a, b| a.id_number <=> b.id_number }
|
||||
keys = self::DATA.keys.sort { |a, b| self::DATA[a].id_number <=> self::DATA[b].id_number }
|
||||
keys.each do |key|
|
||||
yield self::DATA[key] if key.is_a?(Symbol)
|
||||
end
|
||||
@@ -55,15 +57,17 @@ module PokemonData
|
||||
# (called by thing.method) that analyse the data of a particular thing which
|
||||
# the instance represents.
|
||||
module InstanceMethods
|
||||
# @param other [Symbol, self.class, Integer]
|
||||
# @param other [Symbol, self.class, String, Integer]
|
||||
# @return [Boolean] whether other represents the same thing as this thing
|
||||
def ==(other)
|
||||
return false if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
validate other => [Symbol, self.class, String, Integer]
|
||||
if other.is_a?(Symbol)
|
||||
return @id == other
|
||||
elsif other.is_a?(self.class)
|
||||
return @id == other.id
|
||||
elsif other.is_a?(String)
|
||||
return @id_number == other.to_sym
|
||||
elsif other.is_a?(Integer)
|
||||
return @id_number == other
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
class Item
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
@@ -47,54 +47,187 @@ module PokemonData
|
||||
def description
|
||||
return pbGetMessage(MessageTypes::ItemDescriptions, @id_number)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def is_TM?; return @field_use == 3; end
|
||||
def is_HM?; return @field_use == 4; end
|
||||
def is_machine?; return is_TM? || is_HM?; end
|
||||
def is_mail?; return @type == 1 || @type == 2; end
|
||||
def is_icon_mail?; return @type == 2; end
|
||||
def is_poke_ball?; return @type == 3 || @type == 4; end
|
||||
def is_snag_ball?; return @type == 3 || (@type == 4 && $PokemonGlobal.snagMachine); end
|
||||
def is_berry?; return @type == 5; end
|
||||
def is_key_item?; return @type == 6; end
|
||||
def is_evolution_stone?; return @type == 7; end
|
||||
def is_fossil?; return @type == 8; end
|
||||
def is_apricorn?; return @type == 9; end
|
||||
def is_gem?; return @type == 10; end
|
||||
def is_mulch?; return @type == 11; end
|
||||
def is_mega_stone?; return @type == 12; end # Does NOT include Red Orb/Blue Orb
|
||||
|
||||
def is_important?
|
||||
return true if is_key_item? || is_HM?
|
||||
return true if is_TM? && INFINITE_TMS
|
||||
return false
|
||||
end
|
||||
|
||||
module Compiler
|
||||
module_function
|
||||
def can_hold?; return !is_important?; end
|
||||
|
||||
def compile_items
|
||||
item_names = []
|
||||
item_names_plural = []
|
||||
item_descriptions = []
|
||||
# Read each line of items.txt at a time and compile it into an item
|
||||
pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"])
|
||||
item_number = line[0]
|
||||
item_symbol = line[1].to_sym
|
||||
if PokemonData::Item::DATA[item_number]
|
||||
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}", item_number, FileLineData.linereport)
|
||||
elsif PokemonData::Item::DATA[item_symbol]
|
||||
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport)
|
||||
end
|
||||
# Construct item hash
|
||||
item_hash = {
|
||||
:id_number => item_number,
|
||||
:id => item_symbol,
|
||||
:name => line[2],
|
||||
:name_plural => line[3],
|
||||
:pocket => line[4],
|
||||
:price => line[5],
|
||||
:description => line[6],
|
||||
:field_use => line[7],
|
||||
:battle_use => line[8],
|
||||
:type => line[9]
|
||||
def unlosable?(species, ability)
|
||||
return false if isConst?(species, PBSpecies, :ARCEUS) && ability != :MULTITYPE
|
||||
return false if isConst?(species, PBSpecies, :SILVALLY) && ability != :RKSSYSTEM
|
||||
combos = {
|
||||
:ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
|
||||
:SKYPLATE, :FLYINIUMZ,
|
||||
:TOXICPLATE, :POISONIUMZ,
|
||||
:EARTHPLATE, :GROUNDIUMZ,
|
||||
:STONEPLATE, :ROCKIUMZ,
|
||||
:INSECTPLATE, :BUGINIUMZ,
|
||||
:SPOOKYPLATE, :GHOSTIUMZ,
|
||||
:IRONPLATE, :STEELIUMZ,
|
||||
:FLAMEPLATE, :FIRIUMZ,
|
||||
:SPLASHPLATE, :WATERIUMZ,
|
||||
:MEADOWPLATE, :GRASSIUMZ,
|
||||
:ZAPPLATE, :ELECTRIUMZ,
|
||||
:MINDPLATE, :PSYCHIUMZ,
|
||||
:ICICLEPLATE, :ICIUMZ,
|
||||
:DRACOPLATE, :DRAGONIUMZ,
|
||||
:DREADPLATE, :DARKINIUMZ,
|
||||
:PIXIEPLATE, :FAIRIUMZ],
|
||||
:SILVALLY => [:FIGHTINGMEMORY,
|
||||
:FLYINGMEMORY,
|
||||
:POISONMEMORY,
|
||||
:GROUNDMEMORY,
|
||||
:ROCKMEMORY,
|
||||
:BUGMEMORY,
|
||||
:GHOSTMEMORY,
|
||||
:STEELMEMORY,
|
||||
:FIREMEMORY,
|
||||
:WATERMEMORY,
|
||||
:GRASSMEMORY,
|
||||
:ELECTRICMEMORY,
|
||||
:PSYCHICMEMORY,
|
||||
:ICEMEMORY,
|
||||
:DRAGONMEMORY,
|
||||
:DARKMEMORY,
|
||||
:FAIRYMEMORY],
|
||||
:GIRATINA => [:GRISEOUSORB],
|
||||
:GENESECT => [:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE],
|
||||
:KYOGRE => [:BLUEORB],
|
||||
:GROUDON => [:REDORB]
|
||||
}
|
||||
item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
|
||||
# Add item's data to records
|
||||
PokemonData::Item::DATA[item_number] = PokemonData::Item::DATA[item_symbol] = PokemonData::Item.new(item_hash)
|
||||
item_names[item_number] = item_hash[:name]
|
||||
item_names_plural[item_number] = item_hash[:name_plural]
|
||||
item_descriptions[item_number] = item_hash[:description]
|
||||
}
|
||||
# Save all data
|
||||
PokemonData::Item.save
|
||||
MessageTypes.setMessages(MessageTypes::Items, item_names)
|
||||
MessageTypes.setMessages(MessageTypes::ItemPlurals, item_names_plural)
|
||||
MessageTypes.setMessages(MessageTypes::ItemDescriptions, item_descriptions)
|
||||
|
||||
Graphics.update
|
||||
combos.each do |comboSpecies, items|
|
||||
next if !isConst?(species, PBSpecies, comboSpecies)
|
||||
return items.include?(@id)
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Deprecated methods
|
||||
#===============================================================================
|
||||
def pbGetPocket(item)
|
||||
Deprecation.warn_method('pbGetPocket', 'v20', 'GameData::Item.get(item).pocket')
|
||||
return GameData::Item.get(item).pocket
|
||||
end
|
||||
|
||||
def pbGetPrice(item)
|
||||
Deprecation.warn_method('pbGetPrice', 'v20', 'GameData::Item.get(item).price')
|
||||
return GameData::Item.get(item).price
|
||||
end
|
||||
|
||||
def pbGetMachine(item)
|
||||
Deprecation.warn_method('pbGetMachine', 'v20', 'GameData::Item.get(item).move')
|
||||
return GameData::Item.get(item).move
|
||||
end
|
||||
|
||||
def pbIsTechnicalMachine?(item)
|
||||
Deprecation.warn_method('pbIsTechnicalMachine?', 'v20', 'GameData::Item.get(item).is_TM?')
|
||||
return GameData::Item.get(item).is_TM?
|
||||
end
|
||||
|
||||
def pbIsHiddenMachine?(item)
|
||||
Deprecation.warn_method('pbIsHiddenMachine?', 'v20', 'GameData::Item.get(item).is_HM?')
|
||||
return GameData::Item.get(item).is_HM?
|
||||
end
|
||||
|
||||
def pbIsMachine?(item)
|
||||
Deprecation.warn_method('pbIsMachine?', 'v20', 'GameData::Item.get(item).is_machine?')
|
||||
return GameData::Item.get(item).is_machine?
|
||||
end
|
||||
|
||||
def pbIsMail?(item)
|
||||
Deprecation.warn_method('pbIsMail?', 'v20', 'GameData::Item.get(item).is_mail?')
|
||||
return GameData::Item.get(item).is_mail?
|
||||
end
|
||||
|
||||
def pbIsMailWithPokemonIcons?(item)
|
||||
Deprecation.warn_method('pbIsMailWithPokemonIcons?', 'v20', 'GameData::Item.get(item).is_icon_mail?')
|
||||
return GameData::Item.get(item).is_icon_mail?
|
||||
end
|
||||
|
||||
def pbIsPokeBall?(item)
|
||||
Deprecation.warn_method('pbIsPokeBall?', 'v20', 'GameData::Item.get(item).is_poke_ball?')
|
||||
return GameData::Item.get(item).is_poke_ball?
|
||||
end
|
||||
|
||||
def pbIsSnagBall?(item)
|
||||
Deprecation.warn_method('pbIsSnagBall?', 'v20', 'GameData::Item.get(item).is_snag_ball?')
|
||||
return GameData::Item.get(item).is_snag_ball?
|
||||
end
|
||||
|
||||
def pbIsBerry?(item)
|
||||
Deprecation.warn_method('pbIsBerry?', 'v20', 'GameData::Item.get(item).is_berry?')
|
||||
return GameData::Item.get(item).is_berry?
|
||||
end
|
||||
|
||||
def pbIsKeyItem?(item)
|
||||
Deprecation.warn_method('pbIsKeyItem?', 'v20', 'GameData::Item.get(item).is_key_item?')
|
||||
return GameData::Item.get(item).is_key_item?
|
||||
end
|
||||
|
||||
def pbIsEvolutionStone?(item)
|
||||
Deprecation.warn_method('pbIsEvolutionStone?', 'v20', 'GameData::Item.get(item).is_evolution_stone?')
|
||||
return GameData::Item.get(item).is_evolution_stone?
|
||||
end
|
||||
|
||||
def pbIsFossil?(item)
|
||||
Deprecation.warn_method('pbIsFossil?', 'v20', 'GameData::Item.get(item).is_fossil?')
|
||||
return GameData::Item.get(item).is_fossil?
|
||||
end
|
||||
|
||||
def pbIsApricorn?(item)
|
||||
Deprecation.warn_method('pbIsApricorn?', 'v20', 'GameData::Item.get(item).is_apricorn?')
|
||||
return GameData::Item.get(item).is_apricorn?
|
||||
end
|
||||
|
||||
def pbIsGem?(item)
|
||||
Deprecation.warn_method('pbIsGem?', 'v20', 'GameData::Item.get(item).is_gem?')
|
||||
return GameData::Item.get(item).is_gem?
|
||||
end
|
||||
|
||||
def pbIsMulch?(item)
|
||||
Deprecation.warn_method('pbIsMulch?', 'v20', 'GameData::Item.get(item).is_mulch?')
|
||||
return GameData::Item.get(item).is_mulch?
|
||||
end
|
||||
|
||||
def pbIsMegaStone?(item)
|
||||
Deprecation.warn_method('pbIsMegaStone?', 'v20', 'GameData::Item.get(item).is_mega_stone?')
|
||||
return GameData::Item.get(item).is_mega_stone?
|
||||
end
|
||||
|
||||
def pbIsImportantItem?(item)
|
||||
Deprecation.warn_method('pbIsImportantItem?', 'v20', 'GameData::Item.get(item).is_important?')
|
||||
return GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def pbCanHoldItem?(item)
|
||||
Deprecation.warn_method('pbCanHoldItem?', 'v20', 'GameData::Item.get(item).can_hold?')
|
||||
return GameData::Item.get(item).can_hold?
|
||||
end
|
||||
|
||||
def pbIsUnlosableItem?(check_item, species, ability)
|
||||
Deprecation.warn_method('pbIsUnlosableItem?', 'v20', 'GameData::Item.get(item).unlosable?')
|
||||
return GameData::Item.get(check_item).unlosable?(species, ability)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
class Ability
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
|
||||
Reference in New Issue
Block a user