public void TestArguments()
 {
     cp = new CommandParser("give lolindrath shoe");
     Assert.AreEqual(cp.RemainingArguments, cp.Arguments);
     string arg = cp.getArgument();
     Assert.AreEqual("lolindrath", arg);
     Assert.AreEqual("shoe", cp.RemainingArguments);
     arg = cp.getArgument();
     Assert.AreEqual("shoe", arg);
     Assert.AreEqual("", cp.RemainingArguments);
     cp.resetArguments();
     Assert.AreEqual(cp.Arguments, cp.RemainingArguments);
 }
Beispiel #2
0
 ///<summary>
 ///This is how the command is actually executed.
 ///</summary>
 ///<param name="p">The player who is executing the command</param>
 ///<param name="cp">The CommandParser object for the command arguments sent.</param>
 public abstract void doCommand(Player p, CommandParser cp);
 public void TestCommandVerb()
 {
     cp = new CommandParser("look");
     Assert.AreEqual(cp.CommandVerb, "look");
 }
Beispiel #4
0
        ///<summary>
        ///Takes one line of input and passes it through the command parser, then
        ///if it is a valid command it runs it for the user.
        ///</summary>
        ///<param name="p">the player who input the line</param>
        ///<param name="line">the command line itself</param>
        private void interpret(Player p, string line)
        {
            CommandParser cp = new CommandParser(line);

            BaseCommand c = CommandList.findCommand(cp.CommandVerb);

            if(c != null && p.Level >= c.UseLevel)
            {
                c.doCommand(p, cp);
            }
            else
            {
                p.OutBuffer.Append("Type 'commands' to see what commands are available.\n\r");
            }
        }