diff --git a/shards_of_power.rb b/shards_of_power.rb index f110de2..6a53105 100644 --- a/shards_of_power.rb +++ b/shards_of_power.rb @@ -7,6 +7,9 @@ require_relative "spells" require_relative "condition" require_relative "conditions" +require_relative "tilt" +require_relative "tilts" + require_relative "primitive_adds" puts "Shards of Power PDF generator" @@ -16,7 +19,7 @@ class ShardsOfPower FONT_SIZE_SUBSECTION = 18 FONT_SIZE_BODY = 10 - attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name, :spells, :conditions + attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name, :spells, :conditions, :tilts def start_chapter(num, name) @number_name = num @@ -93,8 +96,9 @@ class ShardsOfPower puts "Parsing spells..." @spells = Spell.spells @conditions = Condition.conditions - @conditions.sort_by!(&:name) + @tilts = Tilt.tilts + @tilts.sort_by!(&:name) puts "Creating PDF object..." @pdf = Prawn::Document.new(:margin => 0) @@ -276,6 +280,30 @@ class ShardsOfPower pdf.text "#{condition.authors.size > 1 ? "Authors" : "Author"}: #{condition.authors.to_list}", :inline_format => true end + + pdf.start_new_page + end + + start_section "Tilts" + + puts "Compiling Tilts..." + + pdf.column_box([0, pdf.cursor], :columns => 2, :width => pdf.bounds.width) do + tilts.each do |tilt| + puts "\tCompiling #{tilt.full_title}..." + pdf.outline.add_subsection_to("Tilts") do + @pdf.outline.section tilt.full_title, :destination => @pdf.page_number + end + + tilt_ary = [{:text => tilt.full_title, :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}] + pdf.formatted_text tilt_ary + + pdf.text tilt.rules_text, :inline_format => true + pdf.text "Effect: #{tilt.effect}", :inline_format => true + pdf.text "Causing the Tilt: #{tilt.causing}", :inline_format => true + pdf.text "Ending the Tilt: #{tilt.ending}", :inline_format => true + + end end pdf.render_file("shards_of_power.pdf") diff --git a/tilt.rb b/tilt.rb new file mode 100644 index 0000000..ed18787 --- /dev/null +++ b/tilt.rb @@ -0,0 +1,21 @@ +class Tilt + attr_accessor :name, :rules_text, :effect, :causing, :ending, :environmental, :authors + + def initialize(name:, rules_text:, effect:, causing:, ending:, environmental: false , authors:) + @name = name + @rules_text = rules_text + @effect = effect + @causing = causing + @ending = ending + @environmental = environmental + @authors = authors + end + + def full_title + if environmental + "#{name} (Environmental)" + else + name + end + end +end \ No newline at end of file diff --git a/tilts.rb b/tilts.rb new file mode 100644 index 0000000..d909256 --- /dev/null +++ b/tilts.rb @@ -0,0 +1,8 @@ +class Tilt + + def self.tilts + tilts = [] + + return tilts + end +end \ No newline at end of file