class PathfinderDeckBuilder::Card

Attributes

class_cards[RW]
class_path[R]
index[RW]

Public Class Methods

new(xml_file=nil) click to toggle source
# File lib/card.rb, line 6
def initialize(xml_file=nil)
  @class_cards = []
  @xml_file = xml_file
end

Public Instance Methods

assembled_card(path) click to toggle source
# File lib/card.rb, line 79
def assembled_card(path)
  static_content.merge(variable_content(path))
end
create_card(index=nil) click to toggle source
# 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() click to toggle source
# File lib/card.rb, line 25
def set_class_path
  :must_implement
end
set_multiple_character_path() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/card.rb, line 83
def static_content
  #non-iterative JSON goes here
end
variable_content() click to toggle source
# File lib/card.rb, line 87
def variable_content
  #iterative JSON goes here
end