diff --git a/Qwirkle/Qwirkle.sln b/Qwirkle/Qwirkle.sln index 63d5103..18d07fd 100644 --- a/Qwirkle/Qwirkle.sln +++ b/Qwirkle/Qwirkle.sln @@ -5,9 +5,11 @@ VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qwirkle", "Qwirkle\Qwirkle.csproj", "{DCE2FAE9-9A3A-452E-AFB1-BE3DC5E62BDF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QwirkleClassLibrary", "QwirkleClassLibrary\QwirkleClassLibrary.csproj", "{75739BB2-4DF5-4282-A7AF-0092E69DBDEC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QwirkleClassLibrary", "QwirkleClassLibrary\QwirkleClassLibrary.csproj", "{75739BB2-4DF5-4282-A7AF-0092E69DBDEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QwirkleConsoleApp", "QwirkleConsoleApp\QwirkleConsoleApp.csproj", "{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QwirkleConsoleApp", "QwirkleConsoleApp\QwirkleConsoleApp.csproj", "{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestBase", "TestBase\TestBase.csproj", "{34BF84AE-E69C-497E-AF88-390E70C4D568}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,6 +31,10 @@ Global {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.ActiveCfg = Release|Any CPU {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.Build.0 = Release|Any CPU + {34BF84AE-E69C-497E-AF88-390E70C4D568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34BF84AE-E69C-497E-AF88-390E70C4D568}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34BF84AE-E69C-497E-AF88-390E70C4D568}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34BF84AE-E69C-497E-AF88-390E70C4D568}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Qwirkle/QwirkleClassLibrary/Board.cs b/Qwirkle/QwirkleClassLibrary/Board.cs index 7f335e7..73a7023 100644 --- a/Qwirkle/QwirkleClassLibrary/Board.cs +++ b/Qwirkle/QwirkleClassLibrary/Board.cs @@ -12,7 +12,7 @@ namespace QwirkleClassLibrary public Board() { - Console.WriteLine("BOARD created !"); + //Console.WriteLine("BOARD created !"); Cells = new List(); for (int i = 0; i < 12; i++) @@ -37,13 +37,13 @@ namespace QwirkleClassLibrary } else { - Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile."); + //Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile."); return false; } } } - Console.WriteLine("The cell you're searching for doesn't exist. PLease enter new coordinates for the cell where you want to place your tile."); + //Console.WriteLine("The cell you're searching for doesn't exist. PLease enter new coordinates for the cell where you want to place your tile."); return false; } } diff --git a/Qwirkle/QwirkleClassLibrary/Cell.cs b/Qwirkle/QwirkleClassLibrary/Cell.cs index 9769743..00d3792 100644 --- a/Qwirkle/QwirkleClassLibrary/Cell.cs +++ b/Qwirkle/QwirkleClassLibrary/Cell.cs @@ -13,7 +13,7 @@ public class Cell { this.x = x; this.y = y; - Console.WriteLine("Cell (" + x + ", " + y + ") created"); + //Console.WriteLine("Cell (" + x + ", " + y + ") created"); } public int GetX @@ -41,12 +41,12 @@ public class Cell if(tile == null) { tile = addedTile; - Console.WriteLine("The tile of shape " + addedTile.GetShape + " and color " + addedTile.GetColor + " has correctly been added to the cell of coordinates x = " + this.x + ", y = " + this.y); + //Console.WriteLine("The tile of shape " + addedTile.GetShape + " and color " + addedTile.GetColor + " has correctly been added to the cell of coordinates x = " + this.x + ", y = " + this.y); return true; } else { - Console.WriteLine("There already is a tile in this cell !!"); + //Console.WriteLine("There already is a tile in this cell !!"); return false; } } diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index c133e31..d1e0b6f 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -42,7 +42,7 @@ namespace QwirkleClassLibrary get { return bag.TilesInBag(); } } - public void ShowTileOfPlayer(int posplayer) + public string ShowTileOfPlayer(int posplayer) { List tiles = players[posplayer].Tiles; @@ -52,7 +52,7 @@ namespace QwirkleClassLibrary { r = (r + " " + tile.NameColorTile()); } - Console.WriteLine(r); + return r; } @@ -63,7 +63,7 @@ namespace QwirkleClassLibrary players[old].IsPlaying = false; } players[neew].IsPlaying = true; - Console.WriteLine(players[neew].GetNameTag + " you have main now !"); + } @@ -80,7 +80,7 @@ namespace QwirkleClassLibrary } } - public void NextPlayer() + public string NextPlayer() { int posPlayerPlay = PositionPlayerPlay(); @@ -92,6 +92,8 @@ namespace QwirkleClassLibrary } SetNextPlayer(posPlayerPlay, posPlayerNextPlay); + + return (players[posPlayerNextPlay].GetNameTag); } } diff --git a/Qwirkle/QwirkleClassLibrary/Player.cs b/Qwirkle/QwirkleClassLibrary/Player.cs index 68b2304..0dbcb32 100644 --- a/Qwirkle/QwirkleClassLibrary/Player.cs +++ b/Qwirkle/QwirkleClassLibrary/Player.cs @@ -11,24 +11,12 @@ namespace QwirkleClassLibrary private string nameTag; private List tiles; private bool isPlaying = false; - private Score s; // Les gars, on nous a demandé de ne pas ça, réfléchissez public Player(string name) { nameTag = name; tiles = new List(); - s = new Score(this); - Console.WriteLine("Player created. Name : " + nameTag + "\n"); } - - public Player() // À enlever c'est pas logique - { - nameTag = "Unknow"; - tiles = new List(); - s = new Score(this); - Console.WriteLine("Player created. Name : " + nameTag + "\n"); - } - public string GetNameTag { get { return nameTag; } @@ -37,15 +25,15 @@ namespace QwirkleClassLibrary public bool IsPlaying { get { return isPlaying; } - set { isPlaying = value; } // pour vulgariser, le C# prends la value qui sert d'égalité !! + set { isPlaying = value; } } public void AddTilePlayer(Tile tile) { tiles.Add(tile); } - public void RemoveTilePlayer(Tile tile) + public bool RemoveTilePlayer(Tile tile) { - tiles.Remove(tile); + return tiles.Remove(tile); } public List Tiles // Rajouter un "get" là diff --git a/Qwirkle/QwirkleClassLibrary/Tile.cs b/Qwirkle/QwirkleClassLibrary/Tile.cs index 0e77538..a2510a0 100644 --- a/Qwirkle/QwirkleClassLibrary/Tile.cs +++ b/Qwirkle/QwirkleClassLibrary/Tile.cs @@ -15,7 +15,7 @@ namespace QwirkleClassLibrary { shape = sh; color = co; - Console.WriteLine("A tile of shape " + shape + " and color " + color + " has been created."); + //Console.WriteLine("A tile of shape " + shape + " and color " + color + " has been created."); } public string NameColorTile() diff --git a/Qwirkle/QwirkleClassLibrary/TileBag.cs b/Qwirkle/QwirkleClassLibrary/TileBag.cs index d8d3511..e24c004 100644 --- a/Qwirkle/QwirkleClassLibrary/TileBag.cs +++ b/Qwirkle/QwirkleClassLibrary/TileBag.cs @@ -8,8 +8,8 @@ namespace QwirkleClassLibrary { public class TileBag { - private int nbtiles; - private List tiles; + public ReadOnlyMemory Tiles { get ; private set; } + private List tiles = new List(); public TileBag(int nbSet) { @@ -29,7 +29,6 @@ namespace QwirkleClassLibrary } - } public void RemoveTileInBag(Tile tile) @@ -39,7 +38,6 @@ namespace QwirkleClassLibrary if (tiles[i] == tile) { tiles.RemoveAt(i); - nbtiles--; } } } diff --git a/Qwirkle/QwirkleConsoleApp/Program.cs b/Qwirkle/QwirkleConsoleApp/Program.cs index 0b39762..b96145e 100644 --- a/Qwirkle/QwirkleConsoleApp/Program.cs +++ b/Qwirkle/QwirkleConsoleApp/Program.cs @@ -61,10 +61,15 @@ static void testJeremy() Game game = InitializerGame(); Write("\n -------------------------------------------------------- \n"); - game.NextPlayer(); - game.NextPlayer(); - game.NextPlayer(); - game.NextPlayer(); + String TagPlayerPlay; + + TagPlayerPlay = game.NextPlayer(); + + Write(TagPlayerPlay + " you have main now !"); + + TagPlayerPlay = game.NextPlayer(); + + Write(TagPlayerPlay + " you have main now !"); game.TilsBagPlayer(); @@ -72,6 +77,7 @@ static void testJeremy() { game.ShowTileOfPlayer(i); } + } diff --git a/Qwirkle/TestBase/TestBase.csproj b/Qwirkle/TestBase/TestBase.csproj new file mode 100644 index 0000000..6443260 --- /dev/null +++ b/Qwirkle/TestBase/TestBase.csproj @@ -0,0 +1,27 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + + + + + diff --git a/Qwirkle/TestBase/UnitTest1.cs b/Qwirkle/TestBase/UnitTest1.cs new file mode 100644 index 0000000..b759b05 --- /dev/null +++ b/Qwirkle/TestBase/UnitTest1.cs @@ -0,0 +1,15 @@ +using QwirkleClassLibrary; + +namespace TestBase +{ + public class UnitTest1 + { + public void Test_PlayerRemoveTile(bool expectedResult) + { + Tile t = new Tile(Square, Red); + Player p = new Player("Patrick"); + bool result = p.RemoveTilePlayer(t); + Assert.True(result); + } + } +} \ No newline at end of file