Class: Mgmg::Recipe
- Inherits:
-
Object
- Object
- Mgmg::Recipe
- Defined in:
- lib/mgmg/recipe.rb
Instance Attribute Summary collapse
-
#para ⇒ Object
Returns the value of attribute para.
-
#recipe ⇒ Object
readonly
Returns the value of attribute recipe.
Instance Method Summary collapse
- #build(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, **kw) ⇒ Object
- #buster_optimize(smith = nil, comp = smith, **kw) ⇒ Object
- #find_max(max_exp, para: @para, **kw) ⇒ Object
-
#initialize(recipe, para = :power, **kw) ⇒ Recipe
constructor
A new instance of Recipe.
- #initialize_copy(other) ⇒ Object
- #ir(**kw) ⇒ Object
- #max_weight(include_outsourcing = false) ⇒ Object
- #min_comp ⇒ Object
- #min_level(w = @option.target_weight, include_outsourcing = false) ⇒ Object
- #min_levels(w = 1) ⇒ Object
- #min_levels_max(w = 1) ⇒ Object
- #min_smith ⇒ Object
- #min_weight ⇒ Object
- #option(**kw) ⇒ Object
- #option=(new_option) ⇒ Object
- #para_call(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, para: @para, **kw) ⇒ Object
- #phydef_optimize(smith = nil, comp = smith, **kw) ⇒ Object
- #poly(para = @para, **kw) ⇒ Object
- #replace(new_recipe, para: @para, **kw) ⇒ Object
- #search(target, para: @para, **kw) ⇒ Object
- #show(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, para: @para, **kw) ⇒ Object
Constructor Details
#initialize(recipe, para = :power, **kw) ⇒ Recipe
Returns a new instance of Recipe.
3 4 5 6 7 8 9 |
# File 'lib/mgmg/recipe.rb', line 3 def initialize(recipe, para=:power, **kw) @recipe = recipe @recipe.each(&:freeze) if @recipe.kind_of?(Enumerable) @recipe.freeze @para = para @option = Option.new(**kw).set_default(@recipe) end |
Instance Attribute Details
#para ⇒ Object
Returns the value of attribute para.
11 12 13 |
# File 'lib/mgmg/recipe.rb', line 11 def para @para end |
#recipe ⇒ Object (readonly)
Returns the value of attribute recipe.
10 11 12 |
# File 'lib/mgmg/recipe.rb', line 10 def recipe @recipe end |
Instance Method Details
#build(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, **kw) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mgmg/recipe.rb', line 68 def build(smith=-1, armor=smith, comp=armor.tap{armor=smith}, **kw) opt = temp_opt(**kw) smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil? case @recipe when String recipe.build(smith, comp, opt:) when Enumerable recipe.build(smith, armor, comp, opt:) else raise BrokenRecipeError end end |
#buster_optimize(smith = nil, comp = smith, **kw) ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/mgmg/recipe.rb', line 167 def buster_optimize(smith=nil, comp=smith, **kw) opt = temp_opt(**kw) if @recipe.kind_of?(String) @recipe.buster_optimize(smith, comp, opt:) else raise InvalidRecipeError, "Mgmg::Recipe#buster_optimize is available only for String recipes." end end |
#find_max(max_exp, para: @para, **kw) ⇒ Object
96 97 98 99 |
# File 'lib/mgmg/recipe.rb', line 96 def find_max(max_exp, para: @para, **kw) opt = temp_opt(**kw) @recipe.find_max(para, max_exp, opt:) end |
#initialize_copy(other) ⇒ Object
12 13 14 15 |
# File 'lib/mgmg/recipe.rb', line 12 def initialize_copy(other) @recipe = other.recipe.dup @option = other.option.dup end |
#ir(**kw) ⇒ Object
130 131 132 |
# File 'lib/mgmg/recipe.rb', line 130 def ir(**kw) temp_opt(**kw).irep end |
#max_weight(include_outsourcing = false) ⇒ Object
50 51 52 |
# File 'lib/mgmg/recipe.rb', line 50 def max_weight(include_outsourcing=false) @recipe.max_weight(opt: @option) end |
#min_comp ⇒ Object
65 66 67 |
# File 'lib/mgmg/recipe.rb', line 65 def min_comp @recipe.min_comp end |
#min_level(w = @option.target_weight, include_outsourcing = false) ⇒ Object
53 54 55 |
# File 'lib/mgmg/recipe.rb', line 53 def min_level(w=@option.target_weight, include_outsourcing=false) @recipe.min_level(w, include_outsourcing, opt: @option) end |
#min_levels(w = 1) ⇒ Object
56 57 58 |
# File 'lib/mgmg/recipe.rb', line 56 def min_levels(w=1) @recipe.min_levels(w, opt: @option) end |
#min_levels_max(w = 1) ⇒ Object
59 60 61 |
# File 'lib/mgmg/recipe.rb', line 59 def min_levels_max(w=1) @recipe.min_levels_max(w, opt: @option) end |
#min_smith ⇒ Object
62 63 64 |
# File 'lib/mgmg/recipe.rb', line 62 def min_smith @recipe.min_smith end |
#min_weight ⇒ Object
47 48 49 |
# File 'lib/mgmg/recipe.rb', line 47 def min_weight @recipe.min_weight(opt: @option) end |
#option(**kw) ⇒ Object
32 33 34 35 |
# File 'lib/mgmg/recipe.rb', line 32 def option(**kw) @option = temp_opt(**kw) @option end |
#option=(new_option) ⇒ Object
36 37 38 |
# File 'lib/mgmg/recipe.rb', line 36 def option=(new_option) @option = new_option.set_default(@recipe) end |
#para_call(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, para: @para, **kw) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/mgmg/recipe.rb', line 118 def para_call(smith=-1, armor=smith, comp=armor.tap{armor=smith}, para: @para, **kw) opt = temp_opt(**kw) smith, armor, comp = correct_level(smith, armor, comp, opt) case @recipe when String opt.irep.para_call(para, smith, comp) when Enumerable opt.irep.para_call(para, smith, armor, comp) else raise InvalidRecipeError end end |
#phydef_optimize(smith = nil, comp = smith, **kw) ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/mgmg/recipe.rb', line 159 def phydef_optimize(smith=nil, comp=smith, **kw) opt = temp_opt(**kw) if @recipe.kind_of?(String) @recipe.phydef_optimize(smith, comp, opt:) else raise InvalidRecipeError, "Mgmg::Recipe#phydef_optimize is available only for String recipes." end end |
#poly(para = @para, **kw) ⇒ Object
151 152 153 154 155 156 157 158 |
# File 'lib/mgmg/recipe.rb', line 151 def poly(para=@para, **kw) opt = temp_opt(**kw) if @recipe.kind_of?(String) @recipe.poly(para, opt:) else raise InvalidRecipeError, "Mgmg::Recipe#poly is available only for String recipes." end end |
#replace(new_recipe, para: @para, **kw) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/mgmg/recipe.rb', line 39 def replace(new_recipe, para: @para, **kw) @recipe = new_recipe @recipe.each(&:freeze) if @recipe.kind_of?(Enumerable) @recipe.freeze @para = para @option = Option.new(**kw).set_default(@recipe) self end |
#search(target, para: @para, **kw) ⇒ Object
92 93 94 95 |
# File 'lib/mgmg/recipe.rb', line 92 def search(target, para: @para, **kw) opt = temp_opt(**kw) @recipe.search(para, target, opt:) end |
#show(smith = -1,, armor = smith, comp = armor.tap{armor=smith}, para: @para, **kw) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mgmg/recipe.rb', line 80 def show(smith=-1, armor=smith, comp=armor.tap{armor=smith}, para: @para, **kw) opt = temp_opt(**kw) smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil? case @recipe when String recipe.show(smith, comp, para:, opt:) when Enumerable recipe.show(smith, armor, comp, para:, opt:) else raise BrokenRecipeError end end |