|
|
@ -11,7 +11,7 @@ namespace QwirkleClassLibrary
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class Game : IPlayer, IRules
|
|
|
|
public class Game : IPlayer, IRules
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly TileBag bag;
|
|
|
|
private TileBag bag;
|
|
|
|
public bool GameRunning { get; private set; }
|
|
|
|
public bool GameRunning { get; private set; }
|
|
|
|
private Board board;
|
|
|
|
private Board board;
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +23,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
|
|
public Game()
|
|
|
|
public Game()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bag = new TileBag(3);
|
|
|
|
bag = CreateTileBag(3);
|
|
|
|
board = CreateBoard();
|
|
|
|
board = CreateBoard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -61,19 +61,22 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
|
|
public Board CreateBoard()
|
|
|
|
public Board CreateBoard()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
board = new Board();
|
|
|
|
board = new Board(12, 12);
|
|
|
|
return board;
|
|
|
|
return board;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool StartGame()
|
|
|
|
public TileBag CreateTileBag(int nbSet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(players.Count>= 2 && players.Count < 5)
|
|
|
|
bag = new TileBag(nbSet);
|
|
|
|
|
|
|
|
return bag;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool StartGame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (players.Count < 2 || players.Count >= 5) return false;
|
|
|
|
this.GameRunning = true;
|
|
|
|
this.GameRunning = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Player GetPlayingPlayer()
|
|
|
|
public Player GetPlayingPlayer()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -202,14 +205,39 @@ namespace QwirkleClassLibrary
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsMoveCorrect(Tile t, Board b)
|
|
|
|
public bool IsMoveCorrect(Tile t, int x, int y, Board b)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (b.HasOccupiedCase() == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var surroundingTiles = new List<Tile?>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x + 1, y)?.GetTile);
|
|
|
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x - 1, y)?.GetTile);
|
|
|
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x, y + 1)?.GetTile);
|
|
|
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x, y - 1)?.GetTile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var tile in surroundingTiles)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (tile == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tile.GetColor != t.GetColor && tile.GetShape != t.GetShape)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsGameOver()
|
|
|
|
public bool IsGameOver()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|