From 772a0b0fb8398605ea6793128a1dcde9db89fbfa Mon Sep 17 00:00:00 2001
From: steinti100434 <wurcax-xuvvo7-dadwAk>
Date: Mon, 16 Dec 2024 12:03:04 +0100
Subject: [PATCH] Editedt Leaderboard

---
 MastermindController.cs | 10 +++++-----
 MastermindGame.cs       |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/MastermindController.cs b/MastermindController.cs
index dd6630a..026c2d1 100644
--- a/MastermindController.cs
+++ b/MastermindController.cs
@@ -539,7 +539,7 @@ namespace Controller
                         if (File.Exists(LeaderboardPath))   //checks if file exists
                         {
                             StreamWriter sw = File.AppendText(LeaderboardPath); //initialises new instance of a StreamWriter
-                            sw.WriteLine($"{game.GetUsedAtt()};{string.Join("-", game.GetCode())};{username}");//write attempt in Leaderboard file with syntax : UsedAttempts; Code of the Attempt; Name of the player
+                            sw.WriteLine($"{game.GetUsedAtt()};{string.Join("-", game.GetCode())};{username};{gamemode}");//write attempt in Leaderboard file with syntax : UsedAttempts; Code of the Attempt; Name of the player
                             sw.Close(); //closes StreamWriter instance
                             StreamReader sr = new StreamReader(LeaderboardPath);//initialises new instance of a StreamReader
                             string[] lines = sr.ReadToEnd().Split("\r\n"); //write contents of File into string array where "new lines" are used as separators --> last element of array is "empty"
@@ -579,7 +579,7 @@ namespace Controller
                         else
                         {
                             StreamWriter sw = new StreamWriter(LeaderboardPath);
-                            sw.WriteLine($"{game.GetUsedAtt()};{string.Join("-", game.GetCode())};{username}"); //write attempt in Leaderboard file with syntax : UsedAttempts; Code of the Attempt; Name of the player
+                            sw.WriteLine($"{game.GetUsedAtt()};{string.Join("-", game.GetCode())};{username};{gamemode}"); //write attempt in Leaderboard file with syntax : UsedAttempts; Code of the Attempt; Name of the player
                             sw.Close();
                         }
                         Console.WriteLine("The Game was succesfully saved to the Leaderboard");
@@ -628,8 +628,8 @@ namespace Controller
             Console.WriteLine("██║     ██╔══╝  ██╔══██║██║  ██║██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██║██╔══██╗██║  ██║║");
             Console.WriteLine("███████╗███████╗██║  ██║██████╔╝███████╗██║  ██║██████╔╝╚██████╔╝██║  ██║██║  ██║██████╔╝");
             Console.WriteLine("╚══════╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚══════╝╚═╝  ╚═╝╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝");
-            Console.WriteLine($"\n|{PadCenter("Username", 30, ' ')}|{PadCenter("Tries Left", 30, ' ')}|{PadCenter("Code", 30, ' ')}");
-            Console.WriteLine($"|{PadCenter("-", 30, '-')}|{PadCenter("-", 30, '-')}|{PadCenter("-", 30, '-')}");
+            Console.WriteLine($"\n|{PadCenter("Username", 30, ' ')}|{PadCenter("Tries Left", 30, ' ')}|{PadCenter("Code", 30, ' ')}|{PadCenter("Gamemode", 30, ' ')}");
+            Console.WriteLine($"|{PadCenter("-", 30, '-')}|{PadCenter("-", 30, '-')}|{PadCenter("-", 30, '-')}|{PadCenter("-", 30, '-')}");
 
             if (File.Exists(LeaderboardPath) == false) //checks if file exists
             {
@@ -642,7 +642,7 @@ namespace Controller
                 for (int i = 0; i < allLines.Length - 1; i++)       //Prints array to properly display data 
                 {
                     string[] line = allLines[i].Split(';');
-                    Console.WriteLine($"|{PadCenter(line[2], 30, ' ')}|{PadCenter(line[0], 30, ' ')}|{PadCenter(line[1], 30, ' ')}");
+                    Console.WriteLine($"|{PadCenter(line[2], 30, ' ')}|{PadCenter(line[0], 30, ' ')}|{PadCenter(line[1], 30, ' ')}|{PadCenter(line[3], 30, ' ')}");
                 }
             }
 
diff --git a/MastermindGame.cs b/MastermindGame.cs
index ac5a161..8ecd8d2 100644
--- a/MastermindGame.cs
+++ b/MastermindGame.cs
@@ -341,6 +341,7 @@ namespace Game
         /// </summary>
         public void DisplayBoard()
         {
+            Console.WriteLine(code);
             Console.WriteLine($"\n{new string('=', 30)}");
             Console.WriteLine($"Attempt number {currentAttempt}: ");
 
-- 
GitLab