Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //This loads first when the program is started using this i can in essence loop the program
            int        replay = 0;
            MasterMind myMastermindprogram = new MasterMind();

            myMastermindprogram.RunProgram();

            //Checks to see if the player wants to play again
            Console.WriteLine("\n\nWould you like to play again? (1 to reply & 0 to exit)");
            replay = Convert.ToInt32(Console.ReadLine());
            if (replay == 1)
            {
                //if they do it reloads the program from the start
                Console.WriteLine("\n\n\n");
                MasterMind replayMasterMind = new MasterMind();
                replayMasterMind.RunProgram();
            }
            else
            {
                //if not it gives the user the option to exit with a keypress
                Console.WriteLine("\n\n===============================");
                Console.WriteLine("MasterMind: Press any key to finish");
                Console.ReadKey();
            }
            //i am aware of the bug that exits the program after it has been replayed again i was not able to fix it in time
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var game = new MasterMind();

            game.Play();
            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args) //wipes game and starts new one
        {
            var game = new MasterMind();

            game.Play();


            Console.ReadLine();
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to MasterMind");
            MasterMind masterMind  = new MasterMind();
            int        tries       = 1;
            bool       keepPlaying = true;

            while (keepPlaying)
            {
                while (tries <= 10)
                {
                    string input  = Console.ReadLine();
                    string result = masterMind.RunCode(input);
                    Console.WriteLine(result);
                    if (result == "++++")
                    {
                        Console.WriteLine("Congrats you guessed the code correctly");
                        break;
                    }
                    else if (result.Length <= 4)
                    {
                        Console.WriteLine("You have {0} tries remaining", 10 - tries);
                        tries++;
                    }
                }
                Console.WriteLine("Do you want to play again y/n?");
                string playAgain = Console.ReadLine();
                if (playAgain == "y")
                {
                    masterMind = new MasterMind();
                    tries      = 1;
                }
                else
                {
                    keepPlaying = false;
                }
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //============================PASSAGE DE PARAMETRES=============================//
            MasterMind.PARAM joueur1 = MasterMind.PARAM.PLAYER;
            MasterMind.PARAM joueur2 = MasterMind.PARAM.PC;
            int NBTOKENS             = 5;

            if (args.Length > 0)
            {
                if (args[0].Equals("/?"))
                {
                    Console.Write("====MasterMind====\n" +
                                  "MasterMind.exe <Joueur1> <Joueur2> <NB jetons>\n" +
                                  "Joueur = \"PC\" \"PLAYER\"\n" +
                                  "/!\\ L'IA en J2 ne tient que 6 jetons. ENJOY\n" +
                                  "==================");
                    Environment.Exit(0);
                }
                try
                {
                    joueur1 = (MasterMind.PARAM)Enum.Parse(typeof(MasterMind.PARAM), args[0]);
                    if (args.Length > 1)
                    {
                        joueur2 = (MasterMind.PARAM)Enum.Parse(typeof(MasterMind.PARAM), args[1]);
                    }
                    if (args.Length > 2)
                    {
                        NBTOKENS = int.Parse(args[2]);
                    }
                }
                catch
                {
                    Console.WriteLine("Arguments non valides, pour plus d'info: \"MasterMind /?\"");
                    Environment.Exit(0);
                }
                if (NBTOKENS > 6 || NBTOKENS < 3)
                {
                    throw new Exception("Nombre de tokens invalide.");
                }
            }
            //============================"INTERFACE GRAPHIQUE"=============================//
            Console.Clear();
            Console.BackgroundColor = ConsoleColor.DarkGray;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.SetWindowSize(51, 36);
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MINIMIZE, MF_BYCOMMAND);      /////////////////
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MAXIMIZE, MF_BYCOMMAND);      //https://stackoverflow.com/users/8498455/sven7   "Is there a way to make fixed console?"
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_SIZE, MF_BYCOMMAND);          /////////////////

            (" ......---....---..............................           .\n" +                    /////////////////
             "`-----------------------------------------------`          .\n" +                   //https://www.text-image.com/convert/pic2ascii.cgi
             "`.-. `///////////////////////////////////////.`.-.`        .\n" +                   /////////////////
             "`.-.`:ooosooosooosooosooosooosooosooosooosooo:`.-.`        .\n" +
             "`.-.`:osooosooosooosooosooosooosooosooosoooso:`.-.`        .\n" +
             "`.-.`:ossoo                             oosso:`.-.`        .\n" +
             "`.-.`:oosso                             ossoo:`.-.`        .\n" +
             "`.-.`:oosso                             ossoo:`.-.`        .\n" +
             "`.-.`:oosoo                             osooo:`.-.`        .\n" +
             "`.-.`:ossoo                             oosso:`.-.`        .\n" +
             "`.-.`:ossoo                             oosso:`.-.`        .\n" +
             "`.-.`:oosoo                             oosoo:`.-.`        .\n" +
             "`.-.`:oosso                             ossoo:`.-.`        .\n" +
             "`.-.`:oosso                             ossoo:`.-.`        .\n" +
             "`.-.`:sssoo                             oosss:`.-.`        .\n" +
             "`.-.`:oosoo                             oosoo:`.-.`        .\n" +
             "`.-.`:ooosooosooosooosooosooosooosooosooosooo:`.-.`        .\n" +
             "`.-..........................................`..-.`        .\n" +
             "`.-.-Nintendo.Game.Boy..........................-.`        .\n" +
             "`.-.............................................-.`        .\n" +
             "`.-.............................................-.`        .\n" +
             "`.-.....................................-----...-.`        .\n" +
             "`.-...-/-    -........................--y   y-..-.`        .\n" +
             "`.-.-/---    ---...............--------l     l-.-.`        .\n" +
             "`.-..            .............--y   y---y   y.-.-.`        .\n" +
             "`.-..            -............-l     l-------B-.-.`        .\n" +
             "`.-...---    ---/-.............-y   y.-A-.......-.`        .\n" +
             "`.-.....-    -/-................-------.........-.`        .\n" +
             "`.-.......................................-.....-.`        .\n" +
             "`.-.................//l::...//a::.......----//-.-.`        .\n" +
             "`.-...............//e::...//t::.....---//+-+-+//-.`        .\n" +
             "`.-.............//s::-.://s::.....---+-+//-+-+-//.`        .\n" +
             "`.-...............................--//-+-+-//+-//          .\n" +
             "`.-..................................-//+-+-////           .\n" +
             "`.-....................................-/////              .\n" +
             "    '''''''''''':::::::::::::::::''''''                    .").Draw();
            Console.ForegroundColor = ConsoleColor.Black;
            "HHHH".Draw(9, 22);
            "HHHH".Draw(9, 23);
            "HHHHHHHHHHHH".Draw(5, 24);
            "HHHHHHHHHHHH".Draw(5, 25);
            "HHHH".Draw(9, 26);
            "HHHH".Draw(9, 27);
            Console.ForegroundColor = ConsoleColor.DarkRed;
            "mmm".Draw(41, 22);
            "mm@mm".Draw(40, 23);
            "mmm".Draw(41, 24);
            "mmm".Draw(33, 24);
            "mm@mm".Draw(32, 25);
            "mmm".Draw(33, 26);
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.ForegroundColor = ConsoleColor.Black;
            "|====== MASTERMIND =======|".Draw(12, 5);
            "|                         |".Draw(12, 6);
            "|                         |".Draw(12, 7);
            "|                         |".Draw(12, 8);
            "|                         |".Draw(12, 9);
            "|                         |".Draw(12, 10);
            "|                         |".Draw(12, 11);
            "|                         |".Draw(12, 12);
            "|                         |".Draw(12, 13);
            "|                         |".Draw(12, 14);
            "|_________________________|".Draw(12, 15);

            //============================BOUCLE DU MAIN=====================================//
            MasterMind instance = new MasterMind(joueur1, joueur2, NBTOKENS, 13, 6);

            do
            {
                int NB_TRY = instance.Start();
                "                        ".Draw(13, 7 + NB_TRY % 9);
                if (NB_TRY < 7)
                {
                    "Well Played!!!       ".Draw(13, 7 + NB_TRY % 9);
                }
                else
                {
                    "Not Great..Try Again!".Draw(13, 7 + NB_TRY % 9);
                }
            } while (Console.ReadKey(true).KeyChar == (char)ConsoleKey.Enter);
        }