Tilts
This commit is contained in:
parent
e5da36bda0
commit
aab1b5248b
@ -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 "<b>#{condition.authors.size > 1 ? "Authors" : "Author"}:</b> #{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 "<b>Effect:</b> #{tilt.effect}", :inline_format => true
|
||||
pdf.text "<b>Causing the Tilt:</b> #{tilt.causing}", :inline_format => true
|
||||
pdf.text "<b>Ending the Tilt:</b> #{tilt.ending}", :inline_format => true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
pdf.render_file("shards_of_power.pdf")
|
||||
|
21
tilt.rb
Normal file
21
tilt.rb
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user