Class: RPG::UsableItem::Damage

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from RgssDb::JsonableConstructor

json_create, json_new

Methods included from RgssDb::Jsonable

#as_json, #to_json

Constructor Details

#initializeDamage

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

#criticalObject

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_idObject

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

#formulaObject

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

#typeObject

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

#varianceObject

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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

#signObject



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

Returns:

  • (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

Returns:

  • (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