Awakened2069/spells.rb

17 lines
608 B
Ruby
Raw Normal View History

2019-06-16 15:12:18 -04:00
class Spell
def self.spells
spells = []
# TESTS
duplicate_spells = spells.group_by(&:name).select {| k, v| v.length > 1 }
raise "Duplicate spells (on name) detected: #{duplicate_spells.collect{ |k,v| k}.to_list}" if duplicate_spells.length > 0
unpunctuated_spells = spells.select { |spell| spell.rules_text.unpunctuated? || spell.reaches.collect{|reach| reach[1]}.any?(&:unpunctuated?) || spell.adds.any? { |add| add[:effect].unpunctuated? } }
raise "The following spells lack punctuation: #{unpunctuated_spells.collect(&:name).to_list}" if unpunctuated_spells.length > 0
spells
end
end