From b288c76ac69cae68f28cb734c9980a8d34213c22 Mon Sep 17 00:00:00 2001
From: DamianKomdeur <77113617+DamianKomdeur@users.noreply.github.com>
Date: Mon, 2 Dec 2024 12:12:24 +0100
Subject: [PATCH] Bug fixes

---
 PuzzlePlayer/Binary.cs                              |   2 +-
 PuzzlePlayer/Board.cs                               |   4 ++--
 PuzzlePlayer/PuzzleForm.cs                          |  11 +++++++++--
 PuzzlePlayer/PuzzlePlayer.cs                        |   7 +++----
 PuzzlePlayer/Resources/{Binair.jpg => Binary.jpg}   | Bin
 .../Resources/{BinairGray.jpg => BinaryGray.jpg}    | Bin
 6 files changed, 15 insertions(+), 9 deletions(-)
 rename PuzzlePlayer/Resources/{Binair.jpg => Binary.jpg} (100%)
 rename PuzzlePlayer/Resources/{BinairGray.jpg => BinaryGray.jpg} (100%)

diff --git a/PuzzlePlayer/Binary.cs b/PuzzlePlayer/Binary.cs
index 0f954f4..385aa0c 100644
--- a/PuzzlePlayer/Binary.cs
+++ b/PuzzlePlayer/Binary.cs
@@ -26,7 +26,7 @@ namespace PuzzlePlayer_Namespace
             description = "Binary puzzle is played on any even-numbered square grid, with some cells initially containing black or white circles. The goal of the puzzle is to fill all cells such that:\r\n● More than two circles of the same color cannot be adjacent\r\n● Each row and column must contain an equal number of black and white circles\r\n● Each row and column cannot appear multiple times on the board";
 
             // clear the board (fill it in with -1)
-            Clear();
+            //Clear(false);
         }
 
         public override void Draw (Graphics gr, Rectangle r) //draws board in rectangle R. warning: will stretch image unless FitBoard() is used for rectangle size
diff --git a/PuzzlePlayer/Board.cs b/PuzzlePlayer/Board.cs
index 739b48a..85245dd 100644
--- a/PuzzlePlayer/Board.cs
+++ b/PuzzlePlayer/Board.cs
@@ -51,7 +51,7 @@ namespace PuzzlePlayer_Namespace
         {
             int[,] copy = boardState;
             boardState = newState;
-            if (IsBoardValid(newState) && Solve() == SOLUTIONS.UNIQUE)
+            if (IsBoardValid(newState) && Solve(false) == SOLUTIONS.UNIQUE)
                 return true;
             else
             {
@@ -115,7 +115,7 @@ namespace PuzzlePlayer_Namespace
         public abstract void Generate();
 
         // abstract methode for checking if a imputed boardstate is valid
-        public abstract bool IsBoardValid(int[,] boardToCheck);
+        public virtual bool IsBoardValid(int[,] boardToCheck) { return true; }
 
         // changes tile P to value X
         public abstract void TileInput(Point p, int x);
diff --git a/PuzzlePlayer/PuzzleForm.cs b/PuzzlePlayer/PuzzleForm.cs
index dde1ea0..8f1033b 100644
--- a/PuzzlePlayer/PuzzleForm.cs
+++ b/PuzzlePlayer/PuzzleForm.cs
@@ -21,6 +21,7 @@ namespace PuzzlePlayer_Namespace
         private readonly BufferedGraphics bufferedGraphics;
         private Board board;
         public Board Board //updating the Board member will immediately call board.Draw method so that the board is updated visually
+
         {
             get { return board; }
             set
@@ -31,6 +32,13 @@ namespace PuzzlePlayer_Namespace
         }
 
         private readonly Button UPDATEBUTTON;
+        public string puzzleType { get; }
+        public PuzzleForm(Board b)
+        {
+            board = b;
+            puzzleType = b.GetType().Name;
+        }
+
         public PuzzleForm(Board b, Size s = default) //takes Board and Size parameter and sets up the PuzzleForm window.
         {
             if (s == default) s = new Size(700, 420);
@@ -104,7 +112,6 @@ namespace PuzzlePlayer_Namespace
             hintbutton.Text = "Hint";
             hintbutton.MouseClick += (object sender, MouseEventArgs mea) =>
             {
-                board.Draw(graphics, boardP, boardS);
                 MessageBox.Show("Hint: geef op");
                 Board = Board;
             };
@@ -112,7 +119,7 @@ namespace PuzzlePlayer_Namespace
             solvebutton.Text = "Solve";
             solvebutton.MouseClick += (object sender, MouseEventArgs mea) =>
             {
-                Board.Solve();
+                Board.Solve(false);
                 Board = Board;
             };
 
diff --git a/PuzzlePlayer/PuzzlePlayer.cs b/PuzzlePlayer/PuzzlePlayer.cs
index 865952b..9f617b4 100644
--- a/PuzzlePlayer/PuzzlePlayer.cs
+++ b/PuzzlePlayer/PuzzlePlayer.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Drawing;
 using System.Windows.Forms;
-using static System.Windows.Forms.DataFormats;
 
 namespace PuzzlePlayer_Namespace
 {
@@ -11,7 +10,7 @@ namespace PuzzlePlayer_Namespace
     {
         internal static void Main(string[] args)
         {
-            Application.Run(new MainForm());
+            Application.Run(new PuzzleForm(new Binary()));
         }
     }
 
@@ -29,9 +28,9 @@ namespace PuzzlePlayer_Namespace
         {
             for (int i = 0; i < 5; i++)
             {
-                puzzleForms.Add(new PuzzleForm(new Binair()));
+                puzzleForms.Add(new PuzzleForm(new Binary()));
             }
-            puzzleForms.Add(new PuzzleForm(new Binair()));
+            puzzleForms.Add(new PuzzleForm(new Binary()));
         }
 
         private void SetUpUI()
diff --git a/PuzzlePlayer/Resources/Binair.jpg b/PuzzlePlayer/Resources/Binary.jpg
similarity index 100%
rename from PuzzlePlayer/Resources/Binair.jpg
rename to PuzzlePlayer/Resources/Binary.jpg
diff --git a/PuzzlePlayer/Resources/BinairGray.jpg b/PuzzlePlayer/Resources/BinaryGray.jpg
similarity index 100%
rename from PuzzlePlayer/Resources/BinairGray.jpg
rename to PuzzlePlayer/Resources/BinaryGray.jpg
-- 
GitLab