Browse Source

Tilts

master
The Stranjer 4 years ago
parent
commit
aab1b5248b
3 changed files with 59 additions and 2 deletions
  1. +30
    -2
      shards_of_power.rb
  2. +21
    -0
      tilt.rb
  3. +8
    -0
      tilts.rb

+ 30
- 2
shards_of_power.rb View File

@@ -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
- 0
tilt.rb View 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

+ 8
- 0
tilts.rb View File

@@ -0,0 +1,8 @@
class Tilt

def self.tilts
tilts = []

return tilts
end
end

Loading…
Cancel
Save