Module: Natural20::WizardClass
- Included in:
- PlayerCharacter
- Defined in:
- lib/natural_20/concerns/wizard_class.rb
Overview
typed: false
Constant Summary collapse
- WIZARD_SPELL_SLOT_TABLE =
[ # cantrips, 1st, 2nd, 3rd ... etc [3, 2], # 1 [3, 3], # 2 [3, 4, 2], # 3 [4, 4, 3], # 4 [4, 4, 3, 2], # 5 [4, 4, 3, 3], # 6 [4, 4, 3, 3, 1], # 7 [4, 4, 3, 3, 2], # 8 [4, 4, 3, 3, 3, 1], # 9 [5, 4, 3, 3, 3, 2], # 10 [5, 4, 3, 3, 3, 2, 1], # 11 [5, 4, 3, 3, 3, 2, 1], # 12 [5, 4, 3, 3, 3, 2, 1, 1], # 13 [5, 4, 3, 3, 3, 2, 1, 1], # 14 [5, 4, 3, 3, 3, 2, 1, 1, 1], # 15 [5, 4, 3, 3, 3, 2, 1, 1, 1], # 16 [5, 4, 3, 3, 3, 2, 1, 1, 1, 1], # 17 [5, 4, 3, 3, 3, 3, 1, 1, 1, 1], # 18 [5, 4, 3, 3, 3, 3, 2, 1, 1, 1], # 19 [5, 4, 3, 3, 3, 3, 2, 2, 1, 1] # 20 ].freeze
Instance Attribute Summary collapse
-
#arcane_recovery ⇒ Object
Returns the value of attribute arcane_recovery.
-
#wizard_level ⇒ Object
Returns the value of attribute wizard_level.
-
#wizard_spell_slots ⇒ Object
Returns the value of attribute wizard_spell_slots.
Instance Method Summary collapse
- #initialize_wizard ⇒ Object
- #max_slots_for_wizard(level) ⇒ Object
- #short_rest_for_wizard(battle) ⇒ Object
- #special_actions_for_wizard(_session, _battle) ⇒ Object
- #spell_attack_modifier ⇒ Object
Instance Attribute Details
#arcane_recovery ⇒ Object
Returns the value of attribute arcane_recovery.
28 29 30 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 28 def arcane_recovery @arcane_recovery end |
#wizard_level ⇒ Object
Returns the value of attribute wizard_level.
28 29 30 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 28 def wizard_level @wizard_level end |
#wizard_spell_slots ⇒ Object
Returns the value of attribute wizard_spell_slots.
28 29 30 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 28 def wizard_spell_slots @wizard_spell_slots end |
Instance Method Details
#initialize_wizard ⇒ Object
30 31 32 33 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 30 def initialize_wizard @spell_slots[:wizard] = reset_spell_slots @arcane_recovery = 1 end |
#max_slots_for_wizard(level) ⇒ Object
75 76 77 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 75 def max_slots_for_wizard(level) WIZARD_SPELL_SLOT_TABLE[wizard_level - 1][level] || 0 end |
#short_rest_for_wizard(battle) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 44 def short_rest_for_wizard(battle) if @arcane_recovery.positive? controller = battle.controller_for(self) if controller && controller.respond_to?(:arcane_recovery_ui) max_sum = (wizard_level / 2).ceil loop do current_sum = 0 avail_levels = WIZARD_SPELL_SLOT_TABLE[wizard_level - 1].each_with_index.map do |slots, index| next if index.zero? next if index >= 6 # none of the spell sltos can be 6 or higher next if @spell_slots[:wizard][index] >= slots next if current_sum > max_sum current_sum += index index end.compact break if avail_levels.empty? level = controller.arcane_recovery_ui(self, avail_levels) break if level.nil? @spell_slots[:wizard][level] += 1 @arcane_recovery = 0 max_sum -= level end end end end |
#special_actions_for_wizard(_session, _battle) ⇒ Object
39 40 41 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 39 def special_actions_for_wizard(_session, _battle) [] end |
#spell_attack_modifier ⇒ Object
35 36 37 |
# File 'lib/natural_20/concerns/wizard_class.rb', line 35 def spell_attack_modifier proficiency_bonus + int_mod end |