mgmg 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beb7f465bd84969abfb7ce5897d95f46171e84c2a0e3de9a14c42ccef5c23dfc
4
- data.tar.gz: '09a7eda9204cb28a7a9fc24857353fb5cdcfd21e44564d4a25997658c92fdfd3'
3
+ metadata.gz: b9da45e92b9c5fb1cae6577e532cce280c997f46c1df019514b1eb976d89f03f
4
+ data.tar.gz: 6f905a8d05126dbc81c71e73ddd64988e96a2033f520f6ded8b595ac96eb06be
5
5
  SHA512:
6
- metadata.gz: 5642dc8af3ac998c76650047c97747a32f2b631e9f6438c6a95e6068a9534dcd726d34dd8466fb1cba0e787f11847552aab4812e1b32d4320ff23a5ec8e15e18
7
- data.tar.gz: a327745f26724f3f6bbeabf2ed9fcb687ca4e462ac608c219165845b6ccfeafd5a30c32fdda4ee182dd268db8e0b4528e0acc1bc819eaaae0698d9400c764797
6
+ metadata.gz: cfaf9d22a5aaa36fdef9c15348117a014a4a9385947417a614a3f1fc82622ee4f1ad4c0d5615cbde9dded71b4a2a13edb88938e0fc88c818fafe27625b8f9885
7
+ data.tar.gz: 46734977a74542248d65449eb9b49aa4c9ce6f5b875a194c1ec8db6bdab47856fa341c9c77ef29f28c76dd4d078899260da64a6c8d04510fd7b4c692af8581c1
data/CHANGELOG.md CHANGED
@@ -169,3 +169,8 @@
169
169
  ## 1.6.0 2022/10/18
170
170
  - `Mgmg.#find_upperbound`のアルゴリズムを改善し,探索下限目標値の引数を削除.
171
171
  - `Enumerable#search`,`Enumerable#find_max`が正しい解を返さない場合があったバグを修正.
172
+
173
+ ## 1.6.1 2022/10/21
174
+ - `Mgmg.#find_lowerbound`,`Mgmg.#find_upperbound`において,同値レシピを指定した場合などを例外とするように修正.
175
+ - `Enumerable#to_recipe`にも`allow_over20`キーワード引数を導入し,デフォルトで☆20を超えるレシピを含む場合に例外とするように修正.
176
+ - 実効HP(最大HP+腕力)を表す`Mgmg::Equip#hs`を追加.
data/lib/mgmg/equip.rb CHANGED
@@ -105,6 +105,9 @@ module Mgmg
105
105
  def magic2
106
106
  magic()*2
107
107
  end
108
+ def hs
109
+ hp()+str()
110
+ end
108
111
  [:fire, :earth, :water].each.with_index do |s, i|
109
112
  define_method(s){ @element[i] }
110
113
  end
data/lib/mgmg/ir.rb CHANGED
@@ -220,6 +220,9 @@ module Mgmg
220
220
  def pmdef(s, ac, x=nil)
221
221
  [phydef(s, ac, x), magmag(s, ac, x)].min
222
222
  end
223
+ def hs(s, ac, x=nil)
224
+ hp(s, ac, x)+str(s, ac, x)
225
+ end
223
226
 
224
227
  def power(s, a=s, c=a.tap{a=s})
225
228
  case @kind
data/lib/mgmg/recipe.rb CHANGED
@@ -130,7 +130,7 @@ module Mgmg
130
130
  def ir(**kw)
131
131
  temp_opt(**kw).irep
132
132
  end
133
- %i|attack phydef magdef hp mp str dex speed magic atkstr atk_sd dex_as mag_das magic2 magmag pmdef|.each do |sym|
133
+ %i|attack phydef magdef hp mp str dex speed magic atkstr atk_sd dex_as mag_das magic2 magmag pmdef hs|.each do |sym|
134
134
  define_method(sym) do |s, ac=s, x=false, **kw|
135
135
  s, ac, x = correct_level(s, ac, x, temp_opt(**kw))
136
136
  ir(**kw).method(sym).call(s, ac, x)
data/lib/mgmg/search.rb CHANGED
@@ -369,6 +369,13 @@ module Mgmg
369
369
  pa, pb = opt_a.irep.para_call(para, *sca), opt_b.irep.para_call(para, *scb)
370
370
  if eb < ea || ( ea == eb && pa < pb )
371
371
  a, b, opt_a, opt_b, sca, scb, ea, eb = b, a, opt_b, opt_a, scb, sca, eb, ea
372
+ elsif eb == ea && pa == pb
373
+ raise Mgmg::SearchCutException, "given recipes are equivalent at start target=#{start.comma3}"
374
+ end
375
+ scat, scbt = a.search(para, term, opt: opt_a), b.search(para, term, opt: opt_b)
376
+ eat, ebt = Mgmg.exp(*scat), Mgmg.exp(*scbt)
377
+ if eat < ebt || ( eat == ebt && opt_b.irep.para_call(para, *scbt) <= opt_a.irep.para_call(para, *scat) )
378
+ raise Mgmg::SearchCutException, "given recipes will never be reversed from start target=#{start.comma3} until term target=#{term.comma3}"
372
379
  end
373
380
 
374
381
  loop do
@@ -419,13 +426,18 @@ module Mgmg
419
426
  pa, pb = opt_a.irep.para_call(para, *sca), opt_b.irep.para_call(para, *scb)
420
427
  if ea < eb || ( ea == eb && pb < pa )
421
428
  a, b, opt_a, opt_b, sca, scb, ea, eb = b, a, opt_b, opt_a, scb, sca, eb, ea
429
+ elsif eb == ea && pa == pb
430
+ raise Mgmg::SearchCutException, "given recipes are equivalent at start target=#{start.comma3}"
422
431
  end
423
432
 
433
+
424
434
  loop do
425
435
  loop do
426
436
  foo = a.find_max(para, eb, opt: opt_a)
427
437
  break if sca == foo
428
- sca, pa = foo, opt_a.irep.para_call(para, *foo)
438
+ bar = opt_a.irep.para_call(para, *foo)
439
+ break if pa < bar
440
+ sca, pa = foo, bar
429
441
  scb = b.search(para, pa, opt: opt_b)
430
442
  foo = Mgmg.exp(*scb)
431
443
  break if eb == foo
data/lib/mgmg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mgmg
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
data/lib/mgmg.rb CHANGED
@@ -89,6 +89,8 @@ class String
89
89
  pd = self.poly(:phydef, opt:)
90
90
  md = self.poly(:magmag, opt:)
91
91
  pd <= md ? pd : md
92
+ when :hs
93
+ self.poly(:hp, opt:) + self.poly(:str, opt:)
92
94
  when :cost
93
95
  if opt.include_system_equips and Mgmg::SystemEquip.has_key?(self) then
94
96
  return Mgmg::TPolynomial.new(Mgmg::Mat.new(1, 1, 0.quo(1)), 28, 0, 12, 12)
@@ -140,7 +142,13 @@ class String
140
142
  end
141
143
  module Enumerable
142
144
  using Mgmg::Refiner
143
- def to_recipe(para=:power, **kw)
145
+ def to_recipe(para=:power, allow_over20: false, **kw)
146
+ unless allow_over20
147
+ self.each do |e|
148
+ foo = e.build(-1).star
149
+ raise Mgmg::Over20Error, foo if 20 < foo
150
+ end
151
+ end
144
152
  Mgmg::Recipe.new(self, para, **kw)
145
153
  end
146
154
  def build(smith=-1, armor=smith, comp=armor.tap{armor=smith}, opt: Mgmg::Option.new)
data/reference.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # リファレンス
2
2
  本ライブラリで定義される主要なメソッドを以下に解説します.
3
3
 
4
- ## `String#to_recipe(para=:power, allow_over20: false, **kw)`,`Enumerable#to_recipe(para=:power, **kw)`
4
+ ## `String#to_recipe(para=:power, allow_over20: false, **kw)`,`Enumerable#to_recipe(para=:power, allow_over20: false, **kw)`
5
5
  レシピ文字列である`self`と,注目パラメータ`para`,オプション`Mgmg.option(**kw)`をセットにした[後述](#mgmgrecipe)の`Mgmg::Recipe`オブジェクトを生成して返します.デフォルト値としてセットされたパラメータを使用する以外は,レシピ文字列と同様に扱えます.
6
6
 
7
7
  `allow_over20`が偽の場合,レシピの☆を確認し,20を超える場合は,例外`Mgmg::Over20Error`を発生します.このチェックを抑制したい場合は,真にしてください.
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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAZOON
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler