
require './models.rb'
require './db.rb'

def find_corde_by_codename code_name, cordes
    cordes.each do |corde|
      return corde if corde.code_name == code_name
    end
    nil
end

moods = {
  lovely: Mood.new('Lovely')
}
brands = {
  time: Brand.new('Fantacy Time', moods[:lovely])
}

all_cordes = []
.concat(@topscordes)
.concat(@bottomscordes)
.concat(@onepiececordes)
.concat(@shoescordes)
.concat(@othercordes)

set_owner = Persona.new('システム', 'システムでーす')
owner = Persona.new('鳥', '青')

weekly_color = '赤'

have_cordes = [
  ['2-01-020', owner],
  ['T1-049', owner],
  ['2-014', owner],
  ['T1-048',  owner],
  ['T1-047', owner],
  ['H-02-029', owner],
  ['2-01-019', owner],
  ['2-014', owner],
  ['1-022', owner],
  ['T1-015', owner],
  ['03-001', owner],
  ['03-002', owner],
  ['03-003', owner],
  
].map{|corde|  HaveCorde.new(find_corde_by_codename(corde[0], all_cordes), owner, corde[1]) }

tops_cordes = have_cordes.select {|item| item.corde.class == TopsCorde}
bottoms_cordes = have_cordes.select {|item| item.corde.class == BottomsCorde}
onepieces_cordes = have_cordes.select {|item| item.corde.class == OnePieceCorde}
shoes_cordes = have_cordes.select {|item| item.corde.class == ShoesCorde}

results = []
# トップス/ボトムス/シューズの組み合わせ
tops_cordes.each do |tops|
  bottoms_cordes.each do |bottoms|
    shoes_cordes.each do | shoes|
      corde_set = CordeSet.new tops, bottoms, nil, shoes, nil
      # ぴったりコーデ3(仮)
      # bonus_point = 500
      # ぴったりコーデ2(仮)
      # bonus_point = 300
      # イチオシ(仮)
      # bonus_point = 500
      results << corde_set
    end
  end
end

# ワンピース/シューズの組み合わせ
onepiece_shoes_scores = []
onepieces_cordes.each do |onepieces|
  shoes_cordes.each do | shoes|
    corde_set = CordeSet.new nil, nil, onepieces, shoes, nil
    # ぴったりコーデ3(仮)
    # bonus_point = 500
    # ぴったりコーデ2(仮)
    # bonus_point = 300
    # イチオシ(仮)
    # bonus_point = 500
    results << corde_set
  end
end
rank = results.sort {|a, b| b.total_point <=> a.total_point}
rank.each do |best_corde|
      puts "#{best_corde} Base: #{best_corde.base_point} Total: #{best_corde.total_point}"
end
