diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index 611f949..ebd470d 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -15,7 +15,7 @@ namespace QwirkleClassLibrary public Game(List pl) { players = pl; - bag = new TileBag(); + bag = new TileBag(3); players[0].IsPlaying = true; } @@ -26,7 +26,6 @@ namespace QwirkleClassLibrary { if (players[i].IsPlaying == true) { - Console.WriteLine(i); return i; } } @@ -38,21 +37,11 @@ namespace QwirkleClassLibrary get { return players.Count; } } - public void RemoveTileInBagGame(Tile tile) - { - bag.RemoveTileInBag(tile); - } - public List Bag { get { return bag.TilesInBag(); } } - public void AddTileInBagOfPlayer(int posplayer, Tile tile) - { - players[posplayer].AddTilePlayer(tile); - } - public void ShowTileOfPlayer(int posplayer) { List tiles = players[posplayer].Tiles; @@ -74,8 +63,21 @@ namespace QwirkleClassLibrary players[old].IsPlaying = false; } players[neew].IsPlaying = true; - Console.WriteLine(players[neew].GetNameTag + "you have main now !"); + Console.WriteLine(players[neew].GetNameTag + " you have main now !"); + + } + public void TilsBagPlayer() + { + for (int i = 0; i < players.Count; i++) + { + for (int j = 0; j < 6; j++) + { + Tile tile = Bag[j]; + players[i].AddTilePlayer(tile); + bag.RemoveTileInBag(tile); + } + } } } diff --git a/Qwirkle/QwirkleClassLibrary/TileBag.cs b/Qwirkle/QwirkleClassLibrary/TileBag.cs index 16405ce..d8d3511 100644 --- a/Qwirkle/QwirkleClassLibrary/TileBag.cs +++ b/Qwirkle/QwirkleClassLibrary/TileBag.cs @@ -11,12 +11,12 @@ namespace QwirkleClassLibrary private int nbtiles; private List tiles; - public TileBag() + public TileBag(int nbSet) { tiles = new List(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < nbSet; i++) { foreach (Shape s in Enum.GetValues(typeof(Shape))) { diff --git a/Qwirkle/QwirkleConsoleApp/Program.cs b/Qwirkle/QwirkleConsoleApp/Program.cs index ff3efad..139ad3f 100644 --- a/Qwirkle/QwirkleConsoleApp/Program.cs +++ b/Qwirkle/QwirkleConsoleApp/Program.cs @@ -4,6 +4,7 @@ using static System.Console; static Game InitializerGame() { OutputEncoding = System.Text.Encoding.UTF8; + List Players = new List(); WriteLine("Enter number of player play : "); @@ -23,7 +24,7 @@ static Game InitializerGame() { WriteLine("Enter name of player " + (i + 1) + " : \n"); - String name = ReadLine(); + String? name = ReadLine(); bool nameInvalid = string.IsNullOrWhiteSpace(name); @@ -68,21 +69,7 @@ static void NextPlayer(Game game) game.SetNextPlayer(posPlayerPlay, posPlayerNextPlay); } -static void TilsBagPlayer(Game game) -{ - List listTile = game.Bag; - for (int i = 0; i < game.GetNbPlayers; i++) - { - for (int j = 0; j < 6; j++) - { - Tile tile = listTile[j]; - game.AddTileInBagOfPlayer(i, tile); - game.RemoveTileInBagGame(tile); - } - } - -} static void testJeremy() @@ -95,7 +82,7 @@ static void testJeremy() NextPlayer(game); NextPlayer(game); - TilsBagPlayer(game); + game.TilsBagPlayer(); for (int i = 0; i < game.GetNbPlayers; i++) {