68 lines
2.4 KiB
Ruby
68 lines
2.4 KiB
Ruby
|
class Merit
|
||
|
attr_accessor :name,
|
||
|
:prerequisites,
|
||
|
:adjectives,
|
||
|
:dot_ratings,
|
||
|
:rules_text,
|
||
|
:ranks,
|
||
|
:pdf
|
||
|
|
||
|
attr_accessor :authors
|
||
|
|
||
|
def initialize(name:, prerequisites: nil, adjectives: [], dot_ratings: [], rules_text:, ranks: nil, pdf:)
|
||
|
@name = name
|
||
|
@prerequisites = prerequisites
|
||
|
@adjectives = adjectives
|
||
|
@dot_ratings = dot_ratings
|
||
|
@rules_text = rules_text
|
||
|
@ranks = ranks
|
||
|
@pdf = pdf
|
||
|
|
||
|
|
||
|
@dot_ratings = @dot_ratings.arrayify
|
||
|
@prerequisites = @prerequisites.arrayify
|
||
|
@adjectives = @adjectives.arrayify
|
||
|
end
|
||
|
|
||
|
def render
|
||
|
merit_ary = [{:text => "#{name} (", :font => "Lilith", :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION}]
|
||
|
|
||
|
previous = false
|
||
|
|
||
|
dot_ratings.each do |dr|
|
||
|
merit_ary << {:text => ", ", :font => "Lilith", :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION} if previous
|
||
|
previous = true
|
||
|
if dr.class == Range
|
||
|
merit_ary << {:text => dr.min.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
|
||
|
if dr.max < Float::INFINITY
|
||
|
merit_ary << {:text => " to ", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
|
||
|
merit_ary << {:text => dr.max.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
|
||
|
else
|
||
|
merit_ary << {:text => "+", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
|
||
|
end
|
||
|
elsif dr.class == Integer
|
||
|
merit_ary << {:text => dr.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
|
||
|
end
|
||
|
end
|
||
|
|
||
|
adjectives.each do |adj|
|
||
|
merit_ary << {:text => ", #{adj}", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
|
||
|
end
|
||
|
|
||
|
merit_ary << {:text => ")", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
|
||
|
|
||
|
pdf.group do |g|
|
||
|
g.font_size Awakened2069::FONT_SIZE_BODY
|
||
|
g.formatted_text merit_ary, :indent_paragraphs => Awakened2069::INDENT_SIZE
|
||
|
|
||
|
if prerequisites.size >= 1
|
||
|
prerequisites_text = prerequisites.join(", ")
|
||
|
g.text "<b>#{prerequisites.size == 1 ? "Prerequisite" : "Prerequisites"}:</b> #{prerequisites_text}", :inline_format => true, :indent_paragraphs => Awakened2069::INDENT_SIZE
|
||
|
end
|
||
|
|
||
|
g.text "<b>Effect:</b> #{rules_text}", :inline_format => true, :indent_paragraphs => Awakened2069::INDENT_SIZE
|
||
|
end
|
||
|
|
||
|
self
|
||
|
end
|
||
|
end
|