From c0ba107cf29ab5dc29eeaa04a33cc6932fbe80be Mon Sep 17 00:00:00 2001
From: Seilenthal <mark.seilenthal@siemens.com>
Date: Mon, 16 Dec 2024 13:57:53 +0100
Subject: [PATCH] Bug-Fix + Decorations

---
 MastermindController.cs | 10 +++++-----
 MastermindGame.cs       | 41 ++++++++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/MastermindController.cs b/MastermindController.cs
index dd6630a..4b5ef9a 100644
--- a/MastermindController.cs
+++ b/MastermindController.cs
@@ -63,9 +63,9 @@ namespace Controller
             } while (!checkMenu);
 
             // User selects a difficulty
-            Console.WriteLine(new string('=', 30));
+            Console.WriteLine(new string('=', 71));
             Console.WriteLine("Please select the difficulty you would like to play on:\n");
-            Console.WriteLine(new string('-', 30));
+            Console.WriteLine(new string('-', 71));
 
             // Initializing temporary object to soft code
             MastermindGame tmpObject = new MastermindGame("easy");
@@ -73,21 +73,21 @@ namespace Controller
             Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long.");
             Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts.");
             Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}");
-            Console.WriteLine(new string('-', 30));
+            Console.WriteLine(new string('-', 71));
 
             tmpObject = new MastermindGame("medium");
             Console.WriteLine("Difficulty: \t[M]edium \nDescription: \tRecommended for advanced users.\n");
             Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long.");
             Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts.");
             Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}");
-            Console.WriteLine(new string('-', 30));
+            Console.WriteLine(new string('-', 71));
 
             tmpObject = new MastermindGame("hard");
             Console.WriteLine("Difficulty: \t[H]ard \nDescription: \tRecommended for those who are looking for a challenge.\n");
             Console.WriteLine($"\t\tThe code is {tmpObject.GetCodeLength()} digits long.");
             Console.WriteLine($"\t\tYou have {tmpObject.GetMaxAttempts()} attempts.");
             Console.WriteLine($"\t\tDuplicates: {tmpObject.GetDuplicates()}");
-            Console.WriteLine(new string('=', 30));
+            Console.WriteLine(new string('=', 71));
             Console.WriteLine($"Press \"R\" to return to the main menu. \n");
 
             checkMenu = false;
diff --git a/MastermindGame.cs b/MastermindGame.cs
index ac5a161..c2e9a6a 100644
--- a/MastermindGame.cs
+++ b/MastermindGame.cs
@@ -341,7 +341,7 @@ namespace Game
         /// </summary>
         public void DisplayBoard()
         {
-            Console.WriteLine($"\n{new string('=', 30)}");
+            DisplayDecoration('=', true);
             Console.WriteLine($"Attempt number {currentAttempt}: ");
 
             int counter = 0;
@@ -354,20 +354,7 @@ namespace Game
                 counter++;
             }
 
-            switch (code_length)
-            {
-                case 4:
-                default:
-                    Console.WriteLine($"\n {new string('-', 30)}");
-                    break;
-                case 6:
-                    Console.WriteLine($"\n {new string('-', 34)}");
-                    break;
-                case 8:
-                    Console.WriteLine($"\n {new string('-', 38)}");
-                    break;
-
-            }
+            DisplayDecoration('-', true);
 
             // Shows hints
             Console.Write($"{"Recieved Hints:",-24}");
@@ -409,7 +396,24 @@ namespace Game
             // Shows how many attempts are left
             Console.WriteLine($"\nYou have {maxAttempt - currentAttempt} attempts left");
 
-            Console.WriteLine($"{new string('=', 30)} \n");
+            DisplayDecoration('=', false);
+        }
+
+        private void DisplayDecoration(char letter, bool newLine)
+        {
+            switch (code_length)
+            {
+                case 4:
+                default:
+                    Console.WriteLine((newLine == true) ? $"\n{new string(letter, 31)}" : $"{new string(letter, 31)}");
+                    break;
+                case 6:
+                    Console.WriteLine((newLine == true) ? $"\n{new string(letter, 35)}" : $"{new string(letter, 35)}");
+                    break;
+                case 8:
+                    Console.WriteLine((newLine == true) ? $"\n{new string(letter, 39)}" : $"{new string(letter, 39)}");
+                    break;
+            }
         }
 
         /// <summary>
@@ -505,17 +509,20 @@ namespace Game
 
                 // Reads and converts all the last attempts 
                 string line;
+                int[] input = new int[code_length];
                 while ((line = sr.ReadLine()) != null)
                 {
-                    int[] input = new int[code_length];
                     string[] parts = line.Split("-");
                     for (int i = 0; i < code_length; i++)
                     {
                         input[i] = Convert.ToInt32(parts[i]);
                     }
                     attempts[currentAttempt] = input;
+                    GetHint(input);
+                    currentAttempt++;
                 }
             }
+            DisplayBoard();
         }
 
         /// <summary>
-- 
GitLab