ShardsOfPower/spell.rb

77 lines
1.4 KiB
Ruby
Raw Normal View History

2019-05-27 15:02:07 -04:00
class Spell
ARCANA = [:death, :fate, :forces, :life, :matter, :mind, :prime, :space, :spirit, :time]
RANKS = ["Initiate", "Apprentice", "Disciple", "Adept", "Master"]
ARCANA.each do |arcanum|
attr_accessor arcanum
end
attr_accessor :name,
:practice,
:primary_factor,
:withstand,
:suggested_rote_skills,
:reaches,
:rules_text
attr_accessor :authors
def initialize(
death: 0,
fate: 0,
forces: 0,
life: 0,
matter: 0,
mind: 0,
prime: 0,
space: 0,
spirit: 0,
time: 0,
name:,
practice:,
primary_factor:,
withstand: nil,
suggested_rote_skills:,
reaches:,
rules_text:,
authors:)
@death = death
@fate = fate
@forces = forces
@life = life
@matter = matter
@mind = mind
@prime = prime
@space = space
@spirit = spirit
@time = time
@name = name
@practice = practice
@primary_factor = primary_factor
@withstand = withstand
@suggested_rote_skills = suggested_rote_skills
@reaches = reaches
@rules_text = rules_text
@authors = authors
end
def primary_arcanum
ARCANA.max { |arcanum| self.send(arcanum) }
end
def full_title
"#{name} (#{arcana_with_dots.join(', ')})"
end
def arcana
ARCANA.select { |arcanum| self.send(arcanum) > 0}
end
def arcana_with_dots
arcana.collect { |arcanum| arcanum_with_dots(arcanum) }
end
def arcanum_with_dots(arcanum)
"#{arcanum.to_s.titleize} #{self.send(arcanum).to_dots}"
end
end