Added some rules for the moves
continuous-integration/drone/push Build is passing Details

test_old_branch
Jules LASCRET 12 months ago
parent bca09032f9
commit 69d6d2f9d3

@ -23,7 +23,7 @@ namespace QwirkleClassLibrary
public Game()
{
bag = CreateTileBag(3);
bag = CreateTileBag(1);
board = CreateBoard();
}
@ -63,7 +63,7 @@ namespace QwirkleClassLibrary
public Board CreateBoard()
{
board = new Board(12, 12);
board = new Board(5, 5);
return board;
}
@ -112,7 +112,7 @@ namespace QwirkleClassLibrary
{
for (int j = 0; j < 6; j++)
{
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count + 1);
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count);
p.AddTileToPlayer(bag.TilesBag[val]);
bag.RemoveTileInBag(bag.TilesBag[val]);
@ -221,10 +221,11 @@ namespace QwirkleClassLibrary
surroundingTiles.Add(b.GetCell(x, y + 1)?.GetTile);
surroundingTiles.Add(b.GetCell(x, y - 1)?.GetTile);
foreach (var tile in surroundingTiles)
foreach (var tile in surroundingTiles.ToList())
{
if (tile == null)
{
surroundingTiles.Remove(tile);
continue;
}
@ -234,9 +235,12 @@ namespace QwirkleClassLibrary
}
}
if(surroundingTiles.Count == 0) return false;
return true;
}
public bool IsGameOver()
{
return false;

@ -71,6 +71,8 @@ static void AddTile(Game game)
Write("Enter the y of the cell : ");
int y = Convert.ToInt32(ReadLine());
if (game.IsMoveCorrect(tile, x, y, game.GetBoard()) == true)
{
if (game.PlaceTile(game.GetPlayingPlayer(), tile, x, y) == true)
{
WriteLine("ok ! your tile is placed");
@ -79,6 +81,11 @@ static void AddTile(Game game)
{
WriteLine("ERROR : Cell already used");
}
}
else
{
WriteLine("ERROR : Move not correct");
}
}
static void SwapTile(Game game)
@ -156,9 +163,9 @@ static void ShowBoard(Game game)
{
for(int y=0; y<board.Columns; y++)
{
if(board.GetCell(i, y).IsFree == false)
if(board.GetCell(i, y)!.IsFree == false)
{
Tile tile = board.GetCell(i, y).GetTile;
Tile? tile = board.GetCell(i, y)?.GetTile;
Console.Write("| " + tile.GetShape.ToString()[0] + tile.GetShape.ToString()[1] + tile.GetColor.ToString()[0] + " |");
}
else

Loading…
Cancel
Save