Пример #1
0
        public void Start(string[] args)
        {
            Instance           = this;
            _nounEndingHandler = new NounEndingHandler();
            _stemGenerator     = new StemGenerator();
            _nounHolder        = _stemGenerator.GenerateAllStems(true);
            _verbHolder        = new VerbHolder(_stemGenerator);
            _adjectiveHolder   = new AdjectiveHolder(_stemGenerator);
            NounPrefabs.Init(_nounHolder, _verbHolder, _adjectiveHolder, _nounEndingHandler);
            _gameState = new GameState();

            CmdRegistration.RegisterCommands();

            if (args.Length != 0)
            {
                return;
            }
            MainGameLoop();
        }
Пример #2
0
        private string ParseLine(string readLine)
        {
            if (CmdRegistration.basicCommandMap.ContainsKey(readLine.ToLower()))
            {
                return(CmdRegistration.basicCommandMap[readLine.ToLower()]());
            }
            if (CmdRegistration.complexCommandMap.Any(func => readLine.ToLower().Split(' ')[0] == func.Key) && readLine.ToLower().Split(' ').Length > 1)
            {
                return(CmdRegistration.complexCommandMap[readLine.ToLower().Split(' ')[0]](readLine.ToLower().Substring(readLine.ToLower().Split(' ')[0].Length + 1)));
            }


            #region debugging commands

            //Debug data
            if (readLine.ToLower().StartsWith("d:"))
            {
                switch (readLine.ToLower())
                {
                case "d:connectroom":
                    Console.WriteLine("What room should I connect to this one?");
                    Console.Write(">>");
                    string whatRoomShouldIConnectToThisOne = Console.ReadLine();
                    Console.WriteLine("What direction should I connect it with?");
                    Console.Write(">>");
                    bool           isWork = false;
                    RoomDirections direc;
                    isWork = Enum.TryParse(Console.ReadLine().ToUpper(), false, out direc);
                    if (isWork)
                    {
                        return("Connected rooms");
                    }
                    while (!isWork)
                    {
                        Console.WriteLine("I'm sorry, I didn't understand that, please enter \"north\" \"south\" \"east\" or \"west\".");
                        isWork = Enum.TryParse(Console.ReadLine(), false, out direc);
                    }
                    if (_gameState.currentRoom().adjoiningRooms.ContainsKey(direc))
                    {
                        return("Already have a room connected in that direction!");
                    }
                    _gameState.currentRoom().adjoiningRooms.Add(direc, () => whatRoomShouldIConnectToThisOne);
                    return("Connected rooms");

                case "d:empower":
                    _gameState.isEmpowered = true;
                    return("You are empowered now.");

                case "d:cast":
                    Console.Write(">>");
                    return(SpellCast.CastSpell(Console.ReadLine()).ToString());


                case "d:addnoun":
                    Console.WriteLine("What should I call this noun?");
                    Console.Write(">>");
                    string nounName = Console.ReadLine();
                    Console.WriteLine("What is the prefab of this noun called?");
                    Console.Write(">>");
                    string nounObjPossible = Console.ReadLine();
                    if (String.IsNullOrEmpty(nounObjPossible) || string.IsNullOrEmpty(nounName) | !NounPrefabs.prefabs.ContainsKey(nounObjPossible.ToLower()))
                    {
                        return("Not a valid noun.");
                    }
                    _gameState.currentRoom().Children.Add(nounName, NounPrefabs.prefabs[nounObjPossible.ToLower()]);
                    return("added");

                case "d:isnoun":
                    Console.Write(">>");
                    return(_nounHolder.GetIsNoun(Console.ReadLine(), _nounEndingHandler).ToString());

                case "d:generateallnouns":
                    _nounHolder = _stemGenerator.GenerateAllStems(true);
                    return("");

                case "d:parsenoun":
                    Console.Write(">>");
                    var parseInput = Console.ReadLine();
                    var returnedNounInformation = _nounHolder.GetNounFromInput(parseInput, _nounEndingHandler);
                    if (!_nounHolder.GetIsNoun(parseInput, _nounEndingHandler))
                    {
                        return("That's not a Noun!");
                    }
                    if (_nounHolder.EnglishDefinitionFromNoun(returnedNounInformation.Value.Word) == null)
                    {
                        return
                            ($"Stem : {returnedNounInformation.Value.Stem}\nCase : {returnedNounInformation.Value.NounCase}\nEnglish Definition : No definition found");
                    }
                    return
                        ($"Stem : {returnedNounInformation.Value.Stem}\nCase : {returnedNounInformation.Value.NounCase}\nEnglish Definition : {_nounHolder.EnglishDefinitionFromNoun(returnedNounInformation.Value.Word)}");

                case "d:regenerateendings":
                    _nounEndingHandler = new NounEndingHandler();
                    return("Regeneration Completed!");

                case "d:listendings":
                    return
                        ($"Nominative : {_nounEndingHandler.nominativeEnding}\nGenitive : {_nounEndingHandler.genitiveEnding}\nDative : {_nounEndingHandler.dativeEnding}\nAccusative : {_nounEndingHandler.accusativeEnding}");

                default:
                    return
                        ("No matching command\n Try:\nd:declineroot\nd:regenerateendings\nd:findtypeandstemfromword\nd:generatestem\nd:generateword");
                }
            }
            #endregion debugging commands

            return(TextUtils.Pick("Sorry, I missed that.", "I didn't understand that.", "That doesn't make sense!", "Huh?"));
        }