new traits + attribute questions pdf

pull/1/head
Michael Hansen 5 years ago
parent 285d6ce773
commit d588af2a8b
  1. 11
      CHANGELOG.md
  2. 2
      src/app.rb
  3. BIN
      src/data/bauerbodoni.ttf
  4. 3
      src/lib/data.rb
  5. 103
      src/lib/pdf.rb
  6. 2
      src/public/js/server_settings.js

@ -5,17 +5,20 @@ The format is based on [Keep a Changelog](changelog),
and this project adheres to [Semantic Versioning](semver). and this project adheres to [Semantic Versioning](semver).
## [Unreleased] ## [Unreleased]
- Add emotional attributes to the PDF - Add Great Spiders
- Add a page to the pdf for Health + Steel questions
- Add a page to the pdf for trait descriptions
- Add weapon info to the pdf based on some educated guesses (e.g. do you have the arms resource and the Spear skill?) - Add weapon info to the pdf based on some educated guesses (e.g. do you have the arms resource and the Spear skill?)
- Write a guide on creating your own JSON data files - Write a guide on creating your own JSON data files
- Custom upload for your own data files - Custom upload for your own data files
- Updates to Roden and Great Wolves files (currently the data comes from Monster Burner and not Codex) - Updates to Roden and Great Wolves files (currently the data comes from Monster Burner and not Codex)
## [2.2.1] - 2019-07-28 ## [2.3.0] - 2019-07-28
### Added
- Display emotional attribute traits on PDF
- Append a page to the PDF with trait descriptions and attribute questions
### Fixed ### Fixed
- Wizard's Apprentice should count as Neophyte Sorcerer, and Junior Student counts as Arcane Devotee and Neophyte Sorcerer (thanks StubbsPKS!) - Wizard's Apprentice should count as Neophyte Sorcerer, and Junior Student counts as Arcane Devotee and Neophyte Sorcerer (thanks StubbsPKS!)
- Alphabetize skill and trait dropdown lists
## [2.2.0] - 2019-07-14 ## [2.2.0] - 2019-07-14
### Added ### Added

@ -104,7 +104,7 @@ get '/get_file' do
data = CACHE.delete(params['file']) data = CACHE.delete(params['file'])
if data if data
cs = CharSheet.new(data) cs = CharSheet.new(data)
data = cs.render(logger) data = cs.render(logger, DATA)
end end
else else
content_type 'application/octet-stream' content_type 'application/octet-stream'

Binary file not shown.

@ -26,6 +26,9 @@ module Charred
puts 'loading trolls' puts 'loading trolls'
load_troll(@data) load_troll(@data)
@data[:traits] = @data[:traits].sort.to_h
@data[:skills] = @data[:skills].sort.to_h
end end
def verbose_merge(to, from) def verbose_merge(to, from)

@ -6,7 +6,12 @@ class CharSheet
@character = character @character = character
@t1 = 16 @t1 = 16
@t2 = 12 @t2 = 12
@t2b = 10
@t3 = 10 @t3 = 10
@t3b = 8
@caliban = 'data/caliban.ttf'
@bauerbodoni = 'data/bauerbodoni.ttf'
@mediaeval = 'public/fonts/post-mediaeval.ttf'
end end
def render_skill(pdf, skilldef, at) def render_skill(pdf, skilldef, at)
@ -24,9 +29,47 @@ class CharSheet
pdf.draw_text (exponent.to_s), :at => [x+xs, y+ys], :size => @t2 pdf.draw_text (exponent.to_s), :at => [x+xs, y+ys], :size => @t2
end end
def render(logger) def render_trait(pdf, name, trait)
trait_type = {
"die" => "Die",
"call_on" => "Call-on",
"character" => "Character"
}[trait["type"]]
trait_desc = trait["desc"]
pdf.font @mediaeval
pdf.text "#{name}", :size => @t2
pdf.move_down 5
pdf.font @bauerbodoni
pdf.text "#{trait_type}", :size => @t3b
if trait_desc
pdf.move_down 5
pdf.text "#{trait["desc"]}", :width => 200, :size => @t2b
end
pdf.move_down 10
end
def render_questions(pdf, name, questions)
pdf.font @mediaeval
pdf.text "#{name}", :size => @t2
pdf.font @bauerbodoni
questions.each do |q|
pdf.move_down 5
yes = q["answer"]
pdf.text "#{q["question"]} #{yes ? "Yes." : "No."}", :size => @t2b
end
pdf.move_down 10
end
def render(logger, data)
pdf = Prawn::Document.new(:template => 'data/gold.pdf') pdf = Prawn::Document.new(:template => 'data/gold.pdf')
pdf.font 'data/caliban.ttf' pdf.font @caliban
pdf.default_leading -4 pdf.default_leading -4
# logger.info @character # logger.info @character
@ -123,6 +166,23 @@ class CharSheet
self.render_shade_exponent(pdf, ref_attr[0], ref_attr[1], [279, 396.5]) self.render_shade_exponent(pdf, ref_attr[0], ref_attr[1], [279, 396.5])
self.render_shade_exponent(pdf, mor_attr[0], mor_attr[1], [278.5, 346]) self.render_shade_exponent(pdf, mor_attr[0], mor_attr[1], [278.5, 346])
emo_name = ''
emo_attr = nil
['Spite', 'Grief', 'Greed', 'Faith', 'Hatred', 'Ancestral Taint'].each do |emo|
if not @character['attributes'][emo.downcase].nil?
emo_name = emo
emo_attr = @character['attributes'][emo.downcase]
emo_name = 'Taint' if emo_name == 'Ancestral Taint' # two words is too big
break
end
end
if not emo_attr.nil?
pdf.draw_text emo_name, :at => [127, 398], :size => @t2
self.render_shade_exponent(pdf, emo_attr[0], emo_attr[1], [164.5, 398.3])
end
ptgs = @character['ptgs'] ptgs = @character['ptgs']
["Su", "Li", "Mi", "Se", "Tr", "Mo"].each do |tol| ["Su", "Li", "Mi", "Se", "Tr", "Mo"].each do |tol|
tol_c = ptgs[tol.downcase] tol_c = ptgs[tol.downcase]
@ -147,6 +207,45 @@ class CharSheet
end end
end end
options = {
:page_layout => :landscape,
:margin => 0
}
pdf.start_new_page(:layout => :landscape, :margin => 36)
pdf.default_leading = 0
pdf.column_box([0, pdf.cursor], :columns => 3, :width => pdf.bounds.width) do
pdf.font @mediaeval
pdf.text "Traits", :size => @t1
pdf.move_down 10
trait_list = @character['traits'].sort { |a, b| a <=> b }
trait_list.each_with_index do |t, i|
name = t[0]
trait = DATA[:traits][name]
if trait.nil?
trait = {
"type" => "character"
}
end
self.render_trait(pdf, name, trait)
end
pdf.move_down 10
pdf.font @mediaeval
pdf.text "Attribute Questions", :size => @t1
pdf.move_down 10
attr_mods = @character['attr_mod_questions']
attr_mods.each do |name, questions|
self.render_questions(pdf, name, questions)
end
end
pdf.render pdf.render
end end
end end

@ -1,5 +1,5 @@
var serverSettings = { var serverSettings = {
'versionString' : '2.2.1', 'versionString' : '2.3.0',
'storageType' : 'client', 'storageType' : 'client',
'displayAttrMath' : 'false' 'displayAttrMath' : 'false'
} }

Loading…
Cancel
Save