예제 #1
0
파일: Debug.cs 프로젝트: Nuke928/fwod
 internal static void TalkTest(string pText)
 {
     Console.Clear();
     Player p = new Player(ConsoleTools.BufferWidth / 2, ConsoleTools.BufferHeight - 3);
     p.Initialize();
     p.Say(pText);
     Console.Clear();
 }
예제 #2
0
파일: Program.cs 프로젝트: Nuke928/fwod
        internal static int Main(string[] args)
        {
            // Default values
            string bosstext = string.Empty;
            char Pchar = '@';
            string Pname = "Player";
            bool SkipIntro = false;

            #if DEBUGGER
                args = new string[] { "--debug" };
            #endif

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                    case "/?":
                    case "--help":
                        ShowHelp();
                        return 0;
                    case "--version":
                        ShowVersion();
                        return 0;
                    case "-bosssays":
                    case "-B":
                        if (args[i + 1] != null)
                            bosstext = args[i + 1];
                        break;
                    case "-playerchar":
                    case "-C":
                        if (args[i + 1] != null)
                            Pchar = args[i + 1][0];
                        break;
                    case "--skipintro":
                        SkipIntro = true;
                        break;
                    case "--showmeme":
                        Misc.ShowMeme(); // *shrugs*
                        return 0;
                    #if DEBUG
                    case "--debug":
                        int returnint = 0;
                        Debug.StartTests(ref returnint);
                        return returnint;
                    case "--debugsay":
                        if (args[i + 1] != null)
                        {
                            Debug.TalkTest(args[i + 1]);
                            return 0;
                        }
                        else return 1;
                    #endif
                }
            }

            Console.Clear();
            Console.Title = ProjectName + " " + ProjectVersion;

            /* Try to resize the console */
            try
            {
                    Console.SetWindowSize(ConsoleTools.BufferWidth, ConsoleTools.BufferHeight);
            }
            catch(NotImplementedException)
            {
                    /* Mono sometimes throws an exception if it cannot change the window size */
                    /* If so, keep going. */
            }

            Game.EnemyList.Add(new Player());

            int w = (ConsoleTools.BufferWidth / 4) + (ConsoleTools.BufferWidth / 2);
            int h = ConsoleTools.BufferHeight / 2;

            MainPlayer = new Player((ConsoleTools.BufferWidth / 4) + (ConsoleTools.BufferWidth / 2), 
                ConsoleTools.BufferHeight / 2);
            Game.EnemyList[0] = new Player(ConsoleTools.BufferWidth / 4,
                ConsoleTools.BufferHeight / 2);

            // == Before the game ==

            string BannerText = "* Welcome to " + ProjectName + " *";
            string BannerOutline = ConsoleTools.RepeatChar('*', BannerText.Length);

            ConsoleTools.WriteLineAndCenter(Core.Layer.Game, BannerOutline);
            ConsoleTools.WriteLineAndCenter(Core.Layer.Game, BannerText);
            ConsoleTools.WriteLineAndCenter(Core.Layer.Game, BannerOutline);
            Console.WriteLine();

            #if DEBUG
                Console.WriteLine("This is a development build, so expect bugs and crashes!");
            #endif

            Console.WriteLine();
            Console.Write("Press a key to start!");

            Console.ReadKey(true);
            Console.Clear();

            // == Game starts here ==

            Core.FillScreen(Core.Layer.Game, ' ');
            Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 1, 1, ConsoleTools.BufferWidth - 2, ConsoleTools.BufferHeight - 3);

            MainPlayer.CharacterName = Pname;
            MainPlayer.CharacterChar = Pchar;
            MainPlayer.Initialize();
            Game.EnemyList[0].CharacterChar = '#';
            Game.EnemyList[0].Initialize();

            Game.UpdateEvent("You wake up after being defeated in battle");

            if (!SkipIntro)
            {
                MainPlayer.Say("Arrgh! Where am I?");

                Game.EnemyList[0].Say("Oh, you're awake...");
                Game.EnemyList[0].Say("What is your name?");

                string tmp_name = string.Empty;
                do
                {
                    tmp_name = MainPlayer.GetAnswer();
                    // If the player entered at least something and not too long
                    if (tmp_name.Length == 0)
                        Game.EnemyList[0].Say("Say something!");
                    else if (tmp_name.Length > 25)
                        Game.EnemyList[0].Say("Hey, that's way too long.");
                } while (tmp_name.Length == 0 || tmp_name.Length > 25);

                MainPlayer.CharacterName = tmp_name;
                MainPlayer.Say("It's " + MainPlayer.CharacterName + ".");

                Game.EnemyList[0].Say("Well, it's your unlucky day.");

                MainPlayer.Say("Why?");

                Game.EnemyList[0].Say("Because I will kill you.");

                MainPlayer.Say("WHAT!?!?!");

                if (bosstext.Length > 0)
                    Game.EnemyList[0].Say(bosstext);
                else
                    Game.EnemyList[0].Say("I'll be back for you, " + MainPlayer.CharacterName + "!");
            }

            bool isPlaying = true;
            do
            { // User is playing the game
                isPlaying = Entry();
            } while (isPlaying);

            // == The user is leaving the game ==

            Console.Clear();

            return 0;
        }
예제 #3
0
파일: Debug.cs 프로젝트: Nuke928/fwod
        internal static void StartTests(ref int pReturnInt)
        {
            int testnum = 0;
            try
            {
                Console.Clear();

                #region Test #0
                Console.Write("Test #" + testnum + ": Show what's in Graphics");

                Console.WriteLine();
                Console.WriteLine("Grades                   : " + new string(Game.Graphics.Tiles.Grades));
                Console.WriteLine("Half                     : " + new string(Game.Graphics.Tiles.Half));
                Console.WriteLine("Single                   : " + new string(Game.Graphics.Lines.Single));
                Console.WriteLine("SingleConnector          : " + new string(Game.Graphics.Lines.SingleConnector));
                Console.WriteLine("SingleCorner             : " + new string(Game.Graphics.Lines.SingleCorner));
                Console.WriteLine("Double                   : " + new string(Game.Graphics.Lines.Double));
                Console.WriteLine("DoubleConnector          : " + new string(Game.Graphics.Lines.DoubleConnector));
                Console.WriteLine("DoubleCorner             : " + new string(Game.Graphics.Lines.DoubleCorner));
                Console.WriteLine("DoubleHorizontalConnector: " + new string(Game.Graphics.Lines.DoubleHorizontalConnector));
                Console.WriteLine("DoubleHorizontalCorner   : " + new string(Game.Graphics.Lines.DoubleHorizontalCorner));
                Console.WriteLine("DoubleVerticalConnector  : " + new string(Game.Graphics.Lines.DoubleVerticalConnector));
                Console.WriteLine("DoubleVerticalCorner     : " + new string(Game.Graphics.Lines.DoubleVerticalCorner));

                Pause(ref testnum);
                #endregion

                #region Test #1
                Console.Write("Test #" + testnum + ": Generate 2 boxes of 4x4");

                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Single, 0, 2, 4, 4);
                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 5, 2, 4, 4);

                Pause(ref testnum);
                #endregion

                #region Test #2
                Console.Write("Test #" + testnum + ": Generate 2 boxes of 3x3");

                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Single, 0, 2, 3, 3);
                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 5, 2, 3, 3);

                Pause(ref testnum);
                #endregion

                #region Test #3
                Console.Write("Test #" + testnum + ": Generate 2 boxes of 2x2 (Minimum)");

                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Single, 0, 2, 2, 2);
                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 5, 2, 2, 2);

                Pause(ref testnum);
                #endregion

                #region Test #4
                Console.Write("Test #" + testnum + ": Generate 2 boxes inside of each other");

                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 1, 2, 4, 4);
                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Single, 2, 3, 2, 2);

                Pause(ref testnum);
                #endregion

                #region Test #5
                Console.Write("Test #" + testnum + ": Trying to generate a box with -1, -1 as width and height");

                Game.GenerateBox(Core.Layer.Game, Game.TypeOfLine.Double, 1, 1, -1, -1);

                Pause(ref testnum);
                #endregion

                #region Test #6
                Console.Write("Test #" + testnum + ": Create Player with custom position");

                Player p = new Player(ConsoleTools.BufferWidth / 2, ConsoleTools.BufferHeight - 3);

                p.Initialize();

                Pause(ref testnum);
                #endregion

                #region Test #7
                Console.Write("Test #" + testnum + ": Make the Player answer something");

                p.Initialize(); // Pause() clears the buffer

                ConsoleTools.WriteAndCenter(Core.Layer.Player, "What is your favorite food?", p.PosY - 5);

                string tt = p.GetAnswer();

                Pause(ref testnum);
                #endregion

                #region Test #8
                Console.Write("Test #" + testnum + ": Make the Player say what was asked ");

                p.Initialize(); // Pause() clears the buffer

                p.Say(tt);

                Pause(ref testnum);
                #endregion

                #region Test #9
                Console.Write("Test #" + testnum + ": Make the Player say some text (== 25 chars)");

                p.Initialize(); // Pause() clears the buffer

                p.Say("ddddddddddddddddddddddddd");

                Pause(ref testnum);
                #endregion

                #region Test #10
                Console.Write("Test #" + testnum + ": Make the Player say some text (> 25 chars)");

                p.Initialize(); // Pause() clears the buffer

                p.Say("Hey dere utube im here 2 show u my minecraft tutaliral we gonna have fun!!1");

                Pause(ref testnum);
                #endregion

                #region Test #11
                Console.Write("Test #" + testnum + ": Make the Player say a lot of text");

                p.Initialize(); // Pause() clears the buffer

                p.Say("A constant member is defined at compile time and cannot be changed at runtime.");

                Pause(ref testnum);
                #endregion

                #region Test #12
                Console.Write("Test #" + testnum + ": Recreate player at X:3 and make him talk");

                p = new Player(3, ConsoleTools.BufferHeight - 4);

                p.Initialize(); // Pause() clears the buffer

                p.Say("Didn't you knew that I was there all along?");

                Pause(ref testnum);
                #endregion

                #region Test #13
                Console.Write("Test #" + testnum + ": Recreate player at X:3|Y:1 and make him talk a bit more");

                p = new Player(10, 1);

                p.Initialize(); // Pause() clears the buffer

                p.Say("Haha! TELEPORTER B O Y S. Okay no I'll stop I swear!");

                Pause(ref testnum);
                #endregion

                #region Test #14
                Console.Write("Test #" + testnum + ": Recreate player at the right and make him talk");

                p = new Player(ConsoleTools.BufferWidth - 3, ConsoleTools.BufferHeight - 2);

                p.Initialize(); // Pause() clears the buffer

                p.Say("I will eat all of your pizza if you don't write me this documentation.");

                Pause(ref testnum);
                #endregion

                #region Test #15
                Console.Write("Test #" + testnum + ": Multi-layer test");

                // Write
                Core.Write(Core.Layer.Game, "Test", 0, 2);
                // Wait
                Console.ReadKey(true);
                // Erase
                Console.SetCursorPosition(0, 2);
                Console.Write("    ");
                // Wait
                Console.ReadKey(true);
                // Retrieve info
                string tmp = string.Empty;
                for (int i = 0; i < 4; i++)
                {
                    tmp += Core.GetCharAt(Core.Layer.Game, i, 2);
                }
                // Print back
                Console.SetCursorPosition(0, 2);
                Console.Write(tmp);

                Pause(ref testnum);
                #endregion

                #region Test #16
                Console.Write("Test #" + testnum + ": Multi-layer bubble test");

                Console.ReadKey(true);
                // Fill buffer
                Core.FillScreen(Core.Layer.Game, '.');
                // Wait
                Console.ReadKey(true);
                // Place player
                p = new Player();
                p.Initialize();
                p.Say("Woah!");

                Pause(ref testnum);
                #endregion

                #region Test #17
                Console.Write("Test #" + testnum + ": Multi-layer player test");

                Console.ReadKey(true);

                Core.FillScreen(Core.Layer.Game, '.');

                bool isTesting = true;
                do
                {
                    isTesting = fwod.MainClass.Entry();
                } while (isTesting);

                Pause(ref testnum);
                #endregion

                #region Test #18
                /*
                Console.Write("Test #" + testnum + ": Menu test");

                Menu.Show();

                Pause(ref testnum);
                */
                #endregion

                Console.Write("All tests passed without any exceptions");

                pReturnInt = 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("  !! An error occurred during test #" + testnum + " !!");
                Console.WriteLine("Exception: " + ex.GetType().ToString() + " " + string.Format("(0x{0:X8})", ex.HResult));
                Console.WriteLine("Message: " + ex.Message);
                Console.WriteLine(" -- Stack --" );
                Console.WriteLine(ex.StackTrace);

                pReturnInt = ex.HResult;
            }
        }