Module: Natural20::RogueBuilder

Included in:
CharacterBuilder
Defined in:
lib/natural_20/cli/builder/rogue_builder.rb

Instance Method Summary collapse

Instance Method Details

#rogue_builder(_build_values) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/natural_20/cli/builder/rogue_builder.rb', line 2

def rogue_builder(_build_values)
  @class_values ||= {
    attributes: [],
    saving_throw_proficiencies: %w[dexterity intelligence],
    equipped: %w[leather dagger dagger],
    inventory: [],
    tools: ['thieves_tools'],
    expertise: []
  }

  @class_values[:expertise] = prompt.multi_select(t('builder.rogue.expertise'), min: 2, max: 2) do |q|
    @values[:skills].each do |skill|
      q.choice t("builder.skill.#{skill}"), skill
    end
    q.choice t('builder.skill.thieves_tools'), 'thieves_tools'
  end

  starting_equipment = []
  starting_equipment << prompt.select(t('builder.rogue.select_starting_weapon')) do |q|
    q.choice t('object.rapier'), :rapier
    q.choice t('object.shortsword'), :shortsword
  end

  starting_equipment << prompt.select(t('builder.rogue.select_starting_weapon_2')) do |q|
    q.choice t('object.shortbow_and_quiver'), :shortbow_and_quiver
    q.choice t('object.shortsword'), :shortsword
  end

  starting_equipment.each do |equip|
    case equip
    when :rapier
      @class_values[:inventory] << {
        qty: 1,
        type: 'rapier'
      }
    when :shortbow_and_quiver
      @class_values[:inventory] += [{
        type: 'shortbow',
        qty: 1
      },
                                    {
                                      type: 'arrows',
                                      qty: 20
                                    }]
    end
  end

  shortswords = starting_equipment.select { |a| a == :shortword }.size
  if shortswords > 0
    @class_values[:inventory] << {
      type: 'shortsword',
      qty: shortswords
    }
  end

  result = Natural20::DieRoll.parse(@class_properties[:hit_die])
  @values[:max_hp] = result.die_count * result.die_type.to_i + modifier_table(@values.dig(:ability, :con))

  @class_values
end