class Game_System
  attr_accessor :subpartyList
  
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias tako4124979initialize initialize
  def initialize
    tako4124979initialize
    @subpartyList = [Game_Party.new,Game_Party.new,Game_Party.new] 
    set_init_subparty_member

#~     set_party0
  end  
  
  def change_party(id)
    $game_party = @subpartyList[id]
    $game_player.refresh
  end  
  
  def save_party(id)
    @subpartyList[id] = $game_party
  end  

  def union_party(id,id2)
    
    @subpartyList[id].set_actors(@subpartyList[id].actors.clone + @subpartyList[id2].actors.clone)
    @subpartyList[id].gain_gold(@subpartyList[id2].gold)

    @subpartyList[id].add_items_hash(@subpartyList[id].hash_items,@subpartyList[id2].hash_items) 
    @subpartyList[id].add_items_hash(@subpartyList[id].hash_weapons,@subpartyList[id2].hash_weapons)     
    @subpartyList[id].add_items_hash(@subpartyList[id].hash_armors,@subpartyList[id2].hash_armors)     
    $game_player.refresh
  end    
  
  def copy_party(id1,id2)
    @subpartyList[id1] = @subpartyList[id2]
  end  
  
  def set_init_subparty_member
    3.times {|i| @subpartyList[i].set_actors($data_subparty_init_actors[i].clone)}    

  end  

end

class Game_Party < Game_Unit
#--------------------------------------------------------------------------
  # ● メンバーの取得
  #--------------------------------------------------------------------------
  def set_actors(array)
    @actors = array
  end
  
  def actors
    @actors
  end  
  
  def hash_items
    @items
  end  
  
  def hash_weapons
    @weapons
  end   
  
  def hash_armors
    @armors
  end   
  

  def add_items_hash(ohash,hash)
    hash.each do |key , value|
      newnum = ohash.has_key?(key) ? [ohash[key] + value, max_item_number(key)].min : value
      ohash[key] = newnum
    end  
    
  end  
  
end    