Class: PathfinderDeckBuilder::Card
- Inherits:
-
Object
- Object
- PathfinderDeckBuilder::Card
show all
- Defined in:
- lib/card.rb
Direct Known Subclasses
ArmorCard, CharacterCard, DefensiveAbilityCard, FeatCard, MeleeWeaponCard, RangedWeaponCard, SkillCard, SpecialAbilityCard, SpecialAttackCard, SpellCard, TrackedResourceCard, TraitCard
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(xml_file = nil) ⇒ Card
Returns a new instance of Card.
6
7
8
9
|
# File 'lib/card.rb', line 6
def initialize(xml_file=nil)
@class_cards = []
@xml_file = xml_file
end
|
Instance Attribute Details
#class_cards ⇒ Object
Returns the value of attribute class_cards.
3
4
5
|
# File 'lib/card.rb', line 3
def class_cards
@class_cards
end
|
#class_path ⇒ Object
Returns the value of attribute class_path.
4
5
6
|
# File 'lib/card.rb', line 4
def class_path
@class_path
end
|
#index ⇒ Object
Returns the value of attribute index.
3
4
5
|
# File 'lib/card.rb', line 3
def index
@index
end
|
Instance Method Details
#assembled_card(path) ⇒ Object
79
80
81
|
# File 'lib/card.rb', line 79
def assembled_card(path)
static_content.merge(variable_content(path))
end
|
#create_card(index = nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/card.rb', line 11
def create_card(index=nil)
@index = index
set_paths
set_class_path
unless @class_path.nil?
if @class_path.class == Hash
@class_cards.push(assembled_card(@class_path))
else
@class_path.each { |path| @class_cards.push(assembled_card(path)) }
end
end
end
|
#set_class_path ⇒ Object
25
26
27
|
# File 'lib/card.rb', line 25
def set_class_path
:must_implement
end
|
#set_multiple_character_path ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/card.rb', line 59
def set_multiple_character_path
@character_path = @path_shortcut[@index]
@ac_path = @path_shortcut[@index]["armorclass"]
@initiative_path = @path_shortcut[@index]["armorclass"]
@movement_path = @path_shortcut[@index]["movement"]
@attack_path = @path_shortcut[@index]["attack"]
@attribute_path = @path_shortcut[@index]["attributes"]["attribute"]
@defensive_ability_path = @path_shortcut[@index]["defensive"]["special"] if @path_shortcut[@index]["defensive"] != nil
@feat_path = @path_shortcut[@index]["feats"]["feat"] if @path_shortcut[@index]["feats"] != nil
@armor_path = @path_shortcut[@index]["defenses"]["armor"] if @path_shortcut[@index]["defenses"]["armor"] != nil
@skill_path = @path_shortcut[@index]["skills"]["skill"] if @path_shortcut[@index]["skills"]["skill"] != nil
@special_ability_path = @path_shortcut[@index]["otherspecials"]["special"] if @path_shortcut[@index]["otherspecials"]["special"] != nil
@trait_path = @path_shortcut[@index]["traits"]["trait"] if @path_shortcut[@index]["traits"]["trait"] != nil
@tracked_resource_path = @path_shortcut[@index]["trackedresources"]["trackedresource"] if @path_shortcut[@index]["trackedresources"]["trackedresource"] != nil
@spell_path = @path_shortcut[@index]["spellsmemorized"]["spell"] if @path_shortcut[@index]["spellsmemorized"] != nil
@special_attack_path = @path_shortcut[@index]["attack"]["special"] if @path_shortcut[@index]["attack"]["special"] != nil
@melee_weapons_path = @path_shortcut[@index]["melee"]["weapon"] if @path_shortcut[@index]["melee"] != nil
@ranged_weapons_path = @path_shortcut[@index]["ranged"]["weapon"] if @path_shortcut[@index]["ranged"] != nil
end
|
#set_paths ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/card.rb', line 29
def set_paths
@path_shortcut = @xml_file["document"]["public"]["character"]
if @index
set_multiple_character_path
else
set_single_character_path
end
end
|
#set_single_character_path ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/card.rb', line 39
def set_single_character_path
@character_path = @path_shortcut
@ac_path = @path_shortcut["armorclass"]
@initiative_path = @path_shortcut["armorclass"]
@movement_path = @path_shortcut["movement"]
@attack_path = @path_shortcut["attack"]
@attribute_path = @path_shortcut["attributes"]["attribute"]
@defensive_ability_path = @path_shortcut["defensive"]["special"] if @path_shortcut["defensive"] != nil
@feat_path = @path_shortcut["feats"]["feat"] if @path_shortcut["feats"] != nil
@armor_path = @path_shortcut["defenses"]["armor"] if @path_shortcut["defenses"]["armor"] != nil
@skill_path = @path_shortcut["skills"]["skill"] if @path_shortcut["skills"]["skill"] != nil
@special_ability_path = @path_shortcut["otherspecials"]["special"] if @path_shortcut["otherspecials"]["special"] != nil
@trait_path = @path_shortcut["traits"]["trait"] if @path_shortcut["traits"]["trait"] != nil
@tracked_resource_path = @path_shortcut["trackedresources"]["trackedresource"] if @path_shortcut["trackedresources"]["trackedresource"] != nil
@spell_path = @path_shortcut["spellsmemorized"]["spell"] if @path_shortcut["spellsmemorized"] != nil
@special_attack_path = @path_shortcut["attack"]["special"] if @path_shortcut["attack"]["special"] != nil
@melee_weapons_path = @path_shortcut["melee"]["weapon"] if @path_shortcut["melee"] != nil
@ranged_weapons_path = @path_shortcut["ranged"]["weapon"] if @path_shortcut["ranged"] != nil
end
|
#static_content ⇒ Object
83
84
85
|
# File 'lib/card.rb', line 83
def static_content
end
|
#variable_content ⇒ Object
87
88
89
|
# File 'lib/card.rb', line 87
def variable_content
end
|