class Persona
  attr_reader :manager, :manager_color
  def initialize manager, manager_color
    @manager = manager
    @manager_color = manager_color
  end

  def equal_manager_and_color persona
    equal_manager(persona) and equal_manager_color(persona)
  end
  def equal_manager persona
    persona.manager == @manager
  end
  def equal_manager_color persona
    persona.manager_color == @manager_color
  end

end

class Brand
  attr_reader :name, :mood
  def initialize name, mood
    @name = name
    @mood = mood
  end
end

class Mood
  attr_reader :name
  def initialize name
    @name = name
  end
end

class Corde
  attr_reader :code_name, :name, :rarity, :like, :color, :brand
  def initialize code_name, name, rarity, like, color, brand
    @code_name = code_name
    @name = name
    @rarity = rarity
    @like = like.to_i
    @color = color
    @brand = brand
  end
end

class HairsCorde < Corde
end

class TopsCorde < Corde
end

class BottomsCorde < Corde
end

class OnePieceCorde < Corde
end

class ShoesCorde < Corde
end

class OtherCorde < Corde
end

class HaveCorde
  attr_reader :corde, :user, :owner
  def initialize corde, user, owner
    @corde = corde
    @owner = owner
    @user = user
  end
end

class Music
  attr_reader :name, :mood, :norts1, :norts2, :norts3, :best_effort_score

  def bonus_point corde_set
    [
    ].reduce do |calculator|
      calculator.calc self, corde_set
    end
  end
end

class BaseCordeSet
  attr_reader :tops, :bottoms, :onepieces, :shoes, :hairs
  def initialize tops, bottoms, onepieces, shoes, hairs
    @tops = tops
    @bottoms = bottoms
    @onepieces = onepieces
    @shoes = shoes
    @hairs = hairs
  end
end

class CordeSet < BaseCordeSet
  def use_onepieces?
    @onepieces
  end

  def base_point
    return @onepieces.corde.like + @shoes.corde.like if self.use_onepieces?
    @tops.corde.like + @bottoms.corde.like + @shoes.corde.like
  end

  def bonus_point
    point = 0
    [
      BrandBonusCalculator,
      ManagerBonusCalculator
    ].each do |calculator|
      if self.use_onepieces?
        point += calculator.calc_onepieces(self).to_i
      else
        point += calculator.calc(self).to_i
      end
    end
    point
  end

  def total_point
    base_point + bonus_point
  end

  def to_s
    return "#{onepieces.corde.name}/#{shoes.corde.name}" if self.use_onepieces?
    "#{tops.corde.name}/#{bottoms.corde.name}/#{shoes.corde.name}"
  end
end

class FriendTicket < BaseCordeSet
end

class CampaignStatus
  attr_reader :bonus_color
  def initialize bonus_color
    @bonus_color = bonus_color
  end
end

class BaseCordeBonusCalculator
  def self.calc corde_set
    0
  end
  class << self
    alias_method :calc_onepieces, :calc
  end
end
class BaseFriendBonusCalculator
  def self.calc friend_ticket, corde_set
    0
  end
end

class BaseMusicBonusCalculator
  def self.calc music, corde_set
    0
  end
end

class BrandBonusCalculator < BaseCordeBonusCalculator
  def self.calc corde_set
    # p "BrandBonusCalculator"
    tops = corde_set.tops.corde
    bottoms = corde_set.bottoms.corde
    shoes = corde_set.shoes.corde
    # ブランド3
    return 300 if [tops.brand, bottoms.brand, shoes.brand].uniq.count == 1
    # ブランド2
    return 200 if [tops.brand, bottoms.brand, shoes.brand].uniq.count == 2
    # ミックス1
    100
  end

  def self.calc_onepieces corde_set
    # p "BrandBonusCalculator OP"
    onepieces = corde_set.onepieces.corde
    shoes = corde_set.shoes.corde
    # ブランド2
    return 200 if [onepieces.brand, shoes.brand].uniq.count == 1
    # ミックス1
    100
  end
end

class ManagerBonusCalculator < BaseCordeBonusCalculator
  def self.calc corde_set
    # p "ManagerBonusCalculator"
    tops = corde_set.tops
    bottoms = corde_set.bottoms
    shoes = corde_set.shoes
    eq_tops = tops.owner.equal_manager_and_color(tops.user)
    eq_bottoms = bottoms.owner.equal_manager_and_color(bottoms.user)
    eq_shoes = shoes.owner.equal_manager_and_color(shoes.user)
    return 1000 if eq_tops and eq_bottoms and eq_shoes
    0
  end
  def self.calc_onepieces corde_set
    # p "ManagerBonusCalculator OP"
    onepieces = corde_set.onepieces
    shoes = corde_set.shoes
    return 1000 if onepieces.owner.equal_manager_and_color(onepieces.user) and shoes.owner.equal_manager_and_color(shoes.user)
    0
  end
end
