Пример #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");
        }
    }
Пример #2
0
    //get work done on stuff...

    public static string Parse(string input)
    {
        string[] token;
        if (stage != 2)
        {
            token = GenericCommands.tokenize(input);
        }
        else
        {
            token = GenericCommands.tokenizeKeepCase(input);
        }
        if (stage == 1)
        {
            if (token.Length <= 0)
            {
                return("Invalid Input");
            }
            if (token.Length > 1)
            {
                return("too many args");
            }
            int parsed;
            int.TryParse(token [0], out parsed);
            if (parsed > 0 && parsed <= fileCount)
            {
                xmlFile = files [parsed - 1];

                stage = 2;
                return("Scenario input accepted! transporting to the between zone...\n\nYou find yourself floating, alone in a dark space." +
                       "\nYou wonder who brought you here, or even why you are here.\nSuddenly a voice echoes out of the darkness:\n" +
                       "You look familiar, by what name do you call yourself traveler?");
            }
            else
            {
                return("Invalid Input\n" + listXML());
            }
        }
        else if (stage == 2)
        {
            if (token.Length <= 0)
            {
                return("\nI can't quite hear you, you sound muffled.");
            }
            if (token [0].Contains("!") || token [0].Equals(token [0].ToUpper()))
            {
                return("\nI'm a tad deaf in this ear, could you try speaking louder next time *Sarcasm*.");
            }
            if (token.Length > 1 || token[0].Length > 32)
            {
                return("\nThat is too complicated for me to remember, what do you call yourself for short?");
            }
            else if (token.Length == 1)
            {
                characterName = token [0];
                stage         = 3;
                return("\nAh! " + characterName + ", you do sound like one of those. Are you here for fame, fortune, or power?");
            }
        }
        else if (stage == 3)
        {
            if (token.Length <= 0)
            {
                return("\nWhat was that? Are you here for fame, fortune, or power?");
            }
            if (input.ToLower().Equals("are all 3 an option?\n"))
            {
                return("\nsadly no, you have to choose either fame, fortune, or power.");
            }
            if (token.Length > 1)
            {
                return("\nwoah, repeat that one more time, but be quick about it and to the point; fame, fortune, or power.");
            }
            if (token [0].Equals("fame"))
            {
                type = "hunter";
            }
            else if (token [0].Equals("fortune"))
            {
                type = "thief";
            }
            else if (token [0].Equals("power"))
            {
                type = "knight";
            }
            else
            {
                return("\nyou're here for what now?");
            }
            if (type != "")
            {
                stage          = 4;
                timesSubmitted = 0;
                return("\nI didn't take you for a " + type + ", are you sure that you are a " + type + "?");
            }
        }
        else if (stage == 4)
        {
            if (token.Length <= 0)
            {
                timesSubmitted++;
                if (timesSubmitted == 1)
                {
                    return("\nHmmm? did you say something. Just tell me yes or no");
                }
                if (timesSubmitted == 2)
                {
                    return("In case you forgot, just sitting there quietly, staring into nothingness, I asked a yes or no question.\n");
                }
                if (timesSubmitted == 3)
                {
                    return("You know what, you are completely ignoring the question, I'm not even going to repeat myself this time, " +
                           "you can just scroll back up on that little bar thingy and read what I said earlier, " +
                           "I am like god, talking to you right now and I am the all seeing and all powerful being that controls the game you are playing right now" +
                           " for all of you geeks out there, this is the narrator breaking the 4th wall out of frustration, due to insensitive players such as yourself\n");
                }
                if (timesSubmitted == 4)
                {
                    return("I hate you so much...\n");
                }
                if (timesSubmitted == 5)
                {
                    return("I hate you so much more now\n");
                }
                if (timesSubmitted == 6)
                {
                    return("I hate you even more now\n");
                }
                if (timesSubmitted == 7)
                {
                    return("Hate bar loading |-|\n");
                }
                if (timesSubmitted == 8)
                {
                    return("Hate bar loading |---|\n");
                }
                if (timesSubmitted == 9)
                {
                    return("Hate bar loading |-----|\n");
                }
                if (timesSubmitted == 10)
                {
                    return("Hate bar loading |---------|\n");
                }
                if (timesSubmitted == 11)
                {
                    return("Hate bar loading |--------------|\n");
                }
                if (timesSubmitted == 12)
                {
                    return("Hate bar loading |----------------------|\n");
                }
                if (timesSubmitted == 13)
                {
                    return("Hate bar loading |--------Hate-Fully-Loaded------|\n");
                }
                if (timesSubmitted >= 14 && timesSubmitted < 100)
                {
                    return("you've done this to me " + timesSubmitted + " times\n");
                }
                if (timesSubmitted == 100)
                {
                    return("one more time and I'm going to quit the game\n");
                }
                if (timesSubmitted == 101)
                {
                    return("I'm being serious\n");
                }
                if (timesSubmitted == 102)
                {
                    return("seriously, stop\n");
                }
                if (timesSubmitted == 103)
                {
                    return("you forced me to do this\n");
                }
                if (timesSubmitted == 104)
                {
                    return("one last chance, yes or no\n");
                }
                if (timesSubmitted >= 105)
                {
                    return(GenericCommands.quit());
                }
            }

            if (token.Length > 1 && token.Length < 3)
            {
                return("\nIt's a simple yes or no");
            }
            else if (token.Length > 3)
            {
                return("\nIt's a simple yes or no not the story of your life and your indecisiveness");
            }
            else if (token [0].Equals("yes"))
            {
                stage          = 5;
                timesSubmitted = 0;
                return("\nAlright then. By the way, not to be rude or anything, but I can’t tell if you are a man or woman with that mask on. what exactly are you?");
            }
            else if (token [0].Equals("no"))
            {
                stage = 3;
                return("\nwell if you're not that, what are you here for; fame, fortune or power?");
            }
            else
            {
                return("\nI didn't quite hear you, was that a yes or a no?");
            }
        }
        else if (stage == 5)
        {
            if (token.Length <= 0)
            {
                return("\nWhat was that? I asked if you were a man or a woman.");
            }

            else if (token.Length > 1)
            {
                return("\nJust tell me if you are a man or woman.");
            }
            else if (token [0].Equals("man"))
            {
                gender = "male";
                stage  = 6;
                return(endScene(0));
            }
            else if (token [0].Equals("woman"))
            {
                gender = "female";
                stage  = 6;
                return(endScene(0));
            }
            timesSubmitted++;
            if (timesSubmitted == 1)
            {
                return("\nthat was completely unintelligible, are you a man or a woman?");
            }
            else if (timesSubmitted == 2)
            {
                return("\nthere are two choices, man or woman");
            }
            else if (timesSubmitted == 3)
            {
                return("\nman / woman");
            }
            else if (timesSubmitted == 4)
            {
                return("\nMAN / WOMAN");
            }
            else if (timesSubmitted >= 5)
            {
                return("\nHey look, the programmer is lazy and didn't put in more than two of the infinite options that are out there for gender." +
                       " Trust me, he is more lazy than insensitive to the several other options for gender. Hell, he even told me to tell you that. " +
                       "So please, just for time's sake, pick either man or woman.");
            }
        }
        else if (stage == 6)
        {
            stage = 7;
            return(endScene(1));
        }
        else if (stage == 7)
        {
            stage = 8;
            return(endScene(2));
        }
        else if (stage == 8)
        {
            return(WorldData.StartNewGame(characterName, gender, type, xmlFile));
        }

        return("Guru Mediation x0000005");
    }
Пример #3
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");
     }
 }
Пример #4
0
 public static string loadParser(string input)
 {
     string[] token = GenericCommands.tokenize(input);
     if (token.Length <= 0)
     {
         return("invalid input");
     }
     if (loadStatus == 1)
     {
         if (token.Length > 1)
         {
             return("too many args");
         }
         if (token [0].Equals("yes"))
         {
             listSaveFiles();
             if (files.Count >= 1)
             {
                 loadStatus = 2;
                 return(listSaveFiles());
             }
             else
             {
                 string s = "there aren't any save files\n";
                 if (gameState == 0)
                 {
                     ParserSelect.parserSelect = gameState;
                     return(s + "<<returning to menu>>");
                 }
                 else if (gameState == 1)
                 {
                     ParserSelect.parserSelect = gameState;
                     return(s + "<<returning to game>>");
                 }
             }
         }
         else if (token [0].Equals("no"))
         {
             if (gameState == 0)
             {
                 ParserSelect.parserSelect = gameState;
                 return("<<returning to menu>>");
             }
             else if (gameState == 1)
             {
                 ParserSelect.parserSelect = gameState;
                 return("<<returning to game>>");
             }
         }
         else
         {
             return("invalid input");
         }
     }
     if (loadStatus == 2)
     {
         if (token.Length <= 0)
         {
             return("Invalid input\n" + listSaveFiles());
         }
         if (token.Length > 1)
         {
             return("too many args");
         }
         int parsed;
         int.TryParse(token [0], out parsed);
         if (parsed > 0 && parsed <= fileCount)
         {
             GameData.GameInformation testNull = GameData.GameInformation.deserialize(files [parsed - 1]);
             if (testNull != null)
             {
                 WorldData.gameData = testNull;
                 return("<<Resuming Game>>");
             }
             else
             {
                 //return to menu / game
                 return("error loading file");
             }
         }
         else
         {
             return("Invalid input\n" + listSaveFiles());
         }
     }
     return("Guru Mediation x0000008");
 }
Пример #5
0
    public static string saveParser(string input)
    {
        string[] token = GenericCommands.tokenize(input);

        if (token.Length <= 0)
        {
            return("Invalid Input");
        }
        if (token.Length > 1)
        {
            return("too many args");
        }
        if (saveState == 1)
        {
            if (token [0].Length < 1 || token [0].Length > 64 || token.Length <= 0)
            {
                return("Save file name not valid");
            }


            if (!File.Exists(Application.persistentDataPath + "/SaveGames/" + token [0] + ".save"))
            {
                saveName = token [0] + ".save";
                if (WorldData.gameData.serialize(WorldData.gameData, saveName) == "saved")
                {
                    if (gameState == 1)
                    {
                        ParserSelect.parserSelect = gameState;
                        return("Saved!\n<<returning to game>>");
                    }
                    else if (gameState == 5)
                    {
                        ParserSelect.parserSelect = gameState;
                        return("Saved!\n<input anything to quit>");
                    }
                }
                else
                {
                    saveState = 3;
                    return("there was an error saving the game, do you want to rename the file?");
                }
            }
            else
            {
                saveState = 2;
                return("File name exists, do you want to overwrite the save file?");
            }
        }
        if (saveState == 2)
        {
            if (token [0].Equals("yes"))
            {
                if (WorldData.gameData.serialize(WorldData.gameData, saveName) == "saved")
                {
                    if (gameState == 1)
                    {
                        ParserSelect.parserSelect = gameState;
                        return("Saved!\n<<returning to game>>");
                    }
                    else if (gameState == 5)
                    {
                        ParserSelect.parserSelect = gameState;
                        return("Saved!\n<input anything to quit>");
                    }
                }
                else
                {
                    saveState = 3;
                    return("there was an error saving the game, do you want to rename the file?");
                }
            }
            if (token [0].Equals("no"))
            {
                saveState = 3;
                return("Do you want to rename your save file?");
            }
        }
        if (saveState == 3)
        {
            if (token [0].Equals("yes"))
            {
                saveState = 1;
                return("Enter in a name for the save file");
            }
            if (token [0].Equals("no"))
            {
                if (gameState == 1)
                {
                    ParserSelect.parserSelect = gameState;
                    return("Game Not Saved!\n<<returning to game>>");
                }
                else if (gameState == 5)
                {
                    ParserSelect.parserSelect = gameState;
                    return("Game Not Saved!\n");
                }
            }
        }
        return("Guru Mediation x0000007");
    }