Class: RPG::UsableItem::Damage
- Inherits:
-
Object
- Object
- RPG::UsableItem::Damage
- Extended by:
- RgssDb::JsonableConstructor
- Includes:
- RgssDb::Jsonable
- Defined in:
- lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb
Overview
The data inner class for damage.
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
Methods included from RgssDb::JsonableConstructor
Methods included from RgssDb::Jsonable
Constructor Details
#initialize ⇒ Damage
Returns a new instance of Damage.
15 16 17 18 19 20 21 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 15 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.
53 54 55 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 53 def critical @critical end |
#element_id ⇒ Object
Returns the value of attribute element_id.
53 54 55 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 53 def element_id @element_id end |
#formula ⇒ Object
Returns the value of attribute formula.
53 54 55 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 53 def formula @formula end |
#type ⇒ Object
Returns the value of attribute type.
53 54 55 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 53 def type @type end |
#variance ⇒ Object
Returns the value of attribute variance.
53 54 55 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 53 def variance @variance end |
Instance Method Details
#drain? ⇒ Boolean
39 40 41 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 39 def drain? [5, 6].include?(@type) end |
#eval(a, b, v) ⇒ Object
47 48 49 50 51 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 47 def eval(a, b, v) [Kernel.eval(@formula), 0].max * sign rescue StandardError 0 end |
#none? ⇒ Boolean
23 24 25 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 23 def none? @type == 0 end |
#recover? ⇒ Boolean
35 36 37 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 35 def recover? [3, 4].include?(@type) end |
#sign ⇒ Object
43 44 45 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 43 def sign recover? ? -1 : 1 end |
#to_hp? ⇒ Boolean
27 28 29 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 27 def to_hp? [1, 3, 5].include?(@type) end |
#to_mp? ⇒ Boolean
31 32 33 |
# File 'lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb', line 31 def to_mp? [2, 4, 6].include?(@type) end |