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() public Game()
{ {
bag = CreateTileBag(3); bag = CreateTileBag(1);
board = CreateBoard(); board = CreateBoard();
} }
@ -63,7 +63,7 @@ namespace QwirkleClassLibrary
public Board CreateBoard() public Board CreateBoard()
{ {
board = new Board(12, 12); board = new Board(5, 5);
return board; return board;
} }
@ -112,7 +112,7 @@ namespace QwirkleClassLibrary
{ {
for (int j = 0; j < 6; j++) 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]); p.AddTileToPlayer(bag.TilesBag[val]);
bag.RemoveTileInBag(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);
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) if (tile == null)
{ {
surroundingTiles.Remove(tile);
continue; continue;
} }
@ -234,9 +235,12 @@ namespace QwirkleClassLibrary
} }
} }
if(surroundingTiles.Count == 0) return false;
return true; return true;
} }
public bool IsGameOver() public bool IsGameOver()
{ {
return false; return false;

@ -70,14 +70,21 @@ static void AddTile(Game game)
int x = Convert.ToInt32(ReadLine()); int x = Convert.ToInt32(ReadLine());
Write("Enter the y of the cell : "); Write("Enter the y of the cell : ");
int y = Convert.ToInt32(ReadLine()); int y = Convert.ToInt32(ReadLine());
if (game.PlaceTile(game.GetPlayingPlayer(), tile, x, y) == true) if (game.IsMoveCorrect(tile, x, y, game.GetBoard()) == true)
{ {
WriteLine("ok ! your tile is placed"); if (game.PlaceTile(game.GetPlayingPlayer(), tile, x, y) == true)
{
WriteLine("ok ! your tile is placed");
}
else
{
WriteLine("ERROR : Cell already used");
}
} }
else else
{ {
WriteLine("ERROR : Cell already used"); WriteLine("ERROR : Move not correct");
} }
} }
@ -156,9 +163,9 @@ static void ShowBoard(Game game)
{ {
for(int y=0; y<board.Columns; y++) 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] + " |"); Console.Write("| " + tile.GetShape.ToString()[0] + tile.GetShape.ToString()[1] + tile.GetColor.ToString()[0] + " |");
} }
else else

Loading…
Cancel
Save