class FTLTools::Character
Provides the basic character object.
Constants
- NOBILITY
Constant for the social rank designations.
Attributes
age[RW]
appearance[RW]
career[RW]
culture[RW]
gender[RW]
name[RW]
plot[RW]
role[RW]
temperament[RW]
terms[RW]
traits[RW]
upp[RW]
Public Class Methods
new()
click to toggle source
# File lib/ftl_tools/character.rb, line 22 def initialize @skills = Hash.new end
Public Instance Methods
add_skill(skill, level = 1)
click to toggle source
Add skills
# File lib/ftl_tools/character.rb, line 34 def add_skill(skill, level = 1) level = level.to_i if @skills.key?(skill) @skills[skill] += level else @skills[skill] = level end end
first_name()
click to toggle source
Return the first part of the name.
# File lib/ftl_tools/character.rb, line 109 def first_name @name.split(/ /)[0] end
last_name()
click to toggle source
Return the last part of the name.
# File lib/ftl_tools/character.rb, line 114 def last_name @name.split(/ /)[-1] end
modify_stat(stat, level = 1)
click to toggle source
# File lib/ftl_tools/character.rb, line 43 def modify_stat(stat, level = 1) end
noble?()
click to toggle source
Boolean, true if Noble.
# File lib/ftl_tools/character.rb, line 48 def noble? @upp[:soc] > 10 end
skills_to_s()
click to toggle source
Return an alphabetic sorted list of skills.
# File lib/ftl_tools/character.rb, line 27 def skills_to_s @skills.sort.reduce('') do |str, (skill, value)| "#{str}#{', ' unless str.empty?}#{skill}-#{value}" end end
title()
click to toggle source
Return the title, if noble.
# File lib/ftl_tools/character.rb, line 62 def title NOBILITY.dig(@upp[:soc], @gender) end
traits_s()
click to toggle source
Convert traits to a string
# File lib/ftl_tools/character.rb, line 67 def traits_s @traits.join(', ') end
upp_mod(stat)
click to toggle source
Return an int modifier based on stat.
# File lib/ftl_tools/character.rb, line 72 def upp_mod(stat) case upp[stat] when 15 then 3 when 13..14 then 2 when 10..12 then 1 when 3..5 then -1 when 1..2 then -2 else 0 end end
upp_s_to_h(upp_s)
click to toggle source
Convert a string upp to a hash.
# File lib/ftl_tools/character.rb, line 96 def upp_s_to_h(upp_s) upp_a = upp_s.split('') upp_h = Hash.new(0) upp_h[:str] = upp_a[0].hex upp_h[:dex] = upp_a[1].hex upp_h[:end] = upp_a[2].hex upp_h[:int] = upp_a[3].hex upp_h[:edu] = upp_a[4].hex upp_h[:soc] = upp_a[5].hex upp_h end
upp_to_s(upp = @upp)
click to toggle source
Convert a hash upp to a string
# File lib/ftl_tools/character.rb, line 84 def upp_to_s(upp = @upp) my_str = '' counter = 1 upp.each_pair { |k,v| my_str << '-' if counter == 7 my_str << v.to_s(16).upcase counter += 1 } my_str end