A book for a Mage: the Awakened game set in a cyberpunk dystopia.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

68 satır
2.4KB

  1. class Merit
  2. attr_accessor :name,
  3. :prerequisites,
  4. :adjectives,
  5. :dot_ratings,
  6. :rules_text,
  7. :ranks,
  8. :pdf
  9. attr_accessor :authors
  10. def initialize(name:, prerequisites: nil, adjectives: [], dot_ratings: [], rules_text:, ranks: nil, pdf:)
  11. @name = name
  12. @prerequisites = prerequisites
  13. @adjectives = adjectives
  14. @dot_ratings = dot_ratings
  15. @rules_text = rules_text
  16. @ranks = ranks
  17. @pdf = pdf
  18. @dot_ratings = @dot_ratings.arrayify
  19. @prerequisites = @prerequisites.arrayify
  20. @adjectives = @adjectives.arrayify
  21. end
  22. def render
  23. merit_ary = [{:text => "#{name} (", :font => "Lilith", :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION}]
  24. previous = false
  25. dot_ratings.each do |dr|
  26. merit_ary << {:text => ", ", :font => "Lilith", :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION} if previous
  27. previous = true
  28. if dr.class == Range
  29. merit_ary << {:text => dr.min.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
  30. if dr.max < Float::INFINITY
  31. merit_ary << {:text => " to ", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
  32. merit_ary << {:text => dr.max.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
  33. else
  34. merit_ary << {:text => "+", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
  35. end
  36. elsif dr.class == Integer
  37. merit_ary << {:text => dr.to_dots, :color => "000000", :size => Awakened2069::FONT_SIZE_SUBSECTION, :character_spacing => -5}
  38. end
  39. end
  40. adjectives.each do |adj|
  41. merit_ary << {:text => ", #{adj}", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
  42. end
  43. merit_ary << {:text => ")", :color => "000000", :font => "Lilith", :size => Awakened2069::FONT_SIZE_SUBSECTION}
  44. pdf.group do |g|
  45. g.font_size Awakened2069::FONT_SIZE_BODY
  46. g.formatted_text merit_ary, :indent_paragraphs => Awakened2069::INDENT_SIZE
  47. if prerequisites.size >= 1
  48. prerequisites_text = prerequisites.join(", ")
  49. g.text "<b>#{prerequisites.size == 1 ? "Prerequisite" : "Prerequisites"}:</b> #{prerequisites_text}", :inline_format => true, :indent_paragraphs => Awakened2069::INDENT_SIZE
  50. end
  51. g.text "<b>Effect:</b> #{rules_text}", :inline_format => true, :indent_paragraphs => Awakened2069::INDENT_SIZE
  52. end
  53. self
  54. end
  55. end