The Stranjer 4 лет назад
Родитель
Сommit
0287e4a23e
3 измененных файлов: 239 добавлений и 263 удалений
  1. +0
    -263
      book_of_faces.rb
  2. Двоичные данные
      cover.png
  3. +239
    -0
      shards_of_power.rb

+ 0
- 263
book_of_faces.rb Просмотреть файл

@@ -1,263 +0,0 @@
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 = 10

attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name, :spells

def start_chapter(num, name)
@number_name = num
@chapter_name = name

@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)
end

puts "\tSetting font size"
pdf.font_size FONT_SIZE_CHAPTER
pdf.font "Abess"
puts "\tPrinting chapter to document"
pdf.text "Chapter #{number_name}: #{chapter_name}"

puts "\tRestoring body text"
pdf.font "Goudy"
pdf.font_size FONT_SIZE_BODY
end

def start_section(section_name)
puts "Beginning section #{section_name}: "

@section_name = section_name

pdf.outline.add_subsection_to(chapter_title) do
@pdf.outline.section section_name, :destination => @pdf.page_number
end

puts "\tSetting font size"
pdf.font_size FONT_SIZE_SECTION
pdf.text section_name

puts "\tRestoring body text"
pdf.font_size FONT_SIZE_BODY
pdf.font "Goudy"

end

def roll_results(dramatic_failure:, failure:, success:, exceptional_success:)
pdf.font_size FONT_SIZE_BODY
pdf.font "Goudy"

pdf.text "Roll Results", :style => :bold

pdf.formatted_text [
{ :text => "Dramatic Failure: ", :styles => [:bold] },
{ :text => dramatic_failure }
]

pdf.formatted_text [
{ :text => "Failure: ", :styles => [:bold] },
{ :text => failure }
]

pdf.formatted_text [
{ :text => "Success: ", :styles => [:bold] },
{ :text => success }
]

pdf.formatted_text [
{ :text => "Exceptional Success: ", :styles => [:bold] },
{ :text => exceptional_success }
]
end

def generate
puts "Parsing spells..."
@spells = Spell.spells

puts "Creating PDF object..."
@pdf = Prawn::Document.new(:margin => 0)
pdf.default_leading 5

pdf.font_families.update(
"Goudy" => {
:normal => "goudy.ttf",
:bold => "goudy-bold.ttf",
:italic => "goudy-italic.ttf"
},
"Abess" => {
:normal => "abess.ttf"
},
"Lilith" => {
:normal => "lilith.ttf"
}
)

pdf.outline.instance_variable_set(:@book_of_faces, self)

puts "Importing cover..."
pdf.image("cover.png", :width => 612, :height => 792)
puts "Printing inner cover..."
pdf.start_new_page(:margin => 75)

pdf.font "Abess"
pdf.font_size 72
pdf.text "The Book\nOf Faces", :align => :center
puts "\tBook Of Faces big text..."

pdf.font "Goudy"
pdf.font_size 36
pdf.text "\nA grimoire of spells, Gifts, Disciplines, Contracts, and other anomalies, with anecdotes and exposition from their in-game authors\n\n", :align => :center
puts "\tDescription..."

pdf.font_size 24
pdf.text "Written by members of the /cofd/ Discord, edited by NEETzsche", :align => :center
puts "\tMain credit..."
pdf.outline.define do
end

start_chapter "One", "Introduction"
start_section "Judging It By Its Cover"
pdf.text "This tome is obviously of supernatural origin even by its first glance. It is plain even to the dumb; it practically glows with an undefined supernatural aura. It easily weighs about thirty or so pounds from all of the paper within it. It is leather bound with a very visible face on its cover and no title listed; each time people look away and take another look at it, the face on it changes. Upon opening it, it appears anachronistic and mixed. Most of the pages are merely old paper, but some of them are papyrus scrolls that have been glued into it, while others are cuneiform tablets, and some are even touch screens. Upon inspection of this tome, it's clear it should be much bigger, and much heavier, than it actually is. A quill pen is attached to it by a string. Even though a quill pen normally would only be used with ink-on-paper, it appears to also work as a tool to etch into the cuneiform tablets, as a stylus for the touch screens, and whatever else someone manages to find in this tome. Its contents change upon future viewings, making it feel like an endless sea."
start_section "Exploring Its Contents"

pdf.text "If one were to open it up and start reading, the content would make no sense. It simply cannot be understood. No amount of knowledge on High Speech, First Tongue, or whatever other language of supernatural origin seems to decipher it. However, he who possesses this book may inscribe their meaningful experiences into it. Mages can Scribe Grimoire (Mage: the Awakening, p. 166) into it, except not only is it Lasting, but they may also place their improvised spells in it as though they were Rotes. They may also write their anecdotes, philosophy and experiences within this book, as long as they are sufficiently meaningful. Other supernatural entities like vampires or werewolves may list in explicit detail their Gifts, Disciplines, Contracts or other traits."

pdf.text "This action requires an hour of soul-searching, a successful roll on their equivalent Integrity rating, and a Beat. This Beat is consumed by the book; that Beat is gone forever."

roll_results(
:dramatic_failure => "Same as failure, but in addition to this, the Book of Faces is offended at the player's arrogance. It emits a piercing roar that deals one point of Resistant aggravated damage to everyone in the room.",
:failure => "The person attempting it gave the Book Of Faces dross. It gave it crap, nonsense. Emo scribblings and cockamamie shitposts. They do not get their Beat back; turns out, their life experience wasn't that useful after all. They may try again without penalty, but must sacrifice another Beat.",
:success => "The content the character submitted is of actual value, and it is accepted, incorporated into its pages.\n\nIf the roll succeeds, for the remainder of the scene, the character may at his discretion learn any of the Rotes (as long as they have the Arcanum prerequisites, and even if they were Improvised spells when they were put into the Book of Faces) and Disciplines, may have Gifts conferred upon them, and may enter into Contracts found therein. In mechanics terms, the character reads the Book of Faces extensively for a number of hours and spends their Experiences however they desire, focusing on the things they find most interesting. If they want to use the Book of Faces again in the future, they must make a second roll.",
: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_section "Keeping It In One's Possession"

pdf.text "While the book might be extremely useful, and people would naturally want to maintain control over it for this reason, it also seems to have a mind of its own. The book has a magical habit of simply up and <i>disappearing</i>. Putting it on a bookshelf, in one's backpack, or even in a locked safe, doesn't seem to suffice to ensure it stays put. Both mundane and supernatural means of keeping it one's possession have a habit of failing. If left alone for very long, it just poofs, and finds its way into somebody else's possession.", :inline_format => true
pdf.text "After each use, whenever a person leaves the Book of Faces unattended, that person rolls Perception (Wits + Composure)."

roll_results(
:dramatic_failure => "Not only is the book lost, but its contents forgotten. It's like the previous owner never learned a thing. No Experience refund is issued. This is an exception to the normal Sanctity of Merits (or Sanctity of Anything) rule.",
:failure => "The Book of Faces disappears from this person's possession, to be found by somebody else later.",
:success => "The Book of Faces remains in the person's possession until its next use.",
:exceptional_success => "Not only does the Book of Faces remain in the person's possession, but their input is deemed particularly valuable. Their next use of the Book automatically succeeds."
)

start_section "Its True Origin"

pdf.text "There is quite a bit of dispute about the origin of the Book of Faces. A number of Awakened have insisted that only an entity deep in the labyrinths of Pandemonium could have conceived of this, but some Lost claim it is definitely some kind of Prop. Uratha typically haven't weighed in on this topic, but when they have, they surmised more than insisted that one of the more potent spirits of information or identity concocted it. Very few Kindred weigh in as well, but those few who do typically hail from the Ordo Dracul, and just as typically hautily guffaw at the thought that something other than some Methuselah Elder of great and terrible wisdom would contrive such a cruelly useful tome. Other supernatural entities have their own explanations, but as with so many things, the truth is not really known by anybody."

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_SECTION
pdf.text rating_title

rating_spells.sort_by { |spell| spell.name }.each do |spell|
puts "\t\tCompiling #{spell.full_title} by #{spell.authors.join(', ')}"
pdf.outline.add_subsection_to(rating_title) do
@pdf.outline.section spell.full_title, :destination => @pdf.page_number
end

spell_ary = [{:text => "#{spell.name} (", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}]

pdf.font_size FONT_SIZE_BODY
previous = false
spell.arcana.each do |arcanum|
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 => spell.send(arcanum).to_dots, :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -5}
previous = true
end

spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -3}

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, :inline_format => true

spell.reaches.each do |reach|
pdf.formatted_text [
{:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"},
{:text => reach[1], :font => "Goudy"},
]
end

spell.adds.each do |add|
pdf.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[:effect], :font => "Goudy"},
]
end
end
end

pdf.start_new_page
end

pdf.render_file("book_of_faces.pdf")
end
end

book_of_faces = BookOfFaces.new
book_of_faces.generate

Двоичные данные
cover.png Просмотреть файл

До После
Ширина: 2000  |  Высота: 2588  |  Размер: 5.5MB Ширина: 612  |  Высота: 792  |  Размер: 990KB

+ 239
- 0
shards_of_power.rb Просмотреть файл

@@ -0,0 +1,239 @@
require "prawn"
require "pry"

require_relative "spell"
require_relative "spells"
require_relative "primitive_adds"

puts "Shards of Power PDF generator"
class ShardsOfPower
FONT_SIZE_CHAPTER = 48
FONT_SIZE_SECTION = 24
FONT_SIZE_SUBSECTION = 18
FONT_SIZE_BODY = 10

attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name, :spells

def start_chapter(num, name)
@number_name = num
@chapter_name = name

@chapter_title = "Chapter #{number_name}: #{chapter_name}"
puts "Starting #{chapter_title}"

pdf.start_new_page

pdf.outline.update do
puts "\tAdding #{@shards_of_power.chapter_title} on page #{page_number}"
section(@shards_of_power.chapter_title, :destination => page_number)
end

puts "\tSetting font size"
pdf.font_size FONT_SIZE_CHAPTER
pdf.font "Abess"
puts "\tPrinting chapter to document"
pdf.text "Chapter #{number_name}: #{chapter_name}"

puts "\tRestoring body text"
pdf.font "Goudy"
pdf.font_size FONT_SIZE_BODY
end

def start_section(section_name)
puts "Beginning section #{section_name}: "

@section_name = section_name

pdf.outline.add_subsection_to(chapter_title) do
@pdf.outline.section section_name, :destination => @pdf.page_number
end

puts "\tSetting font size"
pdf.font_size FONT_SIZE_SECTION
pdf.text section_name

puts "\tRestoring body text"
pdf.font_size FONT_SIZE_BODY
pdf.font "Goudy"

end

def roll_results(dramatic_failure:, failure:, success:, exceptional_success:)
pdf.font_size FONT_SIZE_BODY
pdf.font "Goudy"

pdf.text "Roll Results", :style => :bold

pdf.formatted_text [
{ :text => "Dramatic Failure: ", :styles => [:bold] },
{ :text => dramatic_failure }
]

pdf.formatted_text [
{ :text => "Failure: ", :styles => [:bold] },
{ :text => failure }
]

pdf.formatted_text [
{ :text => "Success: ", :styles => [:bold] },
{ :text => success }
]

pdf.formatted_text [
{ :text => "Exceptional Success: ", :styles => [:bold] },
{ :text => exceptional_success }
]
end

def generate
puts "Parsing spells..."
@spells = Spell.spells

puts "Creating PDF object..."
@pdf = Prawn::Document.new(:margin => 0)
pdf.default_leading 5

pdf.font_families.update(
"Goudy" => {
:normal => "goudy.ttf",
:bold => "goudy-bold.ttf",
:italic => "goudy-italic.ttf"
},
"Abess" => {
:normal => "abess.ttf"
},
"Lilith" => {
:normal => "lilith.ttf"
}
)

pdf.outline.instance_variable_set(:@shards_of_power, self)

puts "Importing cover..."
pdf.image("cover.png", :width => 612, :height => 792)
puts "Printing inner cover..."
pdf.start_new_page(:margin => 75)

pdf.font "Abess"
pdf.font_size 72
pdf.text "Shards of Power", :align => :center
puts "\tShards of Power big text..."

pdf.font "Goudy"
pdf.font_size 36
pdf.text "\nA compendium of spells, Conditions, Artifacts, and other interesting tidbits for Mage: the Awakening\n\n", :align => :center
puts "\tDescription..."

pdf.font_size 24
pdf.text "Written by members of the /cofd/ Discord, edited by NEETzsche", :align => :center
puts "\tMain credit..."
pdf.outline.define do
end

start_chapter "One", "Introduction"

pdf.text "Like every supernatural entity in the Chronicles of Darkness, there is a boundless breadth and depth of topics to discuss within them. The Awakened are by no stretch of the imagination an exception to this rule. This book does not dare claim that this will cover all of them, but it does dare to cover the broad strokes on a certain subtopic of the lives of those touched by the Supernal who still reside in the Fallen World: their toolkit.\n\n<b>Mage: the Awakening</b> covered the broadest strokes on Awakened life in general, but there is so much more to the means by which Mages conduct their affairs and pursue their Obsessions that simply is not covered in that volume. There will be yet more that this one fails to consider. However, it is designed to touch on the high level ideas, and dig into some of the specifics for them, leaving you, the reader compelled, and hopefully, inspired as to where to explore next.", :inline_format => true
start_section "Tools Of Awakened Life"
pdf.text "This book is meant to be used as a toolkit. Each of the spells are modular, and for the most part do not operate off of each other. You, as the Storyteller or player, are meant to take the things you find fun, interesting and compelling while leaving the things you find silly, improper, or frustrating behind. This line of thought naturally extends to all of the Conditions, optional Arcana principles, alternative Relinquishment methods, and so on.\n\nThis book was written on a rolling basis by a number of people. It is a compilation, that accumulated over time. It did not get created overnight. As such, by the time you receive this file, there is a good likelihood that it's still in development, which means there might be more up-to-date versions of it, and additionally it may be open to input for your spells, your Artifacts, and your optional rules. The invite code at the time of publication is <b>Cx3JBpB</b>.", :inline_format => true

start_section "Chapters"

pdf.text "There are multiple chapters in this book. Each of them covers a specific set of topics.\n\n<b>Chapter One</b> is ithe Introduction. It is what you are reading now. It gives the mission statement, the credits, and a few other key details before you get into the spells and the Conditions.\n\n<b>Chapter Two</b> is the megagrimoire. It is a grimoire of grimoires, much like the book that White Wolf released when they still called themselves that, and is a combined set of spells that the players of this community have mutually agreed are at least somewhat reasonable. Many of us helped each other write these spells. All of their names will be listed in them, alphabetically.", :inline_format => true

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_SECTION
pdf.text rating_title

rating_spells.sort_by { |spell| spell.name }.each do |spell|
puts "\t\tCompiling #{spell.full_title} by #{spell.authors.join(', ')}"
pdf.outline.add_subsection_to(rating_title) do
@pdf.outline.section spell.full_title, :destination => @pdf.page_number
end

spell_ary = [{:text => "#{spell.name} (", :font => "Lilith", :color => "004E6D", :size => FONT_SIZE_SUBSECTION}]

pdf.font_size FONT_SIZE_BODY
previous = false
spell.arcana.each do |arcanum|
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 => spell.send(arcanum).to_dots, :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -5}
previous = true
end

spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => FONT_SIZE_SUBSECTION, :character_spacing => -3}

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, :inline_format => true

spell.reaches.each do |reach|
pdf.formatted_text [
{:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"},
{:text => reach[1], :font => "Goudy"},
]
end

spell.adds.each do |add|
pdf.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[:effect], :font => "Goudy"},
]
end
end
end

pdf.start_new_page
end

pdf.render_file("shards_of_power.pdf")
end
end

shards_of_power = ShardsOfPower.new
shards_of_power.generate

Загрузка…
Отмена
Сохранить