show + add tile fix

test_old_branch
Jérémy Mouyon 1 year ago
parent c55070be58
commit d4d6b59995

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -18,7 +19,7 @@ namespace QwirkleClassLibrary
{ {
for (int j = 0; j < 12; j++) for (int j = 0; j < 12; j++)
{ {
var localcell = new Cell(i, j); Cell localcell = new(i, j);
Cells.Add(localcell); Cells.Add(localcell);
} }
} }
@ -30,7 +31,11 @@ namespace QwirkleClassLibrary
{ {
if (this.Cells[i].GetX == x && this.Cells[i].GetY == y) if (this.Cells[i].GetX == x && this.Cells[i].GetY == y)
{ {
return Cells[i].IsFree == false && Cells[i].SetTile(tile); if (Cells[i].IsFree == true)
{
return Cells[i].SetTile(tile);
}
} }
} }
return false; return false;

@ -42,7 +42,7 @@ public class Cell
public bool SetTile(Tile addedTile) public bool SetTile(Tile addedTile)
{ {
if(tile == null) if(this.tile == null)
{ {
tile = addedTile; tile = addedTile;
return true; return true;

@ -60,6 +60,7 @@ static void ShowTiles(Game game)
for (int i = 0; i < game.PlayerList[pos].Tiles.Count(); i++) for (int i = 0; i < game.PlayerList[pos].Tiles.Count(); i++)
{ {
stringBuilder.Append("[" + (i+1) + "] ");
stringBuilder.AppendLine(game.PlayerList[pos].Tiles[i].ToString()); stringBuilder.AppendLine(game.PlayerList[pos].Tiles[i].ToString());
} }
@ -107,7 +108,7 @@ static void CaseOneAddTile(Game game)
if (no >= 0 && no <= 5) if (no >= 0 && no <= 5)
{ {
tile = game.TileOfPlayerWithPos(no); tile = game.TileOfPlayerWithPos(no+1);
Write("Enter x : "); Write("Enter x : ");
int x = Convert.ToInt32(ReadLine()); int x = Convert.ToInt32(ReadLine());
Write("Enter y : "); Write("Enter y : ");

Loading…
Cancel
Save