Class: PfrpgCore::Macro
- Inherits:
-
Object
show all
- Defined in:
- lib/pfrpg_core/macros/macro.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(character) ⇒ Macro
5
6
7
|
# File 'lib/pfrpg_core/macros/macro.rb', line 5
def initialize(character)
@character = character
end
|
Instance Attribute Details
#character ⇒ Object
Returns the value of attribute character.
3
4
5
|
# File 'lib/pfrpg_core/macros/macro.rb', line 3
def character
@character
end
|
Class Method Details
.find_available(character) ⇒ Object
38
39
40
|
# File 'lib/pfrpg_core/macros/macro.rb', line 38
def self.find_available(character)
macro_subclasses.map { |m| m.new(character) }.keep_if { |m| m.available? }
end
|
.macro_subclasses ⇒ Object
TODO: This should not be needed - Rails provides #subclasses but there is
crazy classloading stuff happening (or not happening actually) that
is causing this to be empty...
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/pfrpg_core/macros/macro.rb', line 45
def self.macro_subclasses
[
PowerAttackMacro,
SneakAttackMacro,
RapidShotMacro,
ManyshotMacro,
VitalStrikeMacro
]
end
|
Instance Method Details
#applies_to?(_weapon) ⇒ Boolean
13
14
15
|
# File 'lib/pfrpg_core/macros/macro.rb', line 13
def applies_to?(_weapon)
false
end
|
#as_json ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/pfrpg_core/macros/macro.rb', line 30
def as_json
{
slug: slug,
name: name,
info: info
}
end
|
#available? ⇒ Boolean
9
10
11
|
# File 'lib/pfrpg_core/macros/macro.rb', line 9
def available?
false
end
|
#info ⇒ Object
26
27
28
|
# File 'lib/pfrpg_core/macros/macro.rb', line 26
def info
nil
end
|
#name ⇒ Object
22
23
24
|
# File 'lib/pfrpg_core/macros/macro.rb', line 22
def name
slug.titleize
end
|
#slug ⇒ Object
17
18
19
20
|
# File 'lib/pfrpg_core/macros/macro.rb', line 17
def slug
name = self.class.name.split("PfrpgCore::")[1]
name.split('Macro').first
end
|