Class: PfrpgUtility::Alignment
- Inherits:
-
Object
- Object
- PfrpgUtility::Alignment
- Defined in:
- lib/pfrpg_utility/alignment.rb
Instance Attribute Summary collapse
-
#alignment ⇒ Object
readonly
Returns the value of attribute alignment.
Class Method Summary collapse
- .any ⇒ Object
- .any_evil ⇒ Object
- .any_lawful ⇒ Object
- .any_neutral ⇒ Object
- .filter_by_character(character) ⇒ Object
- .from_deity_str(str) ⇒ Object
- .from_str(alignment_str) ⇒ Object
- .get_alignments_for_class(heroclass) ⇒ Object
- .never_lawful ⇒ Object
- .parse(alignment_str) ⇒ Object
Instance Method Summary collapse
-
#initialize(alignment) ⇒ Alignment
constructor
A new instance of Alignment.
Constructor Details
#initialize(alignment) ⇒ Alignment
Returns a new instance of Alignment.
5 6 7 |
# File 'lib/pfrpg_utility/alignment.rb', line 5 def initialize(alignment) @alignment = PfrpgUtility::Alignment.parse(alignment) end |
Instance Attribute Details
#alignment ⇒ Object (readonly)
Returns the value of attribute alignment.
4 5 6 |
# File 'lib/pfrpg_utility/alignment.rb', line 4 def alignment @alignment end |
Class Method Details
.any ⇒ Object
43 44 45 46 47 |
# File 'lib/pfrpg_utility/alignment.rb', line 43 def self.any ["Chaotic Evil", "Chaotic Neutral", "Chaotic Good", "Neutral Evil", "True Neutral", "Neutral Good", "Lawful Evil", "Lawful Neutral", "Lawful Good" ] end |
.any_evil ⇒ Object
54 55 56 |
# File 'lib/pfrpg_utility/alignment.rb', line 54 def self.any_evil ["Chaotic Evil", "Neutral Evil", "Lawful Evil"] end |
.any_lawful ⇒ Object
62 63 64 |
# File 'lib/pfrpg_utility/alignment.rb', line 62 def self.any_lawful ["Lawful Good", "Lawful Evil", "Lawful Neutral"] end |
.any_neutral ⇒ Object
58 59 60 |
# File 'lib/pfrpg_utility/alignment.rb', line 58 def self.any_neutral ["Neutral Good", "Neutral Evil", "True Neutral"] end |
.filter_by_character(character) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pfrpg_utility/alignment.rb', line 9 def self.filter_by_character(character) alignments = [] first_class = character.get_last_level.heroclass classed = get_alignments_for_class(first_class) any.each do |alignment| alignments << alignment if classed.include?(alignment) end return alignments end |
.from_deity_str(str) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/pfrpg_utility/alignment.rb', line 70 def self.from_deity_str(str) case str when "CE" from_str('Chaotic Evil') when "CN" from_str('Chaotic Neutral') when "CG" from_str('Chaotic Good') when "NE" from_str('Neutral Evil') when "NE" from_str('True Neutral') when "NG" from_str('Neutral Good') when "LE" from_str('Lawful Evil') when "LN" from_str('Lawful Neutral') when "LG" from_str('Lawful Good') end end |
.from_str(alignment_str) ⇒ Object
66 67 68 |
# File 'lib/pfrpg_utility/alignment.rb', line 66 def self.from_str(alignment_str) any.find { |x| x.downcase == alignment_str.downcase } end |
.get_alignments_for_class(heroclass) ⇒ Object
19 20 21 |
# File 'lib/pfrpg_utility/alignment.rb', line 19 def self.get_alignments_for_class(heroclass) heroclass.alignment end |
.never_lawful ⇒ Object
49 50 51 52 |
# File 'lib/pfrpg_utility/alignment.rb', line 49 def self.never_lawful ["Chaotic Evil", "Chaotic Neutral", "Chaotic Good", "Neutral Evil", "True Neutral", "Neutral Good" ] end |
.parse(alignment_str) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pfrpg_utility/alignment.rb', line 23 def self.parse(alignment_str) return "None" unless alignment_str if alignment_str.length == 2 h = { 'CN' => "Chaotic Neutral", 'CE' => "Chaotic Evil", 'CG' => "Chaotic Good", 'NE' => "Neutral Evil", "TN" => "True Neutral", "NG" => "Neutral Good", "LE" => "Lawful Evil", "LG" => "Lawful Good", "LN" => "Lawful Neutral" } return h[alignment_str] || "None" else return alignment_str end end |