class ItemLibrary::HealingPotion
Public Class Methods
new(name, properties)
click to toggle source
# File lib/natural_20/item_library/healing_potion.rb, line 26 def initialize(name, properties) @name = name @properties = properties end
Public Instance Methods
build_map(action)
click to toggle source
# File lib/natural_20/item_library/healing_potion.rb, line 4 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
consumable?()
click to toggle source
# File lib/natural_20/item_library/healing_potion.rb, line 31 def consumable? @properties[:consumable] end
resolve(entity, battle)
click to toggle source
@param entity [Natural20::Entity] @param battle [Natrual20::Battle]
# File lib/natural_20/item_library/healing_potion.rb, line 37 def resolve(entity, battle) hp_regain_roll = Natural20::DieRoll.roll(@properties[:hp_regained], description: t('dice_roll.healing_potion'), entity: entity, battle: battle) { hp_gain_roll: hp_regain_roll } end
use!(entity, result)
click to toggle source
# File lib/natural_20/item_library/healing_potion.rb, line 47 def use!(entity, result) entity.heal!(result[:hp_gain_roll].result) end