require "Command.rb" require "Commands.rb" require "Player.rb" module RubyMud class RemoveFlag < Command def words return ["-f"] end def canUse?(object) return true if object.getFlagByClass(Admin) != nil or object.getFlagByClass(Builder) != nil return false end def initialize() super() end # Adds a flag def execute(clientConnection,string) tokens = string.split(' ') currentRoom = clientConnection.player.parent if (tokens.length != 3) clientConnection.send(tokens[0]+" objectname flagclass \r\n") return end begin flagclass = eval(tokens[2]) rescue clientConnection.send("Could not find a flag class with that name\r\n") return end # Check if the flag is infact a flag if !flagclass.ancestors.include?(Flag) clientConnection.send("Whoops #{tokens[2]} is not a flag\r\n") return end # find the object obj = currentRoom.getObjectByName(tokens[1]) if obj == nil clientConnection.send("Could not find that object\r\n") return true end # Check if the flag already is on the object flagInstance = obj.getFlagByClass(flagclass) if flagInstance == nil clientConnection.send("That flag is not on the object\r\n") return end # remove the flag obj.removeFlag(flagInstance) clientConnection.send("Removed #{tokens[2]} from #{tokens[1]}\r\n") end end # Create the instance, it adds itself to the commands list RemoveFlag.new() end #module