models.rb 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. class Persona
  2. attr_reader :manager, :manager_color
  3. def initialize manager, manager_color
  4. @manager = manager
  5. @manager_color = manager_color
  6. end
  7. def equal_manager_and_color persona
  8. equal_manager(persona) and equal_manager_color(persona)
  9. end
  10. def equal_manager persona
  11. persona.manager == @manager
  12. end
  13. def equal_manager_color persona
  14. persona.manager_color == @manager_color
  15. end
  16. end
  17. class Brand
  18. attr_reader :name, :mood
  19. def initialize name, mood
  20. @name = name
  21. @mood = mood
  22. end
  23. end
  24. class Mood
  25. attr_reader :name
  26. def initialize name
  27. @name = name
  28. end
  29. end
  30. class Corde
  31. attr_reader :code_name, :name, :rarity, :like, :color, :brand
  32. def initialize code_name, name, rarity, like, color, brand
  33. @code_name = code_name
  34. @name = name
  35. @rarity = rarity
  36. @like = like.to_i
  37. @color = color
  38. @brand = brand
  39. end
  40. end
  41. class HairsCorde < Corde
  42. end
  43. class TopsCorde < Corde
  44. end
  45. class BottomsCorde < Corde
  46. end
  47. class OnePieceCorde < Corde
  48. end
  49. class ShoesCorde < Corde
  50. end
  51. class OtherCorde < Corde
  52. end
  53. class HaveCorde
  54. attr_reader :corde, :user, :owner
  55. def initialize corde, user, owner
  56. @corde = corde
  57. @owner = owner
  58. @user = user
  59. end
  60. end
  61. class Music
  62. attr_reader :name, :mood, :norts1, :norts2, :norts3, :best_effort_score
  63. def bonus_point corde_set
  64. [
  65. ].reduce do |calculator|
  66. calculator.calc self, corde_set
  67. end
  68. end
  69. end
  70. class BaseCordeSet
  71. attr_reader :tops, :bottoms, :onepieces, :shoes, :hairs
  72. def initialize tops, bottoms, onepieces, shoes, hairs
  73. @tops = tops
  74. @bottoms = bottoms
  75. @onepieces = onepieces
  76. @shoes = shoes
  77. @hairs = hairs
  78. end
  79. end
  80. class CordeSet < BaseCordeSet
  81. def use_onepieces?
  82. @onepieces
  83. end
  84. def base_point
  85. return @onepieces.corde.like + @shoes.corde.like if self.use_onepieces?
  86. @tops.corde.like + @bottoms.corde.like + @shoes.corde.like
  87. end
  88. def bonus_point
  89. point = 0
  90. [
  91. BrandBonusCalculator,
  92. ManagerBonusCalculator
  93. ].each do |calculator|
  94. if self.use_onepieces?
  95. point += calculator.calc_onepieces(self).to_i
  96. else
  97. point += calculator.calc(self).to_i
  98. end
  99. end
  100. point
  101. end
  102. def total_point
  103. base_point + bonus_point
  104. end
  105. def to_s
  106. return "#{onepieces.corde.name}/#{shoes.corde.name}" if self.use_onepieces?
  107. "#{tops.corde.name}/#{bottoms.corde.name}/#{shoes.corde.name}"
  108. end
  109. end
  110. class FriendTicket < BaseCordeSet
  111. end
  112. class CampaignStatus
  113. attr_reader :bonus_color
  114. def initialize bonus_color
  115. @bonus_color = bonus_color
  116. end
  117. end
  118. class BaseCordeBonusCalculator
  119. def self.calc corde_set
  120. 0
  121. end
  122. class << self
  123. alias_method :calc_onepieces, :calc
  124. end
  125. end
  126. class BaseFriendBonusCalculator
  127. def self.calc friend_ticket, corde_set
  128. 0
  129. end
  130. end
  131. class BaseMusicBonusCalculator
  132. def self.calc music, corde_set
  133. 0
  134. end
  135. end
  136. class BrandBonusCalculator < BaseCordeBonusCalculator
  137. def self.calc corde_set
  138. # p "BrandBonusCalculator"
  139. tops = corde_set.tops.corde
  140. bottoms = corde_set.bottoms.corde
  141. shoes = corde_set.shoes.corde
  142. # ブランド3
  143. return 300 if [tops.brand, bottoms.brand, shoes.brand].uniq.count == 1
  144. # ブランド2
  145. return 200 if [tops.brand, bottoms.brand, shoes.brand].uniq.count == 2
  146. # ミックス1
  147. 100
  148. end
  149. def self.calc_onepieces corde_set
  150. # p "BrandBonusCalculator OP"
  151. onepieces = corde_set.onepieces.corde
  152. shoes = corde_set.shoes.corde
  153. # ブランド2
  154. return 200 if [onepieces.brand, shoes.brand].uniq.count == 1
  155. # ミックス1
  156. 100
  157. end
  158. end
  159. class ManagerBonusCalculator < BaseCordeBonusCalculator
  160. def self.calc corde_set
  161. # p "ManagerBonusCalculator"
  162. tops = corde_set.tops
  163. bottoms = corde_set.bottoms
  164. shoes = corde_set.shoes
  165. eq_tops = tops.owner.equal_manager_and_color(tops.user)
  166. eq_bottoms = bottoms.owner.equal_manager_and_color(bottoms.user)
  167. eq_shoes = shoes.owner.equal_manager_and_color(shoes.user)
  168. return 1000 if eq_tops and eq_bottoms and eq_shoes
  169. 0
  170. end
  171. def self.calc_onepieces corde_set
  172. # p "ManagerBonusCalculator OP"
  173. onepieces = corde_set.onepieces
  174. shoes = corde_set.shoes
  175. return 1000 if onepieces.owner.equal_manager_and_color(onepieces.user) and shoes.owner.equal_manager_and_color(shoes.user)
  176. 0
  177. end
  178. end