mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
134 lines
3.5 KiB
Ruby
134 lines
3.5 KiB
Ruby
#===============================================================================
|
|
#
|
|
#===============================================================================
|
|
module GameData
|
|
class BagPocket
|
|
attr_reader :id
|
|
attr_reader :real_name
|
|
attr_reader :icon_position # Where this pocket's icon is within icon_pocket.png
|
|
attr_reader :order
|
|
attr_reader :max_slots
|
|
attr_reader :auto_sort
|
|
|
|
DATA = {}
|
|
|
|
extend ClassMethodsSymbols
|
|
include InstanceMethods
|
|
|
|
def self.load; end
|
|
def self.save; end
|
|
|
|
def self.all_pockets
|
|
ret = []
|
|
DATA.each_value { |pocket| ret.push([pocket.id, pocket.order]) }
|
|
ret.sort_by! { |pckt| pckt[1] }
|
|
ret.map! { |pckt| pckt[0] }
|
|
return ret
|
|
end
|
|
|
|
def self.index(pocket)
|
|
return self.all_pockets.index(pocket)
|
|
end
|
|
|
|
# @param other [Symbol, self, String]
|
|
# @return [self]
|
|
def self.get(other)
|
|
validate other => [Symbol, self, String, Integer]
|
|
return other if other.is_a?(self)
|
|
other = self.all_pockets[other - 1] if other.is_a?(Integer)
|
|
other = other.to_sym if other.is_a?(String)
|
|
raise "Unknown ID #{other}." unless self::DATA.has_key?(other)
|
|
return self::DATA[other]
|
|
end
|
|
|
|
# @param other [Symbol, self, String]
|
|
# @return [self, nil]
|
|
def try_get(other)
|
|
return nil if other.nil?
|
|
validate other => [Symbol, self, String, Integer]
|
|
return other if other.is_a?(self)
|
|
other = self.all_pockets[other - 1] if other.is_a?(Integer)
|
|
other = other.to_sym if other.is_a?(String)
|
|
return (self::DATA.has_key?(other)) ? self::DATA[other] : nil
|
|
end
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
def initialize(hash)
|
|
@id = hash[:id]
|
|
@real_name = hash[:name] || "Unnamed"
|
|
@icon_position = hash[:icon_position] || 0
|
|
@order = hash[:order] || 999
|
|
@max_slots = hash[:max_slots] || -1
|
|
@auto_sort = hash[:auto_sort] || false
|
|
end
|
|
|
|
# @return [String] the translated name of this nature
|
|
def name
|
|
return _INTL(@real_name)
|
|
end
|
|
end
|
|
end
|
|
|
|
#===============================================================================
|
|
#
|
|
#===============================================================================
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :Items,
|
|
:name => _INTL("Items"),
|
|
:icon_position => 0,
|
|
:order => 10
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :Medicine,
|
|
:name => _INTL("Medicine"),
|
|
:icon_position => 1,
|
|
:order => 20
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :PokeBalls,
|
|
:name => _INTL("Poké Balls"),
|
|
:icon_position => 2,
|
|
:order => 30
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :Machines,
|
|
:name => _INTL("TMs & HMs"),
|
|
:icon_position => 3,
|
|
:order => 40,
|
|
:auto_sort => true
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :Berries,
|
|
:name => _INTL("Berries"),
|
|
:icon_position => 4,
|
|
:order => 50,
|
|
:auto_sort => true
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :Mail,
|
|
:name => _INTL("Mail"),
|
|
:icon_position => 5,
|
|
:order => 60
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :BattleItems,
|
|
:name => _INTL("Battle Items"),
|
|
:icon_position => 6,
|
|
:order => 70
|
|
})
|
|
|
|
GameData::BagPocket.register({
|
|
:id => :KeyItems,
|
|
:name => _INTL("Key Items"),
|
|
:icon_position => 7,
|
|
:order => 80
|
|
})
|