コード例 #1
0
        public void LoadGameFile()
        {
            Game   loadedGameTemplate = new Game();
            string path = editor.GetFilePath();

            loadedGameTemplate.FromCSV(path, false);
            MakeGameTemplate(loadedGameTemplate);
        }
コード例 #2
0
        public void LoadGame(string gameFilePath)
        {
            game.FromCSV(gameFilePath, true);
            (bool, bool)r = view.ChooseGame();
            bool ChoseAGame    = r.Item1;
            bool isLoadingSave = r.Item2;

            if (ChoseAGame)
            {
                game.FromCSV(gameFilePath, isLoadingSave);
                view.DrawSudoku(game);
                StartTimer();
            }
            else
            {
                view.Show("Game Load aborted");
            }
        }
コード例 #3
0
        public void ResetGame()
        {
            string gamePath = game.currentGameFile;

            game = new Game();
            game.FromCSV(gamePath, false);
            game.timeTaken = 0;
            view.ResetGame();
        }
コード例 #4
0
 public void StartSudoku(string selection, bool options)
 {
     currentFileName = selection;
     game            = new Game();
     game.FromCSV(selection, options);
     if (options == false)
     {
         game.timeTaken = 0;
     }
     sudokuForm.Initialise(game, this);
     sudokuForm.GenerateGrid(game.originalNumbersArray, game.lastSaveNumbersArray);
     sudokuForm.ShowDialog();
 }
コード例 #5
0
        public void RestartGame()
        {
            game.StopTimer();
            game.lastSaveNumbersArray = game.originalNumbersArray;
            game.numbersArray         = game.originalNumbersArray;
            game.timeTaken            = 0;
            game.ToCSV(currentFileName);

            game = new Game();
            game.FromCSV(currentFileName, false);
            sudokuForm.Initialise(game, this);
            sudokuForm.GenerateGrid(game.originalNumbersArray, game.lastSaveNumbersArray);
        }
コード例 #6
0
        public void StartEditor(int x, int y, bool editExisting, string file)
        {
            game = new Game();

            if (editExisting == false)
            {
                int[] grid = game.CreateGridBlank(x, y);
                game.Set(grid);
                editorForm.Initialise(game, this, x, y, true);
                editorForm.GenerateGrid();
                editorForm.ShowDialog();
            }
            else
            {
                game.FromCSV(file, false);
                editorForm.Initialise(game, this, x, y, false);
                editorForm.GenerateGrid();
                editorForm.ShowDialog();
            }
        }
コード例 #7
0
ファイル: Controller.cs プロジェクト: ncpleslie/Sudoku
        public void Run()
        {
            game.SetMaxValue(9);
            game.SetSquareWidth(3);
            game.SetSquareHeight(3);

            // 4 x 4
            string csv = "1,0,2,0,2,4,3,1,4,2,1,3,3,1,4,2";

            // 9 x 9
            csv = "0,3,5,6,1,4,8,9,2,8,4,2,9,7,3,5,6,1,9,6,1,2,8,5,3,7,4,2,8,6,3,4,9,1,5,7,4,1,3,8,5,7,9,2,6,5,7,9,1,2,6,4,3,8,1,5,7,4,9,2,6,8,3,6,9,4,7,3,8,2,1,5,3,2,8,5,6,1,7,4,0";
            game.FromCSV(csv);
            view.Show(game.ToPrettyString());
            //  game.GetBySquare(8, 1);
            List <int> listToCheck = game.GetByRow(8);


            //Timer timer = new Timer();
            //timer.Start();
            //view.Show("Timer Started");
            view.Show($"Blank spaces remaing: {game.CountAllBlanksRemaining()}");
            int[] changeCellValue = view.GetIntArray("Please enter a square, index, and new value");

            game.SetByRow(changeCellValue[2], changeCellValue[0], changeCellValue[1]);
            changeCellValue = view.GetIntArray("Please enter a square, index, and new value");

            game.SetByRow(changeCellValue[2], changeCellValue[0], changeCellValue[1]);

            view.Show(game.ToPrettyString());

            System.Console.WriteLine("Going Back");
            game.GoBack();
            game.GoBack();
            view.Show(game.ToPrettyString());
            System.Console.WriteLine("Going Forward");
            game.GoForward();
            game.GoForward();
            view.Show(game.ToPrettyString());
            //timer.Stop();
            //view.Show($"Final Game Time: {timer.GetTime()}");
        }