A book for a Mage: the Awakened game set in a cyberpunk dystopia.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

104 рядки
2.2KB

  1. require "prawn"
  2. require "prawn/table"
  3. require "pry"
  4. class Prawn::Document
  5. def background_color(color)
  6. tmp_color = fill_color
  7. canvas do
  8. fill_color color
  9. fill_rectangle [bounds.left, bounds.top], bounds.right, bounds.top
  10. end
  11. fill_color tmp_color
  12. end
  13. end
  14. class Awakened2069
  15. FONT_SIZE_CHAPTER = 48
  16. FONT_SIZE_BODY = 10
  17. attr_accessor :pdf, :chapter_title
  18. def start_chapter(chapter_name)
  19. @chapter_title = chapter_name
  20. puts "Starting #{chapter_title}"
  21. pdf.start_new_page
  22. pdf.outline.update do
  23. puts "\tAdding #{@awakened2069.chapter_title} on page #{page_number}"
  24. section(@chapter_title, :destination => page_number)
  25. end
  26. puts "\tSetting font size"
  27. pdf.font_size Awakened2069::FONT_SIZE_CHAPTER
  28. pdf.font "Abess"
  29. puts "\tPrinting chapter to document"
  30. pdf.text chapter_title, :align => :center
  31. puts "\tRestoring body text"
  32. pdf.font "Goudy"
  33. pdf.font_size FONT_SIZE_BODY
  34. end
  35. def generate
  36. @pdf = Prawn::Document.new(:margin => 0)
  37. pdf.font_families.update(
  38. "Goudy" => {
  39. :normal => "goudy.ttf",
  40. :bold => "goudy-bold.ttf",
  41. :italic => "goudy-italic.ttf"
  42. },
  43. "Abess" => {
  44. :normal => "abess.ttf"
  45. },
  46. "Lilith" => {
  47. :normal => "lilith.ttf"
  48. },
  49. "Goblin Hand" => {
  50. :normal => "VTCGoblinHand.ttf",
  51. :bold => "VTCGoblinHandBold.ttf",
  52. :italic => "VTCGoblinHandItalic.ttf"
  53. },
  54. "Ultramarines" => {
  55. :normal => "ultramarines.ttf"
  56. },
  57. "Unispace" => {
  58. :normal => "unispace rg.ttf"
  59. }
  60. )
  61. pdf.outline.instance_variable_set(:@awakened2069, self)
  62. pdf.image("cover.png", :width => 612, :height => 792)
  63. pdf.start_new_page(:margin => 50)
  64. pdf.font "Ultramarines"
  65. pdf.font_size 72
  66. pdf.text "Awakened 2069", :align => :center
  67. pdf.font "Goudy"
  68. pdf.font_size 36
  69. pdf.text "\nGuide To The Mage: the Awakening, Second Edition Game On Discord. \n\nInvite Code:", :align => :center
  70. pdf.font "Unispace"
  71. pdf.text "25MpfjP", :align => :center
  72. pdf.font "Goudy"
  73. pdf.font_size 24
  74. pdf.text "\n\nAll content in this manual is inspired by the Storyteller and the players", :align => :center
  75. start_chapter "Introduction"
  76. pdf.render_file("writeup.pdf")
  77. end
  78. end
  79. awakened2069 = Awakened2069.new
  80. awakened2069.generate