123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- 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
|