Implemented usage of GameData::Item

This commit is contained in:
Maruno17
2020-11-08 22:45:59 +00:00
parent ff70791104
commit 1955d3698e
82 changed files with 1986 additions and 2195 deletions

View File

@@ -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