Class: Natural20::MageArmor
- Defined in:
- lib/natural_20/spell_library/mage_armor.rb
Instance Attribute Summary
Attributes inherited from Spell
Class Method Summary collapse
- .ac_override(entity, _effect) ⇒ Object
- .apply!(battle, item) ⇒ Object
- .equip(entity, opts = {}) ⇒ Object
Instance Method Summary collapse
- #build_map(action) ⇒ Object
- #resolve(_entity, _battle, spell_action) ⇒ Object
- #validate!(action) ⇒ Object
Methods inherited from Spell
Constructor Details
This class inherits a constructor from Natural20::Spell
Class Method Details
.ac_override(entity, _effect) ⇒ Object
47 48 49 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 47 def self.ac_override(entity, _effect) 13 + entity.dex_mod end |
.apply!(battle, item) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 29 def self.apply!(battle, item) case item[:type] when :mage_armor item[:source].add_casted_effect({ target: item[:target], effect: item[:effect], expiration: battle.session.game_time + 8.hours.to_i }) item[:target].register_effect(:ac_override, self, effect: item[:effect], source: item[:source], duration: 8.hours.to_i) item[:target].register_event_hook(:equip, self, effect: item[:effect], effect: item[:effect], source: item[:source], duration: 8.hours.to_i) Natural20::EventManager.received_event(event: :spell_buf, spell: item[:effect], source: item[:source], target: item[:target]) SpellAction.consume_resource(battle, item) end end |
.equip(entity, opts = {}) ⇒ Object
51 52 53 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 51 def self.equip(entity, opts = {}) entity.dismiss_effect!(opts[:effect]) if entity.wearing_armor? end |
Instance Method Details
#build_map(action) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 2 def build_map(action) OpenStruct.new({ param: [ { type: :select_target, num: 1, range: 5, target_types: i[allies self] } ], next: lambda { |target| action.target = target OpenStruct.new({ param: nil, next: lambda { action } }) } }) end |
#resolve(_entity, _battle, spell_action) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 58 def resolve(_entity, _battle, spell_action) [{ type: :mage_armor, target: spell_action.target, source: spell_action.source, effect: self, spell: @properties }] end |
#validate!(action) ⇒ Object
24 25 26 27 |
# File 'lib/natural_20/spell_library/mage_armor.rb', line 24 def validate!(action) @errors.clear @errors << :wearing_armor if action.target.wearing_armor? end |