|
|
@@ -1,13 +1,18 @@ |
|
|
|
require "prawn" |
|
|
|
require "pry" |
|
|
|
|
|
|
|
require_relative "spell" |
|
|
|
require_relative "spells" |
|
|
|
require_relative "primitive_adds" |
|
|
|
|
|
|
|
puts "Book of Faces PDF generator" |
|
|
|
class BookOfFaces |
|
|
|
FONT_SIZE_CHAPTER = 48 |
|
|
|
FONT_SIZE_SECTION = 24 |
|
|
|
FONT_SIZE_SUBSECTION = 18 |
|
|
|
FONT_SIZE_BODY = 12 |
|
|
|
|
|
|
|
attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name |
|
|
|
attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name, :spells |
|
|
|
|
|
|
|
def start_chapter(num, name) |
|
|
|
@number_name = num |
|
|
@@ -16,6 +21,8 @@ class BookOfFaces |
|
|
|
@chapter_title = "Chapter #{number_name}: #{chapter_name}" |
|
|
|
puts "Starting #{chapter_title}" |
|
|
|
|
|
|
|
pdf.start_new_page |
|
|
|
|
|
|
|
pdf.outline.update do |
|
|
|
puts "\tAdding #{@book_of_faces.chapter_title} on page #{page_number}" |
|
|
|
section(@book_of_faces.chapter_title, :destination => page_number) |
|
|
@@ -79,6 +86,10 @@ class BookOfFaces |
|
|
|
end |
|
|
|
|
|
|
|
def generate |
|
|
|
puts "Parsing spells..." |
|
|
|
@spells = Spell.spells |
|
|
|
|
|
|
|
puts "Creating PDF object..." |
|
|
|
@pdf = Prawn::Document.new(:margin => 0) |
|
|
|
pdf.default_leading 10 |
|
|
|
|
|
|
@@ -117,8 +128,6 @@ class BookOfFaces |
|
|
|
pdf.font_size 24 |
|
|
|
pdf.text "Written by members of the /cofd/ Discord, edited by NEETzsche", :align => :center |
|
|
|
puts "\tMain credit..." |
|
|
|
|
|
|
|
pdf.start_new_page |
|
|
|
|
|
|
|
pdf.outline.define do |
|
|
|
end |
|
|
@@ -142,6 +151,78 @@ class BookOfFaces |
|
|
|
:exceptional_success => "The willworker not only gives it valuable information, but demonstrates they are particularly capable of learning. They gain a full Experience point, but it can only be spent learning things from the Book of Faces" |
|
|
|
) |
|
|
|
|
|
|
|
start_chapter("Two", "Spells") |
|
|
|
|
|
|
|
spells.group_by(&:primary_arcanum).sort_by { |arcanum, spells| arcanum }.to_h.each do |arcanum, arcanum_spells| |
|
|
|
arcanum_name = arcanum.to_s.titleize |
|
|
|
|
|
|
|
puts "Compiling spells for #{arcanum_name}..." |
|
|
|
|
|
|
|
start_section("#{arcanum_name} Spells") |
|
|
|
|
|
|
|
arcanum_spells.group_by(&arcanum).sort_by { |rating, spells| rating }.to_h.each do |rating, rating_spells| |
|
|
|
rating_title = "#{rating.to_dots} #{Spell::RANKS[rating - 1]} of #{arcanum_name}" |
|
|
|
puts "\tCompiling #{rating_title} spells..." |
|
|
|
pdf.outline.add_subsection_to("#{arcanum_name} Spells") do |
|
|
|
@pdf.outline.section rating_title, :destination => @pdf.page_number |
|
|
|
end |
|
|
|
|
|
|
|
pdf.font_size FONT_SIZE_SUBSECTION |
|
|
|
pdf.text rating_title |
|
|
|
|
|
|
|
rating_spells.sort_by { |spell| spell.name }.each do |spell| |
|
|
|
puts "\t\tCompiling #{spell.full_title} by #{spell.authors.join(', ')}" |
|
|
|
|
|
|
|
spell_ary = [{:text => "#{spell.name} (", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SECTION}] |
|
|
|
|
|
|
|
pdf.font_size FONT_SIZE_BODY |
|
|
|
spell.arcana.each do |arcanum| |
|
|
|
spell_ary << {:text => arcanum.to_s.titleize, :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SECTION} |
|
|
|
spell_ary << {:text => spell.send(arcanum).to_dots, :font => "Goudy", :color => "004E6D", :size => FONT_SIZE_SECTION} |
|
|
|
end |
|
|
|
|
|
|
|
spell_ary << {:text => ")", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SECTION} |
|
|
|
|
|
|
|
pdf.formatted_text spell_ary |
|
|
|
|
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => "Practice:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => spell.practice, :font => "Goudy"}, |
|
|
|
] |
|
|
|
|
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => "Primary Factor:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => spell.primary_factor, :font => "Goudy"}, |
|
|
|
] |
|
|
|
|
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => "Withstand:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => spell.withstand, :font => "Goudy"}, |
|
|
|
] if !spell.withstand.nil? |
|
|
|
|
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => "Suggested Rote Skills:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => spell.suggested_rote_skills.join(', '), :font => "Goudy"}, |
|
|
|
] |
|
|
|
|
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => spell.authors.length == 1 ? "Author:" : "Authors:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => spell.authors.join(', '), :font => "Goudy"}, |
|
|
|
] |
|
|
|
|
|
|
|
pdf.text spell.rules_text |
|
|
|
|
|
|
|
spell.reaches.each do |reach| |
|
|
|
puts reach.inspect |
|
|
|
pdf.formatted_text [ |
|
|
|
{:text => "+#{reach[0]} Reach:", :styles => [:bold], :font => "Goudy"}, |
|
|
|
{:text => reach[1], :font => "Goudy"}, |
|
|
|
] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
pdf.render_file("book_of_faces.pdf") |
|
|
|
end |
|
|
|
end |
|
|
|