private void Start()
        {
            CandyCrushLogica.RegularCandies[,] playfield = new RegularCandies[7, 7];
            InitCandies(playfield);
            PrintCandies(playfield);

            CandyCrusher.ScoreRowCheck(playfield);
            ReadPlayfield("Playfield");
            WritePlayfield(playfield, "Playfield");

            if (CandyCrusher.ScoreRowCheck(playfield))
            {
                Console.WriteLine("Score row found");
            }
            else
            {
                Console.WriteLine("Score row not found");
            }

            if (CandyCrusher.ScoreColumnCheck(playfield))
            {
                Console.WriteLine("Score column found");
            }
            else
            {
                Console.WriteLine("Score column not found");
            }

            Console.ReadKey();
        }
Пример #2
0
        void start()
        {
            RegularCandy[,] candyGrid = new RegularCandy[9, 9];

            if (File.Exists(saveFilePath))
            {
                try {
                    candyGrid = readPlayingField(saveFilePath);
                } catch {
                    Console.WriteLine("Het bestand kon niet worden ingelezen, waarschijnlijk omdat hij is aangepast.");
                    Console.WriteLine("Er word nu een nieuw speelveld gegenereerd en opgeslagen");
                    initAndSaveCandies(candyGrid, saveFilePath);
                }
            }
            else
            {
                initAndSaveCandies(candyGrid, saveFilePath);
            }

            printCandies(candyGrid);

            bool scoreRowPresent    = CandyCrusher.checkScoreRowPresent(candyGrid);
            bool scoreColumnPresent = CandyCrusher.checkScoreColumnPresent(candyGrid);

            Console.WriteLine("{0}, er is {1}een score rij aanwezig", scoreRowPresent ? "Ja" : "Nee", scoreRowPresent ? "" : "GEEN ");
            Console.WriteLine("{0}, er is {1}een score kolom aanwezig", scoreColumnPresent ? "Ja" : "Nee", scoreColumnPresent ? "" : "GEEN ");

            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Regularcandies[,] speelveld = new Regularcandies[5, 5];
            CandyCrusher logic = new CandyCrusher();

            logic.InitCandies(speelveld, "candy_04");
            logic.PrintSpeelveld(speelveld);


            if (logic.ScoreKolomAanwezig(speelveld))
            {
                Console.WriteLine("Score kolom");
            }
            else
            {
                Console.WriteLine("Geen score kolom");
            }

            if (logic.ScoreRijAanwezig(speelveld))
            {
                Console.WriteLine("Score rij");
            }
            else
            {
                Console.WriteLine("Geen score rij");
            }

            Console.ReadKey();
        }
Пример #4
0
 void start(int nrOfRows, int nrOfColums)
 {
     RegularCandies[,] pf           = new RegularCandies[nrOfRows, nrOfColums];
     RegularCandies[,] playingField = initCandies(pf);
     displayCandies(playingField);
     Console.WriteLine((CandyCrusher.ScoreRowPresent(playingField)) ? "row score" : "no row score");
     Console.WriteLine((CandyCrusher.ScoreColumnPresent(playingField)) ? "column score" : "no column score");
 }
Пример #5
0
        void Start()
        {
            RegularCandies[,] playingField = new RegularCandies[8, 8];;

            string filename = "playingfield.txt";

            bool fileread = false;

            if (File.Exists(filename))
            {
                Console.WriteLine("Loading");
                try
                {
                    playingField = ReadPlayingField(filename);
                    fileread     = true;
                }

                catch (Exception)
                {
                    fileread = false;
                }
            }

            if (!fileread)
            {
                Console.WriteLine("Generating new field");
                playingField = new RegularCandies[8, 8];
                InitCandies(playingField);

                WritePlayingField(playingField, filename);
            }

            DisplayCandies(playingField);

            bool rowScored = CandyCrusher.ScoreRowPresent(playingField);
            bool colScored = CandyCrusher.ScoreColumnPresent(playingField);


            if (rowScored)
            {
                Console.WriteLine("row score!");
            }
            else
            {
                Console.WriteLine("no row score");
            }

            if (colScored)
            {
                Console.WriteLine("column score!");
            }
            else
            {
                Console.WriteLine("no column score");
            }

            Console.ReadKey();
        }
Пример #6
0
        void Start()
        {
            RegularCandies[,] speelveld = new RegularCandies[9, 9];
            string bestand;

            Console.Write("Voer uw bestand in (Geef nieuwe naam op als u een nieuw bestand wilt): ");
            bestand = Console.ReadLine() + ".txt";
            if (File.Exists(bestand))
            {
                try
                {
                    speelveld = LeesSpeelveld(bestand);
                    Console.WriteLine("Spel succesvol geladen");
                }
                catch
                {
                    Console.WriteLine("Corrupt gamefile '{0}'. Bestand is overschreven met nieuwe gegevens.", bestand);
                    InitCandies(speelveld);
                    // error, file wordt ergens anders gebruikt.
                    SchrijfSpeelveld(speelveld, bestand);
                }
            }
            else
            {
                Console.WriteLine("Nieuw spel aangemaakt voor {0}", bestand);
                InitCandies(speelveld);
                SchrijfSpeelveld(speelveld, bestand);
            }

            PrintCandies(speelveld);
            if (CandyCrusher.ScoreRijAanwezig(speelveld))
            {
                Console.WriteLine("Ja, er is een score rij aanwezig");
            }
            else
            {
                Console.WriteLine("Nee, er is geen score rij aanwezig");
            }

            if (CandyCrusher.ScoreKolomAanwezig(speelveld))
            {
                Console.WriteLine("Ja, er is een score kolom aanwezig");
            }
            else
            {
                Console.WriteLine("Nee, er is geen score kolom aanwezig");
            }
            Console.ReadKey();
        }
Пример #7
0
        bool Start()
        {
            RegularCandies[,] playingField;

            if (File.Exists("playingField.txt"))
            {
                playingField = ReadPlayingField("playingField.txt");
            }
            else
            {
                playingField = new RegularCandies[10, 10];
                InitCandies(playingField);
                WritePlayingField(playingField, "playingField.txt");
            }
            DisplayCandies(playingField);
            Console.WriteLine();
            Position pos = new Position();
            if (CandyCrusher.ScoreRowPresent(playingField, out pos))
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Row score!");
                Console.ResetColor();
                Console.WriteLine($"First position: ({pos.column}, {pos.row})");
            }
            else
            {
                Console.WriteLine("No row score.");
            }
            Console.WriteLine();
            if (CandyCrusher.ScoreColumnPresent(playingField, out pos))
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Column score!");
                Console.ResetColor();
                Console.WriteLine($"First position: ({pos.column}, {pos.row})");
            }
            else
            {
                Console.WriteLine("No column score.");
            }

            if(RemoveSaveFile())
            {
                File.Delete("playingField.txt");
                Console.WriteLine("Your safe file has been succesfully deleted.");
            }

            return ProgramTools.LoopProgram();
        }
Пример #8
0
        void Start()
        {
            RegularCandies[,] speelveld = null;
            bool error = false, rij, kolom;

            if (File.Exists("speelveld.txt"))
            {
                StreamReader reader = new StreamReader("speelveld.txt");

                try
                {
                    speelveld = LeesSpeelveld(ref reader);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Something went wrong: {e.Message}");
                    error = true;
                }
                finally
                {
                    reader.Close();
                }
            }

            if (!File.Exists("speelveld.txt") || error) //1 "unneeded if statement". This is the fallback if the catch is run.
            {
                speelveld = new RegularCandies[20, 20];
                InitCandies(ref speelveld);
                SchrijfSpeelveld(speelveld, "speelveld.txt");
            }

            PrintCandies(speelveld);
            rij   = CandyCrusher.ScoreRijAanwezig(speelveld);
            kolom = CandyCrusher.ScoreKolomAanwezig(speelveld);

            Console.WriteLine($"Horizontal: {rij}\nVertical: {kolom}");


            Console.ReadKey();
        }
Пример #9
0
        void Start()
        {
            Enums.RegularCandies[,] speelveld = new Enums.RegularCandies[9, 9];

            if (File.Exists(PATH + "veld.txt"))
            {
                Console.WriteLine("Een bestaand veld is opgeslagen...");
                InitCandies(ref speelveld, "veld.txt");
            }
            else
            {
                Console.WriteLine("Nieuw veld wordt gegenereerd...");
                InitCandies(ref speelveld);
                SchrijfSpeelveld(speelveld, "veld.txt");
            }

            Console.WriteLine();
            PrintCandies(speelveld);

            SchrijfSpeelveld(speelveld, "veld.txt");

            if (CandyCrusher.ScoreRijAanwezig(speelveld))
            {
                Console.WriteLine("Er is een score rij aanwezig");
            }
            else
            {
                Console.WriteLine("Er is GEEN score rij aanwezig");
            }

            if (CandyCrusher.ScoreKolomAanwezig(speelveld))
            {
                Console.WriteLine("Er is een score kolom aanwezig");
            }
            else
            {
                Console.WriteLine("Er is GEEN score kolom aanwezig");
            }
        }