class Object

Public Instance Methods

execute_state_task(state:, profession:, line: return if line =~ /==/) click to toggle source
# File lib/RawReader.rb, line 119
def execute_state_task state:, profession:, line:
  return if line =~ /==/

  case state
  when :innate then process_innate_skills line: line
  when :strain_disadv then process_innate_skills line: line, disadvantage: true
  when :strain_block then process_innate_skills line: line, disabled: true
  when :innate_preq then process_innate_preqs line: line
  when :prof_concent then process_profession_concentration line: line
  when :prof_hierarc then process_profession_concentration_hierarchy line: line
  when :conc_group then process_profession_concentration_group line: line
  when :conc_skills then process_profession_concentration_skills line: line
  when :adv_prof then process_advanced_professions line: line
  when :adv_skills then process_profession_skills line: line, profession: profession, type: :advanced
  when :strain_rtrs then process_strain_restrictions line: line
  when :strain_stats then process_strain_stats line: line
  when :strain_specs then process_strain_specs line: line
  when :open then process_open_skills line: line
  when :profession then process_profession_skills line: line, profession: profession
  when :skill_group then process_skill_group line: line
  when :skill_counter then process_skill_counters line: line
  when :prof_ext then process_profession_extension line: line
  when :list then process_list_skills line: line
  end
end
process_advanced_professions(line: if line.strip.length == 0) click to toggle source
# File lib/RawReader.rb, line 231
def process_advanced_professions line:
  if line.strip.length == 0
    @multiline_state = nil
  else
    # Force whitespace at end to the length count is correct
    clusters = (line + ' ').split(/\:/)
    
    case clusters.length
    when 2
      @multiline_state = clusters[0].strip.to_sym
      @profession_advanced[@multiline_state] = ''

    when 1
      @profession_advanced[@multiline_state] += clusters[0]
    else
      raise RuntimeError, "#{clusters.length} clusters in multiline processing. Expected 1 or 2: #{line}"
    end
  end
process_innate_preqs(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 153
def process_innate_preqs line:
  clusters = line.split(/:/)
  strain = clusters[0].strip.to_sym
  skill = clusters[1].strip.to_sym
  preqs = process_preq_cluster cluster: clusters[2]

  @skill_cat[skill][:innate_preq] ||= Hash.new
  @skill_cat[skill][:innate_preq][strain] = preqs
end
process_innate_skills(line:, disadvantage: false, disabled: false) click to toggle source
# File lib/RawReader.rb, line 145
def process_innate_skills line:, disadvantage: false, disabled: false
  innate_skill = line.split(/:/)
  strain = innate_skill[0].to_sym
  skills = innate_skill[1].split(/,/)

  smart_insert strain: strain, skills: skills, disadvantage: disadvantage, disabled: disabled
end
process_profession_concentration(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 177
def process_profession_concentration line:
  clusters = line.split(/:/)
  right_cluster = clusters[1].split(/\,/)

  right_cluster.each do |prof|
    @profession_concentrations[prof.strip.to_sym] = clusters[0].split(/\,/).collect{ |x| x.strip.to_sym }
  end
end
process_profession_concentration_group(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 195
def process_profession_concentration_group line:
  clusters = line.split(/:/)
  right_cluster = clusters[1].split(/\,/)

  @profession_concentration_group[clusters[0].strip.to_sym] = right_cluster.collect { |x| x.strip.to_sym }
end
process_profession_concentration_hierarchy(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 186
def process_profession_concentration_hierarchy line:
  clusters = line.split(/:/)
  right_cluster = clusters[1].split(/\,/)

  right_cluster.each do |prof|
    @profession_concentration_hierarchy[prof.strip.to_sym] = clusters[0].strip.to_sym
  end
end
process_profession_concentration_skills(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 202
def process_profession_concentration_skills line:
  clusters = line.split(/:/)

  # @concentration_cat[clusters[0].strip.to_sym] = clusters[1].split(/\,/).collect{ |x| x.strip.to_sym }

  clusters[1].split(/\,/).each do |skill|
    smart_insert profession_skills: { skill: skill.strip.to_sym,
                                      profession: clusters[0].strip.to_sym,
                                      cost: 0 },
                 type: :concentration
  end
end
process_skill_counters(line: segments = line.split(':')) click to toggle source
# File lib/RawReader.rb, line 215
def process_skill_counters line:
  segments = line.split(':')
  skill_name = segments[0].strip.to_sym
  subsegs = segments[1].strip.split('|')

  if subsegs[0].length > 0
    counters = subsegs[0].strip
    @skill_counters[skill_name] = counters.split(',').collect{ |x| x.strip.to_sym }
  end

  if subsegs[1]
    countered_by = subsegs[1].strip
    @skill_countered[skill_name] = countered_by.split(',').collect{ |x| x.strip.to_sym }
  end
end
process_strain_restrictions(line: clusters = line.split(/:/)) click to toggle source
# File lib/RawReader.rb, line 163
def process_strain_restrictions line:
  clusters = line.split(/:/)
  strain = clusters[0].strip.to_sym

  if !@strains.include?(strain)
    raise KeyError, "Can't add profession restriction to non-excisting strain: #{strain}"
  end

  @strain_restrictions[strain] ||= Hash.new
  clusters[1].split(/,/).each do |x| 
    @strain_restrictions[strain][x.strip.to_sym] = true
  end
end