Exemple #1
0
        //function for deciding what to to with input
        public void EditField(Field Controler, string EditField)
        {
            switch (EditField)
            {
            //Flag Field
            case "1":
                if (Controler.IsFlagged == true)
                {
                    Console.WriteLine("Field is already flagged");
                    Console.ReadLine();
                }
                else
                {
                    Controler.IsFlagged = true;
                    Controler.Value     = "F";

                    if (Controler.IsBomb)
                    {
                        WinCon--;
                    }
                    else
                    {
                        WinCon++;
                    }
                }
                break;

            //Unflag Field
            case "2":
                if (Controler.IsFlagged == true)
                {
                    Controler.IsFlagged = false;
                    Controler.Value     = "?";
                    if (Controler.IsBomb)
                    {
                        WinCon++;
                    }
                    else
                    {
                        WinCon--;
                    }
                }
                else
                {
                    Console.WriteLine("Field is already unflagged");
                    Console.ReadLine();
                }

                break;

            //Uncover Field
            case "3":
                if (Controler.IsBomb == false)
                {
                    Controler.Value = Controler.CountBombsinArea().ToString();
                    Controler.UncoverField();
                }
                else
                {
                    GameOver = true;
                }


                break;
            }
        }