class ClasslessMud::Commands::Eat
Public Class Methods
item_from(player, target)
click to toggle source
# File lib/classless_mud/commands/eat.rb, line 21 def self.item_from player, target player.items.detect { |item| (item.keywords.split & target.split).any? } end
perform(game, player, message)
click to toggle source
# File lib/classless_mud/commands/eat.rb, line 4 def self.perform game, player, message command, target = message.split " ", 2 found = item_from player, target if found.nil? player.puts "You do not have that" else if found.edible? player.puts "You eat #{found.name}." found.affect(player) player.items.delete found player.items.save! else player.puts "You cannot eat that!" end end end