Group spells (or attempt to)
This commit is contained in:
parent
05297ec4c7
commit
917ebb67d4
@ -1,4 +1,5 @@
|
|||||||
require "prawn"
|
require "prawn"
|
||||||
|
require "prawn/grouping"
|
||||||
require "pry"
|
require "pry"
|
||||||
|
|
||||||
require_relative "spell"
|
require_relative "spell"
|
||||||
@ -180,72 +181,76 @@ class ShardsOfPower
|
|||||||
@pdf.outline.section rating_title, :destination => @pdf.page_number
|
@pdf.outline.section rating_title, :destination => @pdf.page_number
|
||||||
end
|
end
|
||||||
|
|
||||||
pdf.font_size FONT_SIZE_SECTION
|
rating_spells.sort_by! { |spell| spell.name }
|
||||||
pdf.text rating_title
|
|
||||||
|
|
||||||
rating_spells.sort_by { |spell| spell.name }.each do |spell|
|
rating_spells.each do |spell|
|
||||||
puts "\t\tCompiling #{spell.full_title} by #{spell.authors.join(', ')}"
|
puts "\t\tCompiling #{spell.full_title} by #{spell.authors.join(', ')}"
|
||||||
|
|
||||||
pdf.outline.add_subsection_to(rating_title) do
|
pdf.outline.add_subsection_to(rating_title) do
|
||||||
@pdf.outline.section spell.full_title, :destination => @pdf.page_number
|
@pdf.outline.section spell.full_title, :destination => @pdf.page_number
|
||||||
end
|
end
|
||||||
|
pdf.group do |g|
|
||||||
|
if spell == rating_spells.first
|
||||||
|
g.font_size FONT_SIZE_SECTION
|
||||||
|
g.text rating_title
|
||||||
|
end
|
||||||
|
|
||||||
spell_ary = [{:text => "#{spell.name} (", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}]
|
spell_ary = [{:text => "#{spell.name} (", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}]
|
||||||
|
|
||||||
pdf.font_size FONT_SIZE_BODY
|
g.font_size FONT_SIZE_BODY
|
||||||
previous = false
|
previous = false
|
||||||
spell.arcana.each do |arcanum|
|
spell.arcana.each do |arcanum|
|
||||||
spell_ary << {:text => ", ", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION} if previous
|
spell_ary << {:text => ", ", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION} if previous
|
||||||
spell_ary << {:text => arcanum.to_s.titleize, :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}
|
spell_ary << {:text => arcanum.to_s.titleize, :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}
|
||||||
spell_ary << {:text => spell.send(arcanum).to_dots, :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -5}
|
spell_ary << {:text => spell.send(arcanum).to_dots, :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -5}
|
||||||
|
|
||||||
previous = true
|
previous = true
|
||||||
end
|
end
|
||||||
|
|
||||||
spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -3}
|
spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -3}
|
||||||
|
|
||||||
pdf.formatted_text spell_ary
|
g.formatted_text spell_ary
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "Practice: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "Practice: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.practice, :font => "Goudy"},
|
{:text => spell.practice, :font => "Goudy"},
|
||||||
]
|
]
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "Primary Factor: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "Primary Factor: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.primary_factor, :font => "Goudy"},
|
{:text => spell.primary_factor, :font => "Goudy"},
|
||||||
]
|
]
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "Withstand: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "Withstand: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.withstand, :font => "Goudy"},
|
{:text => spell.withstand, :font => "Goudy"},
|
||||||
] if !spell.withstand.nil?
|
] if !spell.withstand.nil?
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "Cost: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "Cost: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.cost, :font => "Goudy"},
|
{:text => spell.cost, :font => "Goudy"},
|
||||||
] if !spell.cost.nil?
|
] if !spell.cost.nil?
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "Suggested Rote Skills: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "Suggested Rote Skills: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.suggested_rote_skills.join(', '), :font => "Goudy"},
|
{:text => spell.suggested_rote_skills.join(', '), :font => "Goudy"},
|
||||||
]
|
]
|
||||||
|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => spell.authors.length == 1 ? "Author: " : "Authors: ", :styles => [:bold], :font => "Goudy"},
|
{:text => spell.authors.length == 1 ? "Author: " : "Authors: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => spell.authors.join(', '), :font => "Goudy"},
|
{:text => spell.authors.join(', '), :font => "Goudy"},
|
||||||
]
|
]
|
||||||
|
|
||||||
pdf.text spell.rules_text, :inline_format => true
|
g.text spell.rules_text, :inline_format => true
|
||||||
|
|
||||||
spell.reaches.each do |reach|
|
spell.reaches.each do |reach|
|
||||||
pdf.formatted_text [
|
g.formatted_text [
|
||||||
{:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"},
|
{:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"},
|
||||||
{:text => reach[1], :font => "Goudy"},
|
{:text => reach[1], :font => "Goudy"},
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
spell.adds.each do |add|
|
spell.adds.each do |add|
|
||||||
pdf.formatted_text [
|
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[: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"},
|
{:text => add[:effect], :font => "Goudy"},
|
||||||
]
|
]
|
||||||
@ -253,6 +258,7 @@ class ShardsOfPower
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
pdf.start_new_page
|
pdf.start_new_page
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user