|
|
|
@ -9,7 +9,7 @@ using System.Security.Cryptography;
|
|
|
|
|
|
|
|
|
|
namespace QwirkleClassLibrary
|
|
|
|
|
{
|
|
|
|
|
public class Game : IPlayer
|
|
|
|
|
public class Game : IPlayer, IRules
|
|
|
|
|
{
|
|
|
|
|
private TileBag bag;
|
|
|
|
|
public bool GameRunning { get; private set; }
|
|
|
|
@ -20,8 +20,8 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
public Game()
|
|
|
|
|
{
|
|
|
|
|
board = new Board();
|
|
|
|
|
bag = new TileBag(3);
|
|
|
|
|
board = CreateBoard();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AddPlayerInGame(string? playerTag)
|
|
|
|
@ -55,6 +55,12 @@ namespace QwirkleClassLibrary
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Board CreateBoard()
|
|
|
|
|
{
|
|
|
|
|
board = new Board();
|
|
|
|
|
return board;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StartGame()
|
|
|
|
|
{
|
|
|
|
|
this.GameRunning = true;
|
|
|
|
@ -88,7 +94,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < 6; j++)
|
|
|
|
|
{
|
|
|
|
|
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count);
|
|
|
|
|
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count + 1);
|
|
|
|
|
|
|
|
|
|
p.AddTileToPlayer(bag.TilesBag[val]);
|
|
|
|
|
bag.RemoveTileInBag(bag.TilesBag[val]);
|
|
|
|
@ -138,7 +144,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count);
|
|
|
|
|
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count + 1);
|
|
|
|
|
|
|
|
|
|
player.AddTileToPlayer(bag.TilesBag[val]);
|
|
|
|
|
bag.RemoveTileInBag(bag.TilesBag[val]);
|
|
|
|
@ -146,10 +152,43 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SwapTiles(Player player)
|
|
|
|
|
|
|
|
|
|
public bool SwapTiles(Player player, List<Tile> tilesToSwap)
|
|
|
|
|
{
|
|
|
|
|
if (tilesToSwap.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var t in tilesToSwap)
|
|
|
|
|
{
|
|
|
|
|
if (player.RemoveTileToPlayer(t) == false)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DrawTiles(player) == false)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var t in tilesToSwap)
|
|
|
|
|
{
|
|
|
|
|
bag.AddTileInBag(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsMoveCorrect(Tile t, Board b)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsGameOver()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|