Merge remote-tracking branch 'origin/master'

# Conflicts:
#	Qwirkle/QwirkleClassLibrary/Game.cs
test_old_branch
Jules LASCRET 1 year ago
commit 629dc52eb1

@ -10,6 +10,8 @@ namespace QwirkleClassLibrary
public class Board
{
private List<Cell> Cells;
public IReadOnlyCollection<Cell> ReadCells { get; private set; }
ReadCells = Cells.AsReadOnly;
public Board()
{

@ -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<Player> PlayerList { get; private set; }
private readonly List<Player> players;
private readonly List<Player> players = new List<Player>();
public Game()
{
board = new Board();
bag = new TileBag(3);
players = new List<Player>();
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<Player> 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();
}
}

@ -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();
}
}

@ -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();
}
}
}
}

@ -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);
}
}
}
}
Loading…
Cancel
Save