Class: RPG::UsableItem::Damage
- Inherits:
-
Object
- Object
- RPG::UsableItem::Damage
- Defined in:
- lib/rpg/usable_item/damage.rb
Instance Attribute Summary collapse
-
#critical ⇒ Object
Returns the value of attribute critical.
-
#element_id ⇒ Object
Returns the value of attribute element_id.
-
#formula ⇒ Object
Returns the value of attribute formula.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variance ⇒ Object
Returns the value of attribute variance.
Instance Method Summary collapse
- #drain? ⇒ Boolean
- #eval(a, b, v) ⇒ Object
-
#initialize ⇒ Damage
constructor
A new instance of Damage.
- #none? ⇒ Boolean
- #recover? ⇒ Boolean
- #sign ⇒ Object
- #to_hp? ⇒ Boolean
- #to_mp? ⇒ Boolean
Constructor Details
#initialize ⇒ Damage
Returns a new instance of Damage.
4 5 6 7 8 9 10 |
# File 'lib/rpg/usable_item/damage.rb', line 4 def initialize @type = 0 @element_id = 0 @formula = '0' @variance = 20 @critical = false end |
Instance Attribute Details
#critical ⇒ Object
Returns the value of attribute critical.
36 37 38 |
# File 'lib/rpg/usable_item/damage.rb', line 36 def critical @critical end |
#element_id ⇒ Object
Returns the value of attribute element_id.
33 34 35 |
# File 'lib/rpg/usable_item/damage.rb', line 33 def element_id @element_id end |
#formula ⇒ Object
Returns the value of attribute formula.
34 35 36 |
# File 'lib/rpg/usable_item/damage.rb', line 34 def formula @formula end |
#type ⇒ Object
Returns the value of attribute type.
32 33 34 |
# File 'lib/rpg/usable_item/damage.rb', line 32 def type @type end |
#variance ⇒ Object
Returns the value of attribute variance.
35 36 37 |
# File 'lib/rpg/usable_item/damage.rb', line 35 def variance @variance end |
Instance Method Details
#drain? ⇒ Boolean
23 24 25 |
# File 'lib/rpg/usable_item/damage.rb', line 23 def drain? [5,6].include?(@type) end |
#eval(a, b, v) ⇒ Object
29 30 31 |
# File 'lib/rpg/usable_item/damage.rb', line 29 def eval(a, b, v) [Kernel.eval(@formula), 0].max * sign rescue 0 end |
#none? ⇒ Boolean
11 12 13 |
# File 'lib/rpg/usable_item/damage.rb', line 11 def none? @type == 0 end |
#recover? ⇒ Boolean
20 21 22 |
# File 'lib/rpg/usable_item/damage.rb', line 20 def recover? [3,4].include?(@type) end |
#sign ⇒ Object
26 27 28 |
# File 'lib/rpg/usable_item/damage.rb', line 26 def sign recover? ? -1 : 1 end |
#to_hp? ⇒ Boolean
14 15 16 |
# File 'lib/rpg/usable_item/damage.rb', line 14 def to_hp? [1,3,5].include?(@type) end |
#to_mp? ⇒ Boolean
17 18 19 |
# File 'lib/rpg/usable_item/damage.rb', line 17 def to_mp? [2,4,6].include?(@type) end |