Beispiel #1
0
        private void txtInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                var t = sender as TextBox;

                Advent.ProcessText(t.Text);


                if (miDisplayTurnCounter.Checked)
                {
                    this.Text = this.FormTitle + $" Turns: {Advent.TurnCounter}";
                }
                else
                {
                    this.Text = this.FormTitle;
                }

                if (Recorder != null && !Recorder.Playback)
                {
                    Recorder.AddInput(t.Text);
                }

                t.Text = "";
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Console.WindowWidth = 70;

            Console.Clear();
            string arg;
            string arg1;
            string userInput = null;


            try
            {
                #region Process arguments

                //no args provided or no recognised args
                if (args.Length == 0 ||
                    args.Select(a => a.Length > 1 ? a.Substring(0, 2) : a).ToArray().Intersect(flags).Count() == 0 ||
                    getFlagArg(flags[5], args) != null)
                {
                    OutputHelp();
                    return;
                }
                else if ((arg = getFlagArg(flags[2], args)) != null) //formatted output of specified game file
                {
                    var g = GameData.Load(arg);
                    g.SaveAsCommentedXML();
                    return;
                }
                else if ((arg = getFlagArg(flags[5], args)) != null) //formatted output of specified game file
                {
                    GameData.SaveAsCommentedDat(arg);
                    return;
                }

                arg          = getFlagArg(flags[1], args); //Game to load
                arg1         = getFlagArg(flags[0], args); //Save game to restore
                _TurnCounter = getFlagArg(flags[3], args) != null;
                if (arg != null)
                {
                    Advent.RoomView     += Advent_RoomView;
                    Advent.GameMessages += Advent_GameMessages;
                    if (arg1 != null)
                    {
                        Advent.RestoreGame(arg, arg1);  //restore save game
                    }
                    else
                    {
                        Advent.LoadGame(arg);   //just load
                    }
                }
                else
                {
                    Console.WriteLine("ERROR: When using -l must specify game to load with -g");
                    return;
                }



                Console.Title = "Playing: " + Advent.GameName;


                #endregion


                do
                {
                    Console.Write(Advent.PlayerPrompt);

                    Advent.ProcessText(userInput = Console.ReadLine());
                } while (!Advent.ISGameOver);

                Output();
            }
            catch (Exception e)
            {
                ErrorBox(6, 6, 60, 10, e.Message);
            }


            //write the final bar
            string exitmsg = "-Press enter to exit-";
            Console.SetCursorPosition(0, Console.WindowHeight - 2);
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Write(exitmsg + new string(' ', Console.WindowWidth - exitmsg.Length));
            Console.SetCursorPosition(exitmsg.Length + 1, Console.CursorTop - 1);
            Console.ResetColor();
            Console.Read();
            Console.Clear();
        }