mgmg 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7cadbd5fef7941e004310c08f8ec597ce06381b0b305369d0e42afa08cb5016
4
- data.tar.gz: a0d9d53d2e0284274e4558c7d27f26aeb2af6eb2649faaa07d840a5cd4f5aed8
3
+ metadata.gz: 708daf16885a7532d26106458fbcabf1e043bfbbc0d6c8607af45a2e5b31ca45
4
+ data.tar.gz: 765e3c12305233d28ea32c8c13ea819bfe52849a393cc5dc64d3c4e54fbe3b70
5
5
  SHA512:
6
- metadata.gz: fe3d521ee8e90ae3253dacf5389035a53e40d58d0a9e574c0685d346765fdef35de371412d772b77476809cf80a2bb384e1e0b20c0ada8c265f6155ad27fcf3a
7
- data.tar.gz: 77638a9c41f22fa7a509f409645307d2a452822bd557aa83e5d0c8e96ac8e84c93f6d9fd3df265a04dc1e91abde3f143561f410c6b397a89fe599a0ee2dcc8f7
6
+ metadata.gz: d673f9054fe9a1c9ec2d771a699046eb457ddfbc08306355d2a64b988fd00b841e29edc8da7b9c00305423a255ca322a559eb7e8931463ef4ce6ebec63679ce8
7
+ data.tar.gz: 1b2374ffa189136a4b4036424a77660eef55401be88e06a00f9f6034354ae7ecfdf24eeb2b889c1f0df3049fb3978e63bb5ddb355acf4d165023feb9186446bb
data/CHANGELOG.md CHANGED
@@ -138,3 +138,6 @@
138
138
  - `Mgmg::Recipe#build`,`Mgmg::Recipe#search`など`String`等に対する操作と同様にでき,注目パラメータとオプションは,`to_recipe`でセットしたものがデフォルトで使われるようになる.各メソッド呼び出し時にキーワード引数を与えることで,一時的に上書きすることもできる.
139
139
  - `String#to_recipe`にのみ,☆20制限のチェック機構を導入した.
140
140
  - 計算を繰り返した際,複数装備の装備数が増加していってしまうバグを修正した.
141
+
142
+ ## 1.5.2 2022/06/28
143
+ - `String#poly`が`:magic2`に対応していなかったバグを修正.
data/lib/mgmg/optimize.rb CHANGED
@@ -4,9 +4,9 @@ module Mgmg
4
4
  InvList = [%w|帽子 フード サンダル|.freeze, %w|宝1 骨1 木1 木2 骨2|.freeze, %w|宝1 骨1 木1|.freeze].freeze
5
5
  def phydef_optimize(str, smith, comp=smith, opt: Option.new)
6
6
  best = if smith.nil? then
7
- [str, str.poly(:phydef, opt: opt), str.poly(:magdef, opt: opt), str.poly(:cost, opt: opt)]
7
+ [str, str.poly(:phydef, opt:), str.poly(:magdef, opt:), str.poly(:cost, opt:)]
8
8
  else
9
- [str, str.build(smith, comp, opt: opt)]
9
+ [str, str.build(smith, comp, opt:)]
10
10
  end
11
11
  str = Mgmg.check_string(str)
12
12
  ai = 0
@@ -23,7 +23,7 @@ module Mgmg
23
23
  m = /([^\+]*\([^\(]+[綿皮]1\))\]*\Z/.match(str)
24
24
  if m
25
25
  if smith
26
- if m[1].sub(/綿1\)/, '皮1)').build(smith, opt: opt).weight == m[1].sub(/皮1\)/, '綿1)').build(smith, opt: opt).weight
26
+ if m[1].sub(/綿1\)/, '皮1)').build(smith, opt:).weight == m[1].sub(/皮1\)/, '綿1)').build(smith, opt:).weight
27
27
  skin = true
28
28
  end
29
29
  else
@@ -40,9 +40,9 @@ module Mgmg
40
40
  while b
41
41
  r = pd_apply_idx(str, a, b)
42
42
  best = if smith.nil? then
43
- pd_better(best, [r, r.poly(:phydef, opt: opt), r.poly(:magdef, opt: opt), r.poly(:cost, opt: opt)], opt.magdef_maximize)
43
+ pd_better(best, [r, r.poly(:phydef, opt:), r.poly(:magdef, opt:), r.poly(:cost, opt:)], opt.magdef_maximize)
44
44
  else
45
- pd_better(best, [r, r.build(smith, comp, opt: opt)], opt.magdef_maximize)
45
+ pd_better(best, [r, r.build(smith, comp, opt:)], opt.magdef_maximize)
46
46
  end
47
47
  b = pd_next_b(b)
48
48
  end
@@ -58,9 +58,9 @@ module Mgmg
58
58
  while b
59
59
  r = pd_apply_idx(str, a, b)
60
60
  best = if smith.nil? then
61
- pd_better(best, [r, r.poly(:phydef, opt: opt), r.poly(:magdef, opt: opt), r.poly(:cost, opt: opt)], opt.magdef_maximize)
61
+ pd_better(best, [r, r.poly(:phydef, opt:), r.poly(:magdef, opt:), r.poly(:cost, opt:)], opt.magdef_maximize)
62
62
  else
63
- pd_better(best, [r, r.build(smith, comp, opt: opt)], opt.magdef_maximize)
63
+ pd_better(best, [r, r.build(smith, comp, opt:)], opt.magdef_maximize)
64
64
  end
65
65
  b = pd_next_b(b)
66
66
  end
@@ -159,7 +159,7 @@ module Mgmg
159
159
 
160
160
  MwList = %w|綿 皮 骨 木 水|.freeze
161
161
  def buster_optimize(str, smith, comp=smith, opt: Option.new)
162
- best = ( smith.nil? ? [str, str.poly(:mag_das, opt: opt)] : [str, str.build(smith, comp, opt: opt)] )
162
+ best = ( smith.nil? ? [str, str.poly(:mag_das, opt:)] : [str, str.build(smith, comp, opt:)] )
163
163
  str = Mgmg.check_string(str)
164
164
  ai = -1
165
165
  org = nil
@@ -174,7 +174,7 @@ module Mgmg
174
174
  a = Array.new(ai){ [0, 0, 0] }
175
175
  while a
176
176
  r = bus_apply_idx(str, a)
177
- best = bus_better(best, ( smith.nil? ? [r, r.poly(:mag_das, opt: opt)] : [r, r.build(smith, comp, opt: opt)] ))
177
+ best = bus_better(best, ( smith.nil? ? [r, r.poly(:mag_das, opt:)] : [r, r.build(smith, comp, opt:)] ))
178
178
  a = bus_next_a(a)
179
179
  end
180
180
  best[0]
data/lib/mgmg/recipe.rb CHANGED
@@ -70,9 +70,9 @@ module Mgmg
70
70
  smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil?
71
71
  case @recipe
72
72
  when String
73
- recipe.build(smith, comp, opt: opt)
73
+ recipe.build(smith, comp, opt:)
74
74
  when Enumerable
75
- recipe.build(smith, armor, comp, opt: opt)
75
+ recipe.build(smith, armor, comp, opt:)
76
76
  else
77
77
  raise BrokenRecipeError
78
78
  end
@@ -82,16 +82,16 @@ module Mgmg
82
82
  smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil?
83
83
  case @recipe
84
84
  when String
85
- recipe.show(smith, comp, para: para, opt: opt)
85
+ recipe.show(smith, comp, para:, opt:)
86
86
  when Enumerable
87
- recipe.show(smith, armor, comp, para: para, opt: opt)
87
+ recipe.show(smith, armor, comp, para:, opt:)
88
88
  else
89
89
  raise BrokenRecipeError
90
90
  end
91
91
  end
92
92
  def search(target, para: @para, **kw)
93
93
  opt = temp_opt(**kw)
94
- @recipe.search(para, target, opt: opt)
94
+ @recipe.search(para, target, opt:)
95
95
  end
96
96
  private def correct_level(s, ac, x, opt)
97
97
  if s.nil?
@@ -147,7 +147,7 @@ module Mgmg
147
147
  def poly(para=@para, **kw)
148
148
  opt = temp_opt(**kw)
149
149
  if @recipe.kind_of?(String)
150
- @recipe.poly(para, opt: opt)
150
+ @recipe.poly(para, opt:)
151
151
  else
152
152
  raise InvalidRecipeError, "Mgmg::Recipe#poly is available only for String recipes."
153
153
  end
@@ -155,7 +155,7 @@ module Mgmg
155
155
  def phydef_optimize(smith=nil, comp=smith, **kw)
156
156
  opt = temp_opt(**kw)
157
157
  if @recipe.kind_of?(String)
158
- @recipe.phydef_optimize(smith, comp, opt: opt)
158
+ @recipe.phydef_optimize(smith, comp, opt:)
159
159
  else
160
160
  raise InvalidRecipeError, "Mgmg::Recipe#phydef_optimize is available only for String recipes."
161
161
  end
@@ -163,7 +163,7 @@ module Mgmg
163
163
  def buster_optimize(smith=nil, comp=smith, **kw)
164
164
  opt = temp_opt(**kw)
165
165
  if @recipe.kind_of?(String)
166
- @recipe.buster_optimize(smith, comp, opt: opt)
166
+ @recipe.buster_optimize(smith, comp, opt:)
167
167
  else
168
168
  raise InvalidRecipeError, "Mgmg::Recipe#buster_optimize is available only for String recipes."
169
169
  end
data/lib/mgmg/search.rb CHANGED
@@ -48,11 +48,11 @@ class String
48
48
  def search(para, target, opt: Mgmg::Option.new)
49
49
  opt = opt.dup.set_default(self)
50
50
  opt_nocut = opt.dup; opt_nocut.cut_exp = Float::INFINITY
51
- opt.comp_min = comp_search(para, target, opt.smith_max, opt: opt)
51
+ opt.comp_min = comp_search(para, target, opt.smith_max, opt:)
52
52
  opt.smith_max = smith_search(para, target, opt.comp_min, opt: opt_nocut)
53
53
  opt.smith_min = smith_search(para, target, opt.comp_max, opt: opt_nocut)
54
54
  raise Mgmg::SearchCutException if opt.cut_exp < Mgmg.exp(opt.smith_min, opt.comp_min)
55
- opt.comp_max = comp_search(para, target, opt.smith_min, opt: opt)
55
+ opt.comp_max = comp_search(para, target, opt.smith_min, opt:)
56
56
  ret = nil
57
57
  exp = Mgmg.exp(opt.smith_min, opt.comp_max)
58
58
  opt.cut_exp, ret = exp, [opt.smith_min, opt.comp_max] if exp < opt.cut_exp
@@ -60,7 +60,7 @@ class String
60
60
  opt.cut_exp, ret = exp, [opt.smith_max, opt.comp_min] if exp < opt.cut_exp
61
61
  (opt.comp_min+opt.step).step(opt.comp_max-1, opt.step) do |comp|
62
62
  break if opt.cut_exp < Mgmg.exp(opt.smith_min, comp)
63
- smith = smith_search(para, target, comp, opt: opt)
63
+ smith = smith_search(para, target, comp, opt:)
64
64
  exp = Mgmg.exp(smith, comp)
65
65
  if exp < opt.cut_exp
66
66
  opt.cut_exp, ret = exp, [smith, comp]
@@ -144,7 +144,7 @@ module Enumerable
144
144
  opt.cut_exp, ret = exp2, [opt.smith_max, opt.armor_min] if exp2 < opt.cut_exp
145
145
  (opt.armor_min+1).upto(opt.armor_max-1) do |armor|
146
146
  break if opt.cut_exp < Mgmg.exp(opt.smith_min, armor, comp)
147
- smith = smith_search(para, target, armor, comp, opt: opt)
147
+ smith = smith_search(para, target, armor, comp, opt:)
148
148
  exp = Mgmg.exp(smith, armor, comp)
149
149
  if exp < opt.cut_exp
150
150
  opt.cut_exp, ret = exp, [smith, armor]
@@ -158,7 +158,7 @@ module Enumerable
158
158
  else
159
159
  (opt.smith_min+1).upto(opt.smith_max-1) do |smith|
160
160
  break if opt.cut_exp < Mgmg.exp(smith, opt.armor_min, comp)
161
- armor = armor_search(para, target, smith, comp, opt: opt)
161
+ armor = armor_search(para, target, smith, comp, opt:)
162
162
  exp = Mgmg.exp(smith, armor, comp)
163
163
  if exp < opt.cut_exp
164
164
  opt.cut_exp, ret = exp, [smith, armor]
@@ -195,11 +195,11 @@ module Enumerable
195
195
  end
196
196
  def search(para, target, opt: Mgmg::Option.new)
197
197
  opt = opt.dup.set_default(self)
198
- opt.comp_min = comp_search(para, target, opt.smith_max, opt.armor_max, opt: opt)
199
- opt.smith_max, opt.armor_max = sa_search(para, target, opt.comp_min, opt: opt)
200
- opt.smith_min, opt.armor_min = sa_search(para, target, opt.comp_max, opt: opt)
198
+ opt.comp_min = comp_search(para, target, opt.smith_max, opt.armor_max, opt:)
199
+ opt.smith_max, opt.armor_max = sa_search(para, target, opt.comp_min, opt:)
200
+ opt.smith_min, opt.armor_min = sa_search(para, target, opt.comp_max, opt:)
201
201
  raise Mgmg::SearchCutException if opt.cut_exp < Mgmg.exp(opt.smith_min, opt.armor_min, opt.comp_min)
202
- opt.comp_max = comp_search(para, target, opt.smith_min, opt.armor_min, opt: opt)
202
+ opt.comp_max = comp_search(para, target, opt.smith_min, opt.armor_min, opt:)
203
203
  ret = nil
204
204
  exp = Mgmg.exp(opt.smith_min, opt.armor_min, opt.comp_max)
205
205
  opt.cut_exp, ret = exp, [opt.smith_min, opt.armor_min,opt. comp_max] if exp < opt.cut_exp
@@ -207,7 +207,7 @@ module Enumerable
207
207
  opt.cut_exp, ret = exp, [opt.smith_max, opt.armor_max, opt.comp_min] if exp < opt.cut_exp
208
208
  (opt.comp_min+1).upto(opt.comp_max-1) do |comp|
209
209
  break if opt.cut_exp < Mgmg.exp(opt.smith_min, opt.armor_min, comp)
210
- smith, armor = sa_search(para, target, comp, opt: opt)
210
+ smith, armor = sa_search(para, target, comp, opt:)
211
211
  exp = Mgmg.exp(smith, armor, comp)
212
212
  if exp < opt.cut_exp
213
213
  opt.cut_exp, ret = exp, [smith, armor, comp]
@@ -323,10 +323,8 @@ module Mgmg
323
323
  SystemEquip.store(k.sub(/脛当て\Z/, 'すね当て'), SystemEquip[k])
324
324
  end
325
325
  end
326
- SystemEquip.freeze
327
326
  SystemEquipRegexp = Hash.new
328
- SystemEquip.keys.each do |k|
329
- SystemEquipRegexp.store(k.freeze, Regexp.compile(k))
327
+ SystemEquip.each_key do |k|
328
+ SystemEquipRegexp.store(k, Regexp.compile(k).freeze)
330
329
  end
331
- SystemEquipRegexp.freeze
332
330
  end
data/lib/mgmg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mgmg
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
data/lib/mgmg.rb CHANGED
@@ -20,21 +20,21 @@ class String
20
20
  ret
21
21
  end
22
22
  def min_weight(opt: Mgmg::Option.new)
23
- build(build(opt: opt).min_levels_max, opt: opt).weight
23
+ build(build(opt:).min_levels_max, opt:).weight
24
24
  end
25
25
  def max_weight(include_outsourcing=false, opt: Mgmg::Option.new)
26
26
  if include_outsourcing
27
- build(-1, opt: opt).weight
27
+ build(-1, opt:).weight
28
28
  else
29
- build(min_smith(opt: opt), opt: opt).weight
29
+ build(min_smith(opt:), opt:).weight
30
30
  end
31
31
  end
32
32
  def min_level(w=0, include_outsourcing=false, opt: Mgmg::Option.new)
33
- built = build(-1, opt: opt)
34
- w = build(built.min_levels_max, -1, opt: opt).weight - w if w <= 0
33
+ built = build(-1, opt:)
34
+ w = build(built.min_levels_max, -1, opt:).weight - w if w <= 0
35
35
  return -1 if include_outsourcing && built.weight <= w
36
- ms = min_smith(opt: opt)
37
- return ms if build(ms, opt: opt).weight <= w
36
+ ms = min_smith(opt:)
37
+ return ms if build(ms, opt:).weight <= w
38
38
  ary = [ms]
39
39
  4.downto(1) do |wi| # 単品の最大重量は[斧|重鎧](金10石10)の5
40
40
  built.min_levels(wi).values.each do |v|
@@ -42,21 +42,21 @@ class String
42
42
  end
43
43
  end
44
44
  ary.sort.each do |l|
45
- return l if build(l, opt: opt).weight <= w
45
+ return l if build(l, opt:).weight <= w
46
46
  end
47
- raise ArgumentError, "w=`#{w}' is given, but the minimum weight for the recipe is `#{min_weight(opt: opt)}'."
47
+ raise ArgumentError, "w=`#{w}' is given, but the minimum weight for the recipe is `#{min_weight(opt:)}'."
48
48
  end
49
49
  def min_levels(w=1, opt: Mgmg::Option.new)
50
- build(opt: opt).min_levels(w)
50
+ build(opt:).min_levels(w)
51
51
  end
52
52
  def min_levels_max(w=1, opt: Mgmg::Option.new)
53
- min_levels(w, opt: opt).values.append(-1).max
53
+ min_levels(w, opt:).values.append(-1).max
54
54
  end
55
55
  def min_smith(opt: Mgmg::Option.new)
56
- Mgmg::Equip.min_smith(self, opt: opt)
56
+ Mgmg::Equip.min_smith(self, opt:)
57
57
  end
58
58
  def min_comp(opt: Mgmg::Option.new)
59
- Mgmg::Equip.min_comp(self, opt: opt)
59
+ Mgmg::Equip.min_comp(self, opt:)
60
60
  end
61
61
  def build(smith=-1, comp=smith, opt: Mgmg::Option.new)
62
62
  Mgmg::Equip.build(self, smith, comp, left_associative: opt.left_associative).reinforce(*opt.reinforcement)
@@ -67,28 +67,30 @@ class String
67
67
  def poly(para=:cost, opt: Mgmg::Option.new)
68
68
  case para
69
69
  when :atkstr
70
- self.poly(:attack, opt: opt) + self.poly(:str, opt: opt)
70
+ self.poly(:attack, opt:) + self.poly(:str, opt:)
71
71
  when :atk_sd
72
- self.poly(:attack, opt: opt) + self.poly(:str, opt: opt).quo(2) + self.poly(:dex, opt: opt).quo(2)
72
+ self.poly(:attack, opt:) + self.poly(:str, opt:).quo(2) + self.poly(:dex, opt:).quo(2)
73
73
  when :dex_as
74
- self.poly(:dex, opt: opt) + self.poly(:attack, opt: opt).quo(2) + self.poly(:str, opt: opt).quo(2)
74
+ self.poly(:dex, opt:) + self.poly(:attack, opt:).quo(2) + self.poly(:str, opt:).quo(2)
75
75
  when :mag_das
76
- self.poly(:magic, opt: opt) + self.poly(:dex_as, opt: opt).quo(2)
76
+ self.poly(:magic, opt:) + self.poly(:dex_as, opt:).quo(2)
77
+ when :magic2
78
+ self.poly(:magic, opt:).scalar(2)
77
79
  when :magmag
78
- self.poly(:magdef, opt: opt) + self.poly(:magic, opt: opt).quo(2)
80
+ self.poly(:magdef, opt:) + self.poly(:magic, opt:).quo(2)
79
81
  when :pmdef
80
- pd = self.poly(:phydef, opt: opt)
81
- md = self.poly(:magmag, opt: opt)
82
+ pd = self.poly(:phydef, opt:)
83
+ md = self.poly(:magmag, opt:)
82
84
  pd <= md ? pd : md
83
85
  when :cost
84
- if Mgmg::SystemEquip.keys.include?(self)
86
+ if Mgmg::SystemEquip.has_key?(self)
85
87
  return Mgmg::TPolynomial.new(Mgmg::Mat.new(1, 1, 0.quo(1)), 28, 0, 12, 12)
86
88
  end
87
- built = self.build(-1, opt: opt)
89
+ built = self.build(-1, opt:)
88
90
  const = (built.star**2) * ( /\+/.match(self) ? 5 : ( built.kind < 8 ? 2 : 1 ) )
89
- ret = poly(:attack, opt: opt) + poly(:phydef, opt: opt) + poly(:magdef, opt: opt)
90
- ret += poly(:hp, opt: opt).quo(4) + poly(:mp, opt: opt).quo(4)
91
- ret += poly(:str, opt: opt) + poly(:dex, opt: opt) + poly(:speed, opt: opt) + poly(:magic, opt: opt)
91
+ ret = poly(:attack, opt:) + poly(:phydef, opt:) + poly(:magdef, opt:)
92
+ ret += poly(:hp, opt:).quo(4) + poly(:mp, opt:).quo(4)
93
+ ret += poly(:str, opt:) + poly(:dex, opt:) + poly(:speed, opt:) + poly(:magic, opt:)
92
94
  ret.mat.body[0][0] += const
93
95
  ret
94
96
  else
@@ -96,15 +98,15 @@ class String
96
98
  end
97
99
  end
98
100
  def eff(para, smith, comp=smith, opt: Mgmg::Option.new)
99
- a = build(smith, comp, opt: opt).para_call(para)
100
- b = build(smith+1, comp, opt: opt).para_call(para)
101
- c = build(smith, comp+2, opt: opt).para_call(para)
101
+ a = build(smith, comp, opt:).para_call(para)
102
+ b = build(smith+1, comp, opt:).para_call(para)
103
+ c = build(smith, comp+2, opt:).para_call(para)
102
104
  sden = smith==0 ? 1 : 2*smith-1
103
105
  cden = comp==0 ? 4 : 8*comp
104
106
  [(b-a).quo(sden), (c-a).quo(cden)]
105
107
  end
106
108
  def peff(para, smith, comp=smith, opt: Mgmg::Option.new)
107
- poly(para, opt: opt).eff(smith, comp)
109
+ poly(para, opt:).eff(smith, comp)
108
110
  end
109
111
  def show(smith=-1, comp=smith, para: :power, opt: Mgmg::Option.new)
110
112
  rein = case opt.reinforcement
@@ -113,7 +115,7 @@ class String
113
115
  else
114
116
  [Mgmg::Reinforcement.compile(opt.reinforcement)]
115
117
  end
116
- built = build(smith, comp, opt: opt)
118
+ built = build(smith, comp, opt:)
117
119
  pstr = '%.3f' % built.para_call(para)
118
120
  pstr.sub!(/\.?0+\Z/, '')
119
121
  puts "With levels (#{smith}, #{comp}: #{Mgmg.exp(smith, comp).comma3}), building"
@@ -123,10 +125,10 @@ class String
123
125
  puts " #{built}"
124
126
  end
125
127
  def phydef_optimize(smith=nil, comp=smith, opt: Mgmg::Option.new)
126
- Mgmg::Optimize.phydef_optimize(self, smith, comp, opt: opt)
128
+ Mgmg::Optimize.phydef_optimize(self, smith, comp, opt:)
127
129
  end
128
130
  def buster_optimize(smith=nil, comp=smith, opt: Mgmg::Option.new)
129
- Mgmg::Optimize.buster_optimize(self, smith, comp, opt: opt)
131
+ Mgmg::Optimize.buster_optimize(self, smith, comp, opt:)
130
132
  end
131
133
  end
132
134
  module Enumerable
@@ -139,16 +141,16 @@ module Enumerable
139
141
  rein = opt.reinforcement
140
142
  opt.reinforcement = []
141
143
  self.sum(Mgmg::Equip::Zero) do |str|
142
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
143
- str.build(smith, comp, opt: opt)
144
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
145
+ str.build(smith, comp, opt:)
144
146
  else
145
- str.build(armor, comp, opt: opt)
147
+ str.build(armor, comp, opt:)
146
148
  end
147
149
  end.reinforce(*rein)
148
150
  end
149
151
  def ir(opt: Mgmg::Option.new)
150
152
  self.sum(Mgmg::IR::Zero) do |str|
151
- str.ir(opt: opt)
153
+ str.ir(opt:)
152
154
  end.add_reinforcement(opt.reinforcement)
153
155
  end
154
156
  def show(smith=-1, armor=smith, comp=armor.tap{armor=smith}, para: :power, opt: Mgmg::Option.new)
@@ -158,7 +160,7 @@ module Enumerable
158
160
  else
159
161
  [Mgmg::Reinforcement.compile(opt.reinforcement)]
160
162
  end
161
- built = self.build(smith, armor, comp, opt: opt)
163
+ built = self.build(smith, armor, comp, opt:)
162
164
  pstr = '%.3f' % built.para_call(para)
163
165
  pstr.sub!(/\.?0+\Z/, '')
164
166
  puts "With levels (#{smith}, #{armor}, #{comp}: #{Mgmg.exp(smith, armor, comp).comma3}), building"
@@ -168,56 +170,56 @@ module Enumerable
168
170
  puts " #{built}"
169
171
  end
170
172
  def min_weight(opt: Mgmg::Option.new)
171
- build(*build(opt: opt).min_levels_max, -1, opt: opt).weight
173
+ build(*build(opt:).min_levels_max, -1, opt:).weight
172
174
  end
173
175
  def max_weight(include_outsourcing=false, opt: Mgmg::Option.new)
174
176
  if include_outsourcing
175
- build(-1, opt: opt).weight
177
+ build(-1, opt:).weight
176
178
  else
177
- build(*min_smith(opt: opt), -1, opt: opt).weight
179
+ build(*min_smith(opt:), -1, opt:).weight
178
180
  end
179
181
  end
180
182
  def min_weights(opt: Mgmg::Option.new)
181
183
  weapons, armors = [], []
182
184
  each do |str|
183
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
185
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
184
186
  weapons << str
185
187
  else
186
188
  armors << str
187
189
  end
188
190
  end
189
- [weapons.min_weight(opt: opt), armors.min_weight(opt: opt)]
191
+ [weapons.min_weight(opt:), armors.min_weight(opt:)]
190
192
  end
191
193
  def max_weights(include_outsourcing=false, opt: Mgmg::Option.new)
192
194
  weapons, armors = [], []
193
195
  each do |str|
194
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
196
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
195
197
  weapons << str
196
198
  else
197
199
  armors << str
198
200
  end
199
201
  end
200
- [weapons.max_weight(include_outsourcing, opt: opt), armors.max_weight(include_outsourcing, opt: opt)]
202
+ [weapons.max_weight(include_outsourcing, opt:), armors.max_weight(include_outsourcing, opt:)]
201
203
  end
202
204
  def min_level(ws=0, wa=ws, include_outsourcing=false, opt: Mgmg::Option.new)
203
205
  weapons, armors = [], []
204
206
  each do |str|
205
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
207
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
206
208
  weapons << str
207
209
  else
208
210
  armors << str
209
211
  end
210
212
  end
211
- ms, ma = min_smith(opt: opt)
212
- rs = min_level_sub(ws, ms, 0, weapons, include_outsourcing, opt: opt)
213
- ra = min_level_sub(wa, ma, 1, armors, include_outsourcing, opt: opt)
213
+ ms, ma = min_smith(opt:)
214
+ rs = min_level_sub(ws, ms, 0, weapons, include_outsourcing, opt:)
215
+ ra = min_level_sub(wa, ma, 1, armors, include_outsourcing, opt:)
214
216
  [rs, ra]
215
217
  end
216
218
  private def min_level_sub(w, ms, i, recipe, include_outsourcing, opt: Mgmg::Option.new)
217
- built = recipe.build(opt: opt)
218
- w = recipe.build(built.min_levels_max[i], opt: opt).weight - w if w <= 0
219
+ built = recipe.build(opt:)
220
+ w = recipe.build(built.min_levels_max[i], opt:).weight - w if w <= 0
219
221
  return -1 if include_outsourcing && built.weight <= w
220
- return ms if build(ms, opt: opt).weight <= w
222
+ return ms if build(ms, opt:).weight <= w
221
223
  ary = [ms]
222
224
  4.downto(1) do |wi|
223
225
  built.min_levels(wi).values.each do |v|
@@ -225,17 +227,17 @@ module Enumerable
225
227
  end
226
228
  end
227
229
  ary.sort.each do |l|
228
- return l if recipe.build(l, opt: opt).weight <= w
230
+ return l if recipe.build(l, opt:).weight <= w
229
231
  end
230
- raise ArgumentError, "w#{%w|s a|[i]}=`#{w}' is given, but the minimum weight for the #{%w|weapon(s) armor(s)|[i]} is `#{recipe.min_weight(opt: opt)}'."
232
+ raise ArgumentError, "w#{%w|s a|[i]}=`#{w}' is given, but the minimum weight for the #{%w|weapon(s) armor(s)|[i]} is `#{recipe.min_weight(opt:)}'."
231
233
  end
232
234
  def min_levels(w=1, opt: Mgmg::Option.new)
233
- build(opt: opt).min_levels(w)
235
+ build(opt:).min_levels(w)
234
236
  end
235
237
  def min_levels_max(w=1, opt: Mgmg::Option.new)
236
238
  ret = [-1, -1]
237
- min_levels(w, opt: opt).each do |str, level|
238
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
239
+ min_levels(w, opt:).each do |str, level|
240
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
239
241
  ret[0] = [ret[0], level].max
240
242
  else
241
243
  ret[1] = [ret[1], level].max
@@ -246,8 +248,8 @@ module Enumerable
246
248
  def min_smith(opt: Mgmg::Option.new)
247
249
  ret = [-1, -1]
248
250
  self.each do |str|
249
- s = Mgmg::Equip.min_smith(str, opt: opt)
250
- if Mgmg::EquipPosition[str.build(opt: opt).kind] == 0
251
+ s = Mgmg::Equip.min_smith(str, opt:)
252
+ if Mgmg::EquipPosition[str.build(opt:).kind] == 0
251
253
  ret[0] = [ret[0], s].max
252
254
  else
253
255
  ret[1] = [ret[1], s].max
@@ -257,7 +259,7 @@ module Enumerable
257
259
  end
258
260
  def min_comp(opt: Mgmg::Option.new)
259
261
  self.map do |str|
260
- Mgmg::Equip.min_comp(str, opt: opt)
262
+ Mgmg::Equip.min_comp(str, opt:)
261
263
  end.append(-1).max
262
264
  end
263
265
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgmg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAZOON
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler