Class: RPG::UsableItem

Inherits:
BaseItem show all
Defined in:
lib/rpg/usable_item.rb,
lib/rpg/usable_item/damage.rb,
lib/rpg/usable_item/effect.rb

Direct Known Subclasses

Item, Skill

Defined Under Namespace

Classes: Damage, Effect

Instance Attribute Summary collapse

Attributes inherited from BaseItem

#description, #features, #icon_index, #id, #name, #note

Instance Method Summary collapse

Constructor Details

#initializeUsableItem

Returns a new instance of UsableItem.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rpg/usable_item.rb', line 3

def initialize
  super
  @scope = 0
  @occasion = 0
  @speed = 0
  @success_rate = 100
  @repeats = 1
  @tp_gain = 0
  @hit_type = 0
  @animation_id = 0
  @damage = RPG::UsableItem::Damage.new
  @effects = []
end

Instance Attribute Details

#animation_idObject

Returns the value of attribute animation_id.



61
62
63
# File 'lib/rpg/usable_item.rb', line 61

def animation_id
  @animation_id
end

#damageObject

Returns the value of attribute damage.



66
67
68
# File 'lib/rpg/usable_item.rb', line 66

def damage
  @damage
end

#effectsObject

Returns the value of attribute effects.



67
68
69
# File 'lib/rpg/usable_item.rb', line 67

def effects
  @effects
end

#hit_typeObject

Returns the value of attribute hit_type.



65
66
67
# File 'lib/rpg/usable_item.rb', line 65

def hit_type
  @hit_type
end

#occasionObject

Returns the value of attribute occasion.



59
60
61
# File 'lib/rpg/usable_item.rb', line 59

def occasion
  @occasion
end

#repeatsObject

Returns the value of attribute repeats.



63
64
65
# File 'lib/rpg/usable_item.rb', line 63

def repeats
  @repeats
end

#scopeObject

Returns the value of attribute scope.



58
59
60
# File 'lib/rpg/usable_item.rb', line 58

def scope
  @scope
end

#speedObject

Returns the value of attribute speed.



60
61
62
# File 'lib/rpg/usable_item.rb', line 60

def speed
  @speed
end

#success_rateObject

Returns the value of attribute success_rate.



62
63
64
# File 'lib/rpg/usable_item.rb', line 62

def success_rate
  @success_rate
end

#tp_gainObject

Returns the value of attribute tp_gain.



64
65
66
# File 'lib/rpg/usable_item.rb', line 64

def tp_gain
  @tp_gain
end

Instance Method Details

#battle_ok?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rpg/usable_item.rb', line 43

def battle_ok?
  [0, 1].include?(@occasion)
end

#certain?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/rpg/usable_item.rb', line 49

def certain?
  @hit_type == 0
end

#for_all?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rpg/usable_item.rb', line 37

def for_all?
  [2, 8, 10].include?(@scope)
end

#for_dead_friend?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rpg/usable_item.rb', line 22

def for_dead_friend?
  [9, 10].include?(@scope)
end

#for_friend?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rpg/usable_item.rb', line 19

def for_friend?
  [7, 8, 9, 10, 11].include?(@scope)
end

#for_one?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rpg/usable_item.rb', line 28

def for_one?
  [1, 3, 7, 9, 11].include?(@scope)
end

#for_opponent?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rpg/usable_item.rb', line 16

def for_opponent?
  [1, 2, 3, 4, 5, 6].include?(@scope)
end

#for_random?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rpg/usable_item.rb', line 31

def for_random?
  [3, 4, 5, 6].include?(@scope)
end

#for_user?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rpg/usable_item.rb', line 25

def for_user?
  @scope == 11
end

#magical?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/rpg/usable_item.rb', line 55

def magical?
  @hit_type == 2
end

Returns:

  • (Boolean)


46
47
48
# File 'lib/rpg/usable_item.rb', line 46

def menu_ok?
  [0, 2].include?(@occasion)
end

#need_selection?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rpg/usable_item.rb', line 40

def need_selection?
  [1, 7, 9].include?(@scope)
end

#number_of_targetsObject



34
35
36
# File 'lib/rpg/usable_item.rb', line 34

def number_of_targets
  for_random? ? @scope - 2 : 0
end

#physical?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/rpg/usable_item.rb', line 52

def physical?
  @hit_type == 1
end