diff --git a/Qwirkle/QwirkleClassLibrary/Board.cs b/Qwirkle/QwirkleClassLibrary/Board.cs index b1c0f6a..eedc5bc 100644 --- a/Qwirkle/QwirkleClassLibrary/Board.cs +++ b/Qwirkle/QwirkleClassLibrary/Board.cs @@ -10,6 +10,8 @@ namespace QwirkleClassLibrary public class Board { private List Cells; + public IReadOnlyCollection ReadCells { get; private set; } + ReadCells = Cells.AsReadOnly; public Board() { diff --git a/Qwirkle/QwirkleClassLibrary/Game.cs b/Qwirkle/QwirkleClassLibrary/Game.cs index 57f4a5d..66dcb53 100644 --- a/Qwirkle/QwirkleClassLibrary/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Game.cs @@ -9,21 +9,21 @@ using System.Xml.Linq; namespace QwirkleClassLibrary { - public class Game : IPlayer + public class Game { private TileBag bag; private bool gameRunning; private Board board; public ReadOnlyCollection PlayerList { get; private set; } - private readonly List players; + private readonly List players = new List(); public Game() { board = new Board(); bag = new TileBag(3); - - players = new List(); + Console.Write(bag.TilesBag.Count); + gameRunning = false; PlayerList = players.AsReadOnly(); } @@ -43,7 +43,7 @@ namespace QwirkleClassLibrary for (int i = 0; i < players.Count; i++) { - if (players[i].NameTag == PlayerTag) + if (players[i].GetNameTag == PlayerTag) { return false; } @@ -55,12 +55,6 @@ namespace QwirkleClassLibrary return true; } - public Player CreatePlayer(string playerTag) - { - var player = new Player(playerTag); - return player; - } - public bool StartGame() { if (players.Count < 2) @@ -71,7 +65,8 @@ namespace QwirkleClassLibrary this.gameRunning = true; return true; } - + + public int GetPlayingPlayerPosition() { for (int i = 0; i < players.Count; i++) @@ -97,6 +92,7 @@ namespace QwirkleClassLibrary public void SetNextPlayer(int old, int neew) { + if (old >= 0 || old != -1) { players[old].IsPlaying = false; @@ -133,7 +129,7 @@ namespace QwirkleClassLibrary SetNextPlayer(posPlayerPlay, posPlayerNextPlay); - return (players[posPlayerNextPlay].NameTag); + return (players[posPlayerNextPlay].GetNameTag); } public bool GameRunning @@ -157,26 +153,6 @@ namespace QwirkleClassLibrary return false; } - public void SetNextPlayer(List playersList) - { - for(int i = 0; i < PlayerList.Count; i++) - { - if (PlayerList[i].IsPlaying != true) continue; - - PlayerList[i].IsPlaying = false; - PlayerList[(i + 1) % PlayerList.Count].IsPlaying = true; - } - } - - public void PlaceTile(Player player, Tile tile, int x, int y) - { - throw new NotImplementedException(); - } - - public bool ContinueToPlay() - { - throw new NotImplementedException(); - } } diff --git a/Qwirkle/QwirkleClassLibrary/IRules.cs b/Qwirkle/QwirkleClassLibrary/IRules.cs new file mode 100644 index 0000000..83180f4 --- /dev/null +++ b/Qwirkle/QwirkleClassLibrary/IRules.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace QwirkleClassLibrary +{ + public interface IRules + { + Board CreateBoard(); + bool isMoveCorrect(Tile t, Cell c); + bool isGameOver(); + + } +} diff --git a/Qwirkle/QwirkleClassLibrary/Tile.cs b/Qwirkle/QwirkleClassLibrary/Tile.cs index 4a65dfc..d57db8b 100644 --- a/Qwirkle/QwirkleClassLibrary/Tile.cs +++ b/Qwirkle/QwirkleClassLibrary/Tile.cs @@ -1,4 +1,5 @@ -using System; +using QwirkleClassLibrary; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -37,4 +38,4 @@ namespace QwirkleClassLibrary return shape.ToString() + color.ToString(); } } -} +} \ No newline at end of file diff --git a/Qwirkle/TestBase/TestTile.cs b/Qwirkle/TestBase/TestTile.cs new file mode 100644 index 0000000..29b3f30 --- /dev/null +++ b/Qwirkle/TestBase/TestTile.cs @@ -0,0 +1,56 @@ +using QwirkleClassLibrary; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TestBase +{ + internal class TestTile + { + public class TestCorrect // test with correct Shape and Color + { + [Fact] + public void TestCreateCorrect() + { + Tile t = new Tile(Shape.Star, Color.Blue); + Assert.NotNull(t); + Assert.Equal(Shape.Star, t.GetShape); + Assert.Equal(Color.Blue, t.GetColor); + } + // Modifier plus tard avec [Theory] à la place de [Fact] pour tester avec toutes les Shape et Color possibles (voir vidéo) + } + + public class TestWrongColor // test with correct Shape but wrong Color + { + [Fact] + public void TestCreateWrongColor() + { + Tile t = new Tile(Shape.Rhombus, Color.Rainbow); + Assert.Fail(t); + } + } + public class TestWrongShape // test with wrong Shape but correct Color + { + [Fact] + public void TestCreateWrongShape() + { + bool result = new Tile(Shape.Hexagon, Color.Green); + Assert.False(result); + } + } + + public class TestWrongShapeWrongColor // test with wrong Sape and wrong Color + { + [Fact] + public void TestCreateWrongShapeWrongColor() + { + bool result = new Tile(Shape.Triangle, Color.Grey); + Assert.False(result); + } + } + + } +} +