A book for a Mage: the Awakened game set in a cyberpunk dystopia.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.2KB

  1. class Spell
  2. ARCANA = [:death, :fate, :forces, :life, :matter, :mind, :prime, :space, :spirit, :time]
  3. RANKS = ["Initiate", "Apprentice", "Disciple", "Adept", "Master"]
  4. ARCANA.each do |arcanum|
  5. attr_accessor arcanum
  6. end
  7. attr_accessor :name,
  8. :practice,
  9. :primary_factor,
  10. :withstand,
  11. :suggested_rote_skills,
  12. :reaches,
  13. :adds,
  14. :rules_text,
  15. :cost,
  16. :pdf
  17. attr_accessor :authors
  18. def initialize(
  19. death: 0,
  20. fate: 0,
  21. forces: 0,
  22. life: 0,
  23. matter: 0,
  24. mind: 0,
  25. prime: 0,
  26. space: 0,
  27. spirit: 0,
  28. time: 0,
  29. name:,
  30. practice:,
  31. primary_factor:,
  32. withstand: nil,
  33. suggested_rote_skills:,
  34. reaches: [],
  35. rules_text:,
  36. authors:,
  37. adds: [],
  38. cost: nil,
  39. pdf:)
  40. @death = death
  41. @fate = fate
  42. @forces = forces
  43. @life = life
  44. @matter = matter
  45. @mind = mind
  46. @prime = prime
  47. @space = space
  48. @spirit = spirit
  49. @time = time
  50. @name = name
  51. @practice = practice
  52. @primary_factor = primary_factor
  53. @withstand = withstand
  54. @suggested_rote_skills = suggested_rote_skills
  55. @reaches = reaches
  56. @rules_text = rules_text
  57. @authors = authors
  58. @adds = adds
  59. @cost = cost
  60. @pdf = pdf
  61. end
  62. def primary_arcanum
  63. ARCANA.max { |arcanum1, arcanum2| self.send(arcanum1) <=> self.send(arcanum2) }
  64. end
  65. def full_title
  66. "#{name} (#{arcana_with_dots.join(', ')})"
  67. end
  68. def arcana
  69. ARCANA.select { |arcanum| self.send(arcanum) > 0}
  70. end
  71. def arcana_with_dots
  72. arcana.collect { |arcanum| arcanum_with_dots(arcanum) }
  73. end
  74. def arcanum_with_dots(arcanum)
  75. [arcanum, self.send(arcanum)].to_arcanum_with_dots
  76. end
  77. def render(rating_title = nil)
  78. puts "\t\tCompiling #{full_title} by #{authors.join(', ')}"
  79. pdf.outline.add_subsection_to(rating_title) do
  80. @pdf.outline.section full_title, :destination => @pdf.page_number
  81. end
  82. pdf.group do |g|
  83. unless rating_title.nil?
  84. g.font_size Awakened2069::FONT_SIZE_SECTION
  85. g.text rating_title
  86. end
  87. spell_ary = [{:text => "#{name} (", :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION}]
  88. g.font_size Awakened2069::FONT_SIZE_BODY
  89. previous = false
  90. arcana.each do |arcanum|
  91. spell_ary << {:text => ", ", :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION} if previous
  92. spell_ary << {:text => arcanum.to_s.titleize, :font => "Lilith", :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION}
  93. spell_ary << {:text => self.send(arcanum).to_dots, :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
  94. previous = true
  95. end
  96. spell_ary << {:text => " )", :font => "Lilith", :styles => [], :color => "004E6D", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -3}
  97. g.formatted_text spell_ary
  98. g.formatted_text [
  99. {:text => "Practice: ", :styles => [:bold], :font => "Goudy"},
  100. {:text => practice, :font => "Goudy"},
  101. ]
  102. g.formatted_text [
  103. {:text => "Primary Factor: ", :styles => [:bold], :font => "Goudy"},
  104. {:text => primary_factor, :font => "Goudy"},
  105. ]
  106. g.formatted_text [
  107. {:text => "Withstand: ", :styles => [:bold], :font => "Goudy"},
  108. {:text => withstand, :font => "Goudy"},
  109. ] if !withstand.nil?
  110. g.formatted_text [
  111. {:text => "Cost: ", :styles => [:bold], :font => "Goudy"},
  112. {:text => cost, :font => "Goudy"},
  113. ] if !cost.nil?
  114. g.formatted_text [
  115. {:text => "Suggested Rote Skills: ", :styles => [:bold], :font => "Goudy"},
  116. {:text => suggested_rote_skills.join(', '), :font => "Goudy"},
  117. ]
  118. g.formatted_text [
  119. {:text => authors.length == 1 ? "Author: " : "Authors: ", :styles => [:bold], :font => "Goudy"},
  120. {:text => authors.join(', '), :font => "Goudy"},
  121. ]
  122. g.text rules_text, :inline_format => true
  123. reaches.each do |reach|
  124. g.formatted_text [
  125. {:text => "+#{reach[0]} Reach: ", :styles => [:bold], :font => "Goudy"},
  126. {:text => reach[1], :font => "Goudy"},
  127. ]
  128. end
  129. adds.each do |add|
  130. g.formatted_text [
  131. {: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"},
  132. {:text => add[:effect], :font => "Goudy"},
  133. ]
  134. end
  135. end
  136. end
  137. end