class Rsrb::Actions::HarvestingAction
Attributes
loc[R]
Public Class Methods
new(player, loc)
click to toggle source
Calls superclass method
Rsrb::Engine::Action::new
# File lib/rsrb/core/actions.rb, line 5 def initialize(player, loc) super(player, 0) @loc = loc @total_cycles = 0 @cycles = 0 end
Public Instance Methods
animation()
click to toggle source
# File lib/rsrb/core/actions.rb, line 48 def animation raise "animation is abstract" end
cycles()
click to toggle source
# File lib/rsrb/core/actions.rb, line 28 def cycles raise "cycles is abstract" end
execute()
click to toggle source
# File lib/rsrb/core/actions.rb, line 56 def execute if @delay == 0 @delay = harvest_delay init if @running player.play_animation animation player.face @loc end @cycles = cycles @total_cycles = @cycles else @cycles -= 1 item = harvested_item if player.inventory.has_room_for item give_rewards(item) if (@total_cycles == 1 || rand > factor) && periodic_rewards else stop player.io.send_message "There is not enough space in your inventory." return end if @cycles == 0 # TODO Replace with expired object give_rewards item unless periodic_rewards stop else player.play_animation animation player.face @loc end end end
experience()
click to toggle source
# File lib/rsrb/core/actions.rb, line 40 def experience raise "experience is abstract" end
factor()
click to toggle source
# File lib/rsrb/core/actions.rb, line 32 def factor raise "factor is abstract" end
give_rewards(reward)
click to toggle source
# File lib/rsrb/core/actions.rb, line 91 def give_rewards(reward) @player.inventory.add reward @player.io.send_message "You get some #{reward.definition.name}." @player.skills.add_exp(skill, experience) end
harvest_delay()
click to toggle source
# File lib/rsrb/core/actions.rb, line 24 def harvest_delay raise "harvest_delay is abstract" end
harvested_item()
click to toggle source
# File lib/rsrb/core/actions.rb, line 36 def harvested_item raise "harvested_item is abstract" end
init()
click to toggle source
# File lib/rsrb/core/actions.rb, line 20 def init raise "init is abstract" end
periodic_rewards()
click to toggle source
# File lib/rsrb/core/actions.rb, line 52 def periodic_rewards raise "periodic_rewards is abstract" end
queue_policy()
click to toggle source
# File lib/rsrb/core/actions.rb, line 12 def queue_policy Rsrb::Engine::QueuePolicy::NEVER end
skill()
click to toggle source
# File lib/rsrb/core/actions.rb, line 44 def skill raise "skill is abstract" end
walkable_policy()
click to toggle source
# File lib/rsrb/core/actions.rb, line 16 def walkable_policy Rsrb::Engine::WalkablePolicy::NON_WALKABLE end