class ItemLibrary::Ground
Attributes
key_name[R]
locked[R]
state[R]
Public Instance Methods
available_interactions(_entity, _battle = nil)
click to toggle source
Returns available interaction with this object @param entity [Natural20::PlayerCharacter] @return [Array]
# File lib/natural_20/item_library/ground.rb, line 80 def available_interactions(_entity, _battle = nil) [] end
build_map(action, action_object)
click to toggle source
Builds a custom UI map @param action [Symbol] The item specific action @param action_object [InteractAction] @return [OpenStruct]
# File lib/natural_20/item_library/ground.rb, line 12 def build_map(action, action_object) case action when :drop OpenStruct.new({ action: action_object, param: [ { type: :select_items, label: action_object.source.items_label, items: action_object.source.inventory } ], next: lambda { |items| action_object.other_params = items OpenStruct.new({ param: nil, next: lambda { action_object } }) } }) when :pickup OpenStruct.new({ action: action_object, param: [ { type: :select_items, label: items_label, items: inventory } ], next: lambda { |items| action_object.other_params = items OpenStruct.new({ param: nil, next: lambda { action_object } }) } }) end end
color()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 73 def color :cyan end
interactable?()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 84 def interactable? false end
list_notes(_entity, _perception, highlight: false)
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 110 def list_notes(_entity, _perception, highlight: false) inventory.map do |_item| t("object.#{m.label}", default: m.label) end end
opaque?()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 57 def opaque? false end
passable?()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 61 def passable? true end
placeable?()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 65 def placeable? true end
resolve(entity, action, other_params, opts = {})
click to toggle source
@param entity [Natural20::Entity] @param action [InteractAction]
# File lib/natural_20/item_library/ground.rb, line 90 def resolve(entity, action, other_params, opts = {}) return if action.nil? case action when :drop, :pickup { action: action, items: other_params, source: entity, target: self, battle: opts[:battle] } end end
token()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 69 def token ["\u00B7".encode('utf-8')] end
use!(_entity, result)
click to toggle source
@param entity [Natural20::Entity] @param result [Hash]
# File lib/natural_20/item_library/ground.rb, line 101 def use!(_entity, result) case result[:action] when :drop store(result[:battle], result[:source], result[:target], result[:items]) when :pickup retrieve(result[:battle], result[:source], result[:target], result[:items]) end end
Protected Instance Methods
on_take_damage(battle, damage_params)
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 118 def on_take_damage(battle, damage_params); end
setup_other_attributes()
click to toggle source
# File lib/natural_20/item_library/ground.rb, line 120 def setup_other_attributes @inventory = {} end