mgmg 1.4.0 → 1.5.0
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 +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +37 -248
- data/lib/mgmg/cuisine.rb +140 -0
- data/lib/mgmg/equip.rb +37 -39
- data/lib/mgmg/ir.rb +400 -0
- data/lib/mgmg/optimize.rb +21 -9
- data/lib/mgmg/option.rb +85 -0
- data/lib/mgmg/poly.rb +2 -2
- data/lib/mgmg/reinforce.rb +70 -0
- data/lib/mgmg/search.rb +246 -175
- data/lib/mgmg/system_equip.rb +6 -0
- data/lib/mgmg/utils.rb +47 -1
- data/lib/mgmg/version.rb +1 -1
- data/lib/mgmg.rb +176 -62
- data/mgmg.gemspec +4 -4
- data/reference.md +453 -0
- metadata +15 -10
data/lib/mgmg/option.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Mgmg
|
2
|
+
module_function def option(recipe=nil, **kw)
|
3
|
+
ret = Option.new(**kw)
|
4
|
+
ret.set_default(recipe) unless recipe.nil?
|
5
|
+
ret
|
6
|
+
end
|
7
|
+
class Option
|
8
|
+
def initialize(
|
9
|
+
left_associative: true,
|
10
|
+
smith_min: nil, armor_min:nil, comp_min: nil, smith_max: 10000, armor_max: 10000, comp_max: 10000,
|
11
|
+
step: 1, magdef_maximize: true,
|
12
|
+
target_weight: 0, reinforcement: [], buff: nil,
|
13
|
+
irep: nil, cut_exp: Float::INFINITY
|
14
|
+
)
|
15
|
+
@left_associative = left_associative
|
16
|
+
@smith_min = smith_min
|
17
|
+
@armor_min = armor_min
|
18
|
+
@comp_min = comp_min
|
19
|
+
@smith_max = smith_max
|
20
|
+
@armor_max = armor_max
|
21
|
+
@comp_max = comp_max
|
22
|
+
@step = step
|
23
|
+
@magdef_maximize = magdef_maximize
|
24
|
+
@target_weight = target_weight
|
25
|
+
@reinforcement = reinforcement
|
26
|
+
unless buff.nil?
|
27
|
+
if @reinforcement.empty?
|
28
|
+
@reinforcement = buff
|
29
|
+
else
|
30
|
+
raise ArgumentError, "reinforcement and buff are exclusive"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@irep = irep
|
34
|
+
@cut_exp = cut_exp
|
35
|
+
end
|
36
|
+
attr_accessor :left_associative, :smith_min, :armor_min, :comp_min, :smith_max, :armor_max, :comp_max
|
37
|
+
attr_accessor :step, :magdef_maximize, :target_weight, :reinforcement, :irep, :cut_exp
|
38
|
+
def initialize_copy(other)
|
39
|
+
@left_associative = other.left_associative
|
40
|
+
@smith_min = other.smith_min
|
41
|
+
@armor_min = other.armor_min
|
42
|
+
@comp_min = other.comp_min
|
43
|
+
@smith_max = other.smith_max
|
44
|
+
@armor_max = other.armor_max
|
45
|
+
@comp_max = other.comp_max
|
46
|
+
@step = other.step
|
47
|
+
@magdef_maximize = other.magdef_maximize
|
48
|
+
@target_weight = other.target_weight
|
49
|
+
@reinforcement = other.reinforcement.dup
|
50
|
+
@irep = other.irep
|
51
|
+
@cut_exp = other.cut_exp
|
52
|
+
end
|
53
|
+
def set_default(recipe, force: false)
|
54
|
+
case recipe
|
55
|
+
when String
|
56
|
+
if @smith_min.nil? && @armor_min
|
57
|
+
@smith_min = @armor_min
|
58
|
+
end
|
59
|
+
if force || @smith_min.nil?
|
60
|
+
s = recipe.min_level(@target_weight, opt: self)
|
61
|
+
@smith_min = s if force || @smith_min.nil?
|
62
|
+
@armor_min = s if force || @armor_min.nil?
|
63
|
+
end
|
64
|
+
when Enumerable
|
65
|
+
if force || @smith_min.nil? || @armor_min.nil?
|
66
|
+
@target_weight = [@target_weight, @target_weight] if @target_weight.kind_of? Numeric
|
67
|
+
s, a = recipe.min_level(*@target_weight, opt: self)
|
68
|
+
@smith_min = s if force || @smith_min.nil?
|
69
|
+
@armor_min = a if force || @armor_min.nil?
|
70
|
+
end
|
71
|
+
else
|
72
|
+
raise ArgumentError, 'recipe should be String or Enumerable'
|
73
|
+
end
|
74
|
+
@comp_min = recipe.min_comp(opt: self) if force || @comp_min.nil?
|
75
|
+
@irep = recipe.ir(opt: self) if force || @irep.nil?
|
76
|
+
self
|
77
|
+
end
|
78
|
+
def buff
|
79
|
+
@reinforcement
|
80
|
+
end
|
81
|
+
def buff=(v)
|
82
|
+
@reinforcement = v
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/mgmg/poly.rb
CHANGED
@@ -301,8 +301,8 @@ module Mgmg
|
|
301
301
|
raise ArgumentError.new("given string `#{str}' is unparsable as a smithing recipe")
|
302
302
|
end
|
303
303
|
kind = EquipIndex[m[1].to_sym]
|
304
|
-
main_m, main_s, main_mc =
|
305
|
-
sub_m, sub_s, sub_mc =
|
304
|
+
main_m, main_s, main_mc = Mgmg.parse_material(m[2])
|
305
|
+
sub_m, sub_s, sub_mc = Mgmg.parse_material(m[3])
|
306
306
|
para = ParamIndex[para]
|
307
307
|
|
308
308
|
c = ( Equip9[kind][para] * Main9[main_m][para] ).cdiv(100).quo( main_mc==sub_mc ? 200 : 100 )
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Mgmg
|
2
|
+
class Reinforcement
|
3
|
+
def initialize(vec)
|
4
|
+
@vec = vec
|
5
|
+
end
|
6
|
+
attr_accessor :vec
|
7
|
+
def initialize_copy(other)
|
8
|
+
@vec = other.vec.dup
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
'(' + @vec.map.with_index{|e, i| e==0 ? nil : "#{Equip::ParamList[i]}:#{e}"}.compact.join(', ') + ')'
|
13
|
+
end
|
14
|
+
alias :inspect :to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
# スキル名 攻 物 防 HP MP 腕 器 速 魔
|
18
|
+
Skill = {
|
19
|
+
'物防御UP' => Reinforcement.new( Vec[ 0, 10, 0, 0, 0, 0, 0, 0, 0] ),
|
20
|
+
'魔防御UP' => Reinforcement.new( Vec[ 0, 0, 10, 0, 0, 0, 0, 0, 0] ),
|
21
|
+
'腕力UP' => Reinforcement.new( Vec[ 0, 0, 0, 0, 0, 10, 0, 0, 0] ),
|
22
|
+
'メンテナンス' => Reinforcement.new( Vec[ 50, 0, 0, 0, 0, 0, 0, 0, 0] ),
|
23
|
+
'ガードアップ' => Reinforcement.new( Vec[ 0, 50, 0, 0, 0, 0, 0, 0, 0] ),
|
24
|
+
'パワーアップ' => Reinforcement.new( Vec[ 0, 0, 0, 0, 0, 50, 0, 0, 0] ),
|
25
|
+
'デックスアップ' => Reinforcement.new( Vec[ 0, 0, 0, 0, 0, 0, 50, 0, 0] ),
|
26
|
+
'スピードアップ' => Reinforcement.new( Vec[ 0, 0, 0, 0, 0, 0, 0, 50, 0] ),
|
27
|
+
'マジックアップ' => Reinforcement.new( Vec[ 0, 0, 0, 0, 0, 0, 0, 0, 50] ),
|
28
|
+
'オールアップ' => Reinforcement.new( Vec[ 0, 50, 0, 0, 0, 50, 50, 50, 50] ),
|
29
|
+
}
|
30
|
+
|
31
|
+
class << Reinforcement
|
32
|
+
def cuisine(c)
|
33
|
+
Reinforcement.new( Vec[*(c.vec), *Array.new(6, 0)] )
|
34
|
+
end
|
35
|
+
def compile(arg)
|
36
|
+
case arg
|
37
|
+
when Reinforcement
|
38
|
+
arg
|
39
|
+
when Cuisine
|
40
|
+
cuisine(arg)
|
41
|
+
when String
|
42
|
+
if Skill.has_key?(arg)
|
43
|
+
Skill[arg]
|
44
|
+
elsif SystemCuisine.has_key?(arg)
|
45
|
+
cuisine(SystemCuisine[arg])
|
46
|
+
else
|
47
|
+
raise InvalidReinforcementNameError, arg
|
48
|
+
end
|
49
|
+
else
|
50
|
+
raise ArgumentError, "The argument should be Mgmg::Cuisine or skill name String. (`#{arg}' is given)"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Equip
|
56
|
+
def reinforce(*arg)
|
57
|
+
arg.each do |r|
|
58
|
+
r = Reinforcement.compile(r)
|
59
|
+
@para.map!.with_index do |pr, i|
|
60
|
+
if r.vec[i] == 0
|
61
|
+
pr
|
62
|
+
else
|
63
|
+
pr * (100+r.vec[i]).quo(100)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
self
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|