From fb6773e40a99c4687fcfd94d0c6d79d4201af078 Mon Sep 17 00:00:00 2001 From: "jeremy.mouyon" Date: Thu, 16 May 2024 14:25:48 +0200 Subject: [PATCH] push now push npow --- Qwirkle/QwirkleClassLibrary/Game.cs | 8 ++++---- Qwirkle/QwirkleConsoleApp/Program.cs | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index 97813b2..eae2e62 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -13,7 +13,8 @@ namespace QwirkleClassLibrary public class Game : IPlayer, IRules { - private Dictionary scoreBoard = new(); + public ReadOnlyDictionary ScoreBoard => scoreBoard.AsReadOnly(); + private readonly Dictionary scoreBoard = new(); private TileBag bag; public bool GameRunning { get; private set; } @@ -78,7 +79,6 @@ namespace QwirkleClassLibrary } players.Add(CreatePlayer(playerTag)); - //scores.Add(new Score(players[players.Count-1])); OnPlayerNotified(new AddPlayerNotifiedEventArgs("Player was correctly added")); return true; } @@ -125,7 +125,7 @@ namespace QwirkleClassLibrary { if(GetPlayingPlayerPosition() == -1) { - throw new ArgumentException(); + throw new ArgumentException("No player play."); } return players[GetPlayingPlayerPosition()]; } @@ -166,7 +166,7 @@ namespace QwirkleClassLibrary if (GameRunning) { players[0].IsPlaying = true; - //OnNextPlayer(new NextPlayerNotifiedEventArgs(players[0])); + OnNextPlayer(new NextPlayerNotifiedEventArgs(players[0])); return players[0].NameTag; } else diff --git a/Qwirkle/QwirkleConsoleApp/Program.cs b/Qwirkle/QwirkleConsoleApp/Program.cs index 25511dd..3430e5e 100644 --- a/Qwirkle/QwirkleConsoleApp/Program.cs +++ b/Qwirkle/QwirkleConsoleApp/Program.cs @@ -204,11 +204,11 @@ static void MainMenu(Game game) WriteLine("Game is starting !"); Console.ResetColor(); - NotificationClass nc = new NotificationClass(); - game.NextPlayerNotified += nc.NotificationNextPlayer; - do { + NotificationClass nc = new NotificationClass(); + game.NextPlayerNotified += nc.NotificationNextPlayer; + game.SetNextPlayer(); WriteLine(" --------------------- GAME ! ------------------------"); @@ -216,6 +216,8 @@ static void MainMenu(Game game) game.DrawTiles(game.GetPlayingPlayer()); MenuSwitch(game); + game.NextPlayerNotified -= nc.NotificationNextPlayer; + } while (game.IsGameOver()); }