class Spell ARCANA = [:death, :fate, :forces, :life, :matter, :mind, :prime, :space, :spirit, :time] RANKS = ["Initiate", "Apprentice", "Disciple", "Adept", "Master"] ARCANA.each do |arcanum| attr_accessor arcanum end attr_accessor :name, :practice, :primary_factor, :withstand, :suggested_rote_skills, :reaches, :adds, :rules_text, :cost, :pdf attr_accessor :authors def initialize( death: 0, fate: 0, forces: 0, life: 0, matter: 0, mind: 0, prime: 0, space: 0, spirit: 0, time: 0, name:, practice:, primary_factor:, withstand: nil, suggested_rote_skills:, reaches: [], rules_text:, authors:, adds: [], cost: nil, pdf:) @death = death @fate = fate @forces = forces @life = life @matter = matter @mind = mind @prime = prime @space = space @spirit = spirit @time = time @name = name @practice = practice @primary_factor = primary_factor @withstand = withstand @suggested_rote_skills = suggested_rote_skills @reaches = reaches @rules_text = rules_text @authors = authors @adds = adds @cost = cost @pdf = pdf end def primary_arcanum ARCANA.max { |arcanum1, arcanum2| self.send(arcanum1) <=> self.send(arcanum2) } end def full_title "#{name} (#{arcana_with_dots.join(', ')})" end def arcana ARCANA.select { |arcanum| self.send(arcanum) > 0} end def arcana_with_dots arcana.collect { |arcanum| arcanum_with_dots(arcanum) } end def arcanum_with_dots(arcanum) [arcanum, self.send(arcanum)].to_arcanum_with_dots end def render(rating_title = nil) puts "\t\tCompiling #{full_title} by #{authors.join(', ')}" pdf.outline.add_subsection_to(rating_title) do @pdf.outline.section full_title, :destination => @pdf.page_number end pdf.group do |g| unless rating_title.nil? g.font_size Awakened2069::FONT_SIZE_SECTION g.text rating_title end spell_ary = [{:text => "#{name} (", :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION}] g.font_size Awakened2069::FONT_SIZE_BODY previous = false arcana.each do |arcanum| spell_ary << {:text => ", ", :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION} if previous spell_ary << {:text => arcanum.to_s.titleize, :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION} spell_ary << {:text => self.send(arcanum).to_dots, :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5} previous = true end spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -3} g.formatted_text spell_ary g.formatted_text [ {:text => "Practice: ", :styles => [:bold], :font => "Goudy"}, {:text => practice, :font => "Goudy"}, ] g.formatted_text [ {:text => "Primary Factor: ", :styles => [:bold], :font => "Goudy"}, {:text => primary_factor, :font => "Goudy"}, ] g.formatted_text [ {:text => "Withstand: ", :styles => [:bold], :font => "Goudy"}, {:text => withstand, :font => "Goudy"}, ] if !withstand.nil? g.formatted_text [ {:text => "Cost: ", :styles => [:bold], :font => "Goudy"}, {:text => cost, :font => "Goudy"}, ] if !cost.nil? g.formatted_text [ {:text => "Suggested Rote Skills: ", :styles => [:bold], :font => "Goudy"}, {:text => suggested_rote_skills.join(', '), :font => "Goudy"}, ] g.formatted_text [ {:text => authors.length == 1 ? "Author: " : "Authors: ", :styles => [:bold], :font => "Goudy"}, {:text => authors.join(', '), :font => "Goudy"}, ] g.text rules_text, :inline_format => true reaches.each do |reach| g.formatted_text [ {:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"}, {:text => reach[1], :font => "Goudy"}, ] end adds.each do |add| g.formatted_text [ {:text => "#{add[:verb] ? add[:verb] : "Add"} #{add[:arcana].collect { |arcanum, rating| [arcanum, rating].to_arcanum_with_dots }.to_list(:separator => add[:separator])}: ", :styles => [:bold], :font => "Goudy"}, {:text => add[:effect], :font => "Goudy"}, ] end end end end