From 342de5ce08a67b4056f50d307f1a286e64ae3928 Mon Sep 17 00:00:00 2001 From: "jeremy.mouyon" Date: Sun, 7 Apr 2024 16:02:43 +0200 Subject: [PATCH] switch nextplayer to method --- Qwirkle/QwirkleClassLibrary/Game.cs | 14 ++++++++++++++ Qwirkle/QwirkleConsoleApp/Program.cs | 24 ++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index ebd470d..2575d90 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -80,6 +80,20 @@ namespace QwirkleClassLibrary } } + public void NextPlayer() + { + int posPlayerPlay = PositionPlayerPlay(); + + int posPlayerNextPlay = PositionPlayerPlay() + 1; + + if (posPlayerNextPlay >= GetNbPlayers) + { + posPlayerNextPlay = 0; + } + + SetNextPlayer(posPlayerPlay, posPlayerNextPlay); + } + } diff --git a/Qwirkle/QwirkleConsoleApp/Program.cs b/Qwirkle/QwirkleConsoleApp/Program.cs index 139ad3f..0b39762 100644 --- a/Qwirkle/QwirkleConsoleApp/Program.cs +++ b/Qwirkle/QwirkleConsoleApp/Program.cs @@ -55,32 +55,16 @@ static Game InitializerGame() return new Game(Players); } -static void NextPlayer(Game game) -{ - int posPlayerPlay = game.PositionPlayerPlay(); - - int posPlayerNextPlay = game.PositionPlayerPlay() + 1; - - if (posPlayerNextPlay >= game.GetNbPlayers) - { - posPlayerNextPlay = 0; - } - - game.SetNextPlayer(posPlayerPlay, posPlayerNextPlay); -} - - - static void testJeremy() { Game game = InitializerGame(); Write("\n -------------------------------------------------------- \n"); - NextPlayer(game); - NextPlayer(game); - NextPlayer(game); - NextPlayer(game); + game.NextPlayer(); + game.NextPlayer(); + game.NextPlayer(); + game.NextPlayer(); game.TilsBagPlayer();