class DesiredPerkSlot

  # TODO - DRY this up (also present in PerkSlot)
  PERK_SLOT_NAMES = [ 'barrels', 'magazines', 'perks1', 'perks2', 'masterworks' ]

  attr_reader :name
  attr_reader :desired_perks

  def initialize(name, desired_perks)
    @name = name
    @desired_perks = desired_perks
  end

  def self.desired_perk_slots_from_hash(data_hash)
    desired_perk_slots = {}
    data_hash.each do |slot_name, desired_perk_names|
      raise "'#{slot_name}' is not a valid perk slot name" unless PERK_SLOT_NAMES.include?(slot_name)
      perks = desired_perk_names.map{|n| Perk.from_name(n)}
      desired_perk_slots[slot_name] = DesiredPerkSlot.new(slot_name, perks)
    end
    desired_perk_slots
  end

end
