mgmg 1.6.0 → 1.6.2

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: 0aee0bc2d348dfc0e23ce8556cea710f7645b6a590145f67bc1d5715b8c999a1
4
+ data.tar.gz: eed968af79443fabb9b65e931b93079a5dd8c839af6ea0b6f84a62c1ad411eda
5
5
  SHA512:
6
- metadata.gz: 5642dc8af3ac998c76650047c97747a32f2b631e9f6438c6a95e6068a9534dcd726d34dd8466fb1cba0e787f11847552aab4812e1b32d4320ff23a5ec8e15e18
7
- data.tar.gz: a327745f26724f3f6bbeabf2ed9fcb687ca4e462ac608c219165845b6ccfeafd5a30c32fdda4ee182dd268db8e0b4528e0acc1bc819eaaae0698d9400c764797
6
+ metadata.gz: 218e8c123428a6ec6228c1d296973c8ec01ba77d09430c3e33e49df081364b2e3e295b4f02a480b5349a709dd26e955e8472852e872ba73dd87b2044ec690904
7
+ data.tar.gz: 1c9db46a5f5fe0fdcb76bc0fbeab261414e2d9df4661d3dfe91f137ab066e739584170695fc58868d5d64e1ddec578866a90fd9291c9a47eca31f3cfafab915d
data/CHANGELOG.md CHANGED
@@ -169,3 +169,11 @@
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`を追加.
177
+
178
+ ## 1.6.2 2022/10/31
179
+ - 既製品を含むかどうかのチェックを行った場合,同じレシピについては繰り返しチェックしないようにして高速化した.
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/option.rb CHANGED
@@ -33,9 +33,10 @@ module Mgmg
33
33
  @irep = irep
34
34
  @cut_exp = cut_exp
35
35
  @include_system_equips = include_system_equips
36
+ @system_equips_checked = false
36
37
  end
37
38
  attr_accessor :left_associative, :smith_min, :armor_min, :comp_min, :smith_max, :armor_max, :comp_max
38
- attr_accessor :step, :magdef_maximize, :target_weight, :reinforcement, :irep, :cut_exp, :include_system_equips
39
+ attr_accessor :step, :magdef_maximize, :target_weight, :reinforcement, :irep, :cut_exp, :include_system_equips, :system_equips_checked
39
40
  def initialize_copy(other)
40
41
  @left_associative = other.left_associative
41
42
  @smith_min = other.smith_min
@@ -76,7 +77,7 @@ module Mgmg
76
77
  self
77
78
  end
78
79
  def set_default(recipe, force: false)
79
- if @include_system_equips
80
+ if (!@system_equips_checked) and @include_system_equips then
80
81
  case recipe
81
82
  when String
82
83
  @include_system_equips = false unless Mgmg::SystemEquipRegexp.values.any?{|re| re.match(recipe)}
@@ -85,6 +86,7 @@ module Mgmg
85
86
  else
86
87
  raise ArgumentError, 'recipe should be String or Enumerable'
87
88
  end
89
+ @system_equips_checked = true
88
90
  end
89
91
  update_sa_min(recipe, force)
90
92
  @comp_min = recipe.min_comp(opt: self) if force || @comp_min.nil?
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.2"
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.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-10-18 00:00:00.000000000 Z
11
+ date: 2022-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler