class Rsrb::GroundItems::PickupItemAction

Attributes

item[R]

Public Class Methods

new(player, item) click to toggle source
Calls superclass method Rsrb::Engine::Action::new
# File lib/rsrb/services/ground_items.rb, line 75
def initialize(player, item)
  super(player, item.on_table ? 900 : 50)
  @item = item
end

Public Instance Methods

execute() click to toggle source
# File lib/rsrb/services/ground_items.rb, line 80
def execute
  p_loc = @player.location
  item_loc = @item.location
  
  if !@item.available
    @player.walking_queue.reset
    stop
  elsif((@item.on_table && p_loc.within_interaction_distance?(item_loc)) || (p_loc.x == item_loc.x && p_loc.y == item_loc.y))
    if @player.inventory.has_room_for @item.item
      
      @player.inventory.add @item.item
      @item.remove
    else
      @player.io.send_message "You do not have enough room for that!"
    end
  end
  
  stop
end
queue_policy() click to toggle source
# File lib/rsrb/services/ground_items.rb, line 100
def queue_policy
  Rsrb::Engine::QueuePolicy::NEVER
end
walkable_policy() click to toggle source
# File lib/rsrb/services/ground_items.rb, line 104
def walkable_policy
  Rsrb::Engine::WalkablePolicy::WALKABLE
end