Exemplo n.º 1
0
    public static string Parse(string input)
    {
        if (commandList0 == null)
        {
            initializeCommands();
        }
        string[] token = GenericCommands.tokenize(input);
        if (token.Length <= 0 || !commandList0.ContainsKey(token [0].ToLower()))
        {
            return("Please enter a valid command");
        }

        int command = commandList0 [token [0].ToLower()];

        if (command == 0)
        {
            return(help(token));
        }
        else if (command == 1)
        {
            return(GenericCommands.clear(token));
        }
        else if (command == 2)
        {
            return(GenericCommands.startQuit(token));
        }
        else if (command == 3)
        {
            return(GameData.startLoad(token));
        }
        else if (command == 4)
        {
            return(NewGameParser.startNewGame(token));
        }
        else if (command == 5)
        {
            return(import(token));
        }
        else
        {
            return("you have entered in a valid command");
        }
    }
Exemplo n.º 2
0
 public static string Parse(string input)
 {
     if (commandList1 == null)
     {
         initializeCommands();
     }
     string[] token = GenericCommands.tokenize(input);
     if (token.Length <= 0 || !commandList1.ContainsKey(token [0].ToLower()))
     {
         return("Please enter a valid command");
     }
     else if (devCommandList.ContainsKey(token [0].ToLower()))
     {
         #region devmode args
         int devcommand = devCommandList [token [0].ToLower()];
         if (devmode == true)
         {
             if (devcommand == 0)
             {
                 if (token.Length > 2)
                 {
                     return("too many args");
                 }
                 else if (token.Length <= 1)
                 {
                     return("devmode is enabled");
                 }
                 else if (token [1].ToLower().Equals("enable"))
                 {
                     return("devmode is already enabled");
                 }
                 else if (token [1].ToLower().Equals("disable"))
                 {
                     devmode = false;
                     return("devmode is now disabled");
                 }
                 else
                 {
                     return("unrecognized modifier");
                 }
             }
             else if (devcommand == 1)
             {
                 return("set location");
             }
             else if (devcommand == 2)
             {
                 return("add item");
             }
             else if (devcommand == 3)
             {
                 return("create location");
             }
             else if (devcommand == 4)
             {
                 return("export XML");
             }
         }
         else if (devmode == false)
         {
             if (devcommand == 0)
             {
                 if (token.Length > 2)
                 {
                     return("too many args");
                 }
                 else if (token.Length <= 1)
                 {
                     return("devmode is disabled");
                 }
                 else if (token [1].ToLower().Equals("enable"))
                 {
                     devmode = true;
                     return("devmode is now enabled");
                 }
                 else if (token [1].ToLower().Equals("disable"))
                 {
                     return("devmode is already disabled");
                 }
                 else
                 {
                     return("unrecognized modifier");
                 }
             }
         }
         #endregion
     }
     int command = commandList1 [token [0].ToLower()];
     if (command == 0)
     {
         return(help(token));
     }
     else if (command == 1)
     {
         return(GenericCommands.clear(token));
     }
     else if (command == 2)
     {
         return(look(token));
     }
     else if (command == 3)
     {
         return(go(token));
     }
     else if (command == 4)
     {
         return(pickup(token));
     }
     else if (command == 5)
     {
         return(drop(token));
     }
     else if (command == 6)
     {
         return(listInventory(token));
     }
     else if (command == 7)
     {
         return(GenericCommands.startQuit(token));
     }
     else if (command == 8)
     {
         return(Inventory.open(token));
     }
     else if (command == 9)
     {
         return(Inventory.close(token));
     }
     else if (command == 10)
     {
         return(Inventory.equip(token));
     }
     else if (command == 11)
     {
         return(Inventory.unequip(token));
     }
     else if (command == 12)
     {
         return(Inventory.use(token));
     }
     else if (command == 13)
     {
         return(GameData.startSave(token));
     }
     else if (command == 14)
     {
         return(GameData.startLoad(token));
     }
     else
     {
         return("you have entered in a valid command");
     }
 }