Class: Mgmg::Option
- Inherits:
-
Object
- Object
- Mgmg::Option
- Defined in:
- lib/mgmg/option.rb
Constant Summary collapse
- Defaults =
{ left_associative: true, include_system_equips: true, smith_max: 100_000, armor_max: 100_000, comp_max: 100_000, fib_ext: [4, 10] }
Instance Attribute Summary collapse
-
#armor_max ⇒ Object
Returns the value of attribute armor_max.
-
#armor_min ⇒ Object
Returns the value of attribute armor_min.
-
#comp_max ⇒ Object
Returns the value of attribute comp_max.
-
#comp_min ⇒ Object
Returns the value of attribute comp_min.
-
#cut_exp ⇒ Object
Returns the value of attribute cut_exp.
-
#fib_ext ⇒ Object
Returns the value of attribute fib_ext.
-
#include_system_equips ⇒ Object
Returns the value of attribute include_system_equips.
-
#irep ⇒ Object
Returns the value of attribute irep.
-
#left_associative ⇒ Object
Returns the value of attribute left_associative.
-
#magdef_maximize ⇒ Object
Returns the value of attribute magdef_maximize.
-
#reinforcement ⇒ Object
Returns the value of attribute reinforcement.
-
#smith_max ⇒ Object
Returns the value of attribute smith_max.
-
#smith_min ⇒ Object
Returns the value of attribute smith_min.
-
#system_equips_checked ⇒ Object
Returns the value of attribute system_equips_checked.
-
#target_weight ⇒ Object
Returns the value of attribute target_weight.
Instance Method Summary collapse
- #buff ⇒ Object
- #buff=(v) ⇒ Object
-
#initialize(left_associative: , smith_min: nil, armor_min: nil, comp_min: nil, smith_max: , armor_max: , comp_max: , fib_ext: , magdef_maximize: true, target_weight: 0, reinforcement: [], buff: nil, irep: nil, cut_exp: Float::INFINITY, include_system_equips: ) ⇒ Option
constructor
A new instance of Option.
- #initialize_copy(other) ⇒ Object
- #set_default(recipe, force: false) ⇒ Object
- #update_sa_min(recipe, force = true) ⇒ Object
Constructor Details
#initialize(left_associative: , smith_min: nil, armor_min: nil, comp_min: nil, smith_max: , armor_max: , comp_max: , fib_ext: , magdef_maximize: true, target_weight: 0, reinforcement: [], buff: nil, irep: nil, cut_exp: Float::INFINITY, include_system_equips: ) ⇒ Option
Returns a new instance of Option.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mgmg/option.rb', line 8 def initialize( left_associative: Defaults[:left_associative], smith_min: nil, armor_min:nil, comp_min: nil, smith_max: Defaults[:smith_max], armor_max: Defaults[:armor_max], comp_max: Defaults[:comp_max], fib_ext: Defaults[:fib_ext], magdef_maximize: true, target_weight: 0, reinforcement: [], buff: nil, irep: nil, cut_exp: Float::INFINITY, include_system_equips: Defaults[:include_system_equips] ) @left_associative = left_associative @smith_min = smith_min @armor_min = armor_min @comp_min = comp_min @smith_max = smith_max @armor_max = armor_max @comp_max = comp_max @fib_ext = fib_ext @magdef_maximize = magdef_maximize @target_weight = target_weight @reinforcement = reinforcement unless buff.nil? if @reinforcement.empty? @reinforcement = buff else raise ArgumentError, "reinforcement and buff are exclusive" end end @irep = irep @cut_exp = cut_exp @include_system_equips = include_system_equips @system_equips_checked = false end |
Instance Attribute Details
#armor_max ⇒ Object
Returns the value of attribute armor_max.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def armor_max @armor_max end |
#armor_min ⇒ Object
Returns the value of attribute armor_min.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def armor_min @armor_min end |
#comp_max ⇒ Object
Returns the value of attribute comp_max.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def comp_max @comp_max end |
#comp_min ⇒ Object
Returns the value of attribute comp_min.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def comp_min @comp_min end |
#cut_exp ⇒ Object
Returns the value of attribute cut_exp.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def cut_exp @cut_exp end |
#fib_ext ⇒ Object
Returns the value of attribute fib_ext.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def fib_ext @fib_ext end |
#include_system_equips ⇒ Object
Returns the value of attribute include_system_equips.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def include_system_equips @include_system_equips end |
#irep ⇒ Object
Returns the value of attribute irep.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def irep @irep end |
#left_associative ⇒ Object
Returns the value of attribute left_associative.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def left_associative @left_associative end |
#magdef_maximize ⇒ Object
Returns the value of attribute magdef_maximize.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def magdef_maximize @magdef_maximize end |
#reinforcement ⇒ Object
Returns the value of attribute reinforcement.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def reinforcement @reinforcement end |
#smith_max ⇒ Object
Returns the value of attribute smith_max.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def smith_max @smith_max end |
#smith_min ⇒ Object
Returns the value of attribute smith_min.
40 41 42 |
# File 'lib/mgmg/option.rb', line 40 def smith_min @smith_min end |
#system_equips_checked ⇒ Object
Returns the value of attribute system_equips_checked.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def system_equips_checked @system_equips_checked end |
#target_weight ⇒ Object
Returns the value of attribute target_weight.
41 42 43 |
# File 'lib/mgmg/option.rb', line 41 def target_weight @target_weight end |
Instance Method Details
#buff ⇒ Object
99 100 101 |
# File 'lib/mgmg/option.rb', line 99 def buff @reinforcement end |
#buff=(v) ⇒ Object
102 103 104 |
# File 'lib/mgmg/option.rb', line 102 def buff=(v) @reinforcement = v end |
#initialize_copy(other) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mgmg/option.rb', line 42 def initialize_copy(other) @left_associative = other.left_associative @smith_min = other.smith_min @armor_min = other.armor_min @comp_min = other.comp_min @smith_max = other.smith_max @armor_max = other.armor_max @comp_max = other.comp_max @fib_ext = other.fib_ext.dup @magdef_maximize = other.magdef_maximize @target_weight = other.target_weight @reinforcement = other.reinforcement.dup @irep = other.irep @cut_exp = other.cut_exp @include_system_equips = other.include_system_equips end |
#set_default(recipe, force: false) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/mgmg/option.rb', line 81 def set_default(recipe, force: false) if (!@system_equips_checked) and @include_system_equips then case recipe when String @include_system_equips = false unless Mgmg::SystemEquipRegexp.values.any?{|re| re.match(recipe)} when Enumerable @include_system_equips = false unless recipe.any?{|str| Mgmg::SystemEquipRegexp.values.any?{|re| re.match(str)}} else raise ArgumentError, 'recipe should be String or Enumerable' end @system_equips_checked = true end update_sa_min(recipe, force) @comp_min = recipe.min_comp(opt: self) if force || @comp_min.nil? @irep = recipe.ir(opt: self) if force || @irep.nil? self end |
#update_sa_min(recipe, force = true) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mgmg/option.rb', line 58 def update_sa_min(recipe, force=true) case recipe when String if @smith_min.nil? && @armor_min @smith_min = @armor_min end if force || @smith_min.nil? s = recipe.min_level(@target_weight, opt: self) @smith_min = s if force || @smith_min.nil? @armor_min = s if force || @armor_min.nil? end when Enumerable if force || @smith_min.nil? || @armor_min.nil? @target_weight = [@target_weight, @target_weight] if @target_weight.kind_of? Numeric s, a = recipe.min_level(*@target_weight, opt: self) @smith_min = s if force || @smith_min.nil? @armor_min = a if force || @armor_min.nil? end else raise ArgumentError, 'recipe should be String or Enumerable' end self end |