Slight modification kinda useless though

test_old_branch
Jules LASCRET 1 year ago
parent 8c609e7ad0
commit de63fd17b6

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable All
namespace QwirkleClassLibrary
{
@ -12,7 +13,6 @@ namespace QwirkleClassLibrary
public Board()
{
//Console.WriteLine("BOARD created !");
Cells = new List<Cell>();
for (int i = 0; i < 12; i++)
@ -31,19 +31,17 @@ namespace QwirkleClassLibrary
{
if (this.Cells[i].GetX == x && this.Cells[i].GetY == y)
{
if (Cells[i].SetTile(tile) == true)
if (Cells[i].IsFree == false)
{
return true;
return Cells[i].SetTile(tile);
}
else
{
//Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile.");
return false;
}
}
}
//Console.WriteLine("The cell you're searching for doesn't exist. PLease enter new coordinates for the cell where you want to place your tile.");
return false;
}
}

@ -13,7 +13,6 @@ public class Cell
{
this.x = x;
this.y = y;
//Console.WriteLine("Cell (" + x + ", " + y + ") created");
}
public int GetX
@ -41,12 +40,10 @@ public class Cell
if(tile == null)
{
tile = addedTile;
//Console.WriteLine("The tile of shape " + addedTile.GetShape + " and color " + addedTile.GetColor + " has correctly been added to the cell of coordinates x = " + this.x + ", y = " + this.y);
return true;
}
else
{
//Console.WriteLine("There already is a tile in this cell !!");
return false;
}
}

@ -12,15 +12,13 @@ namespace QwirkleClassLibrary
private TileBag bag;
private List<Player> players;
public Game(List<Player> pl)
public Game(List<Player> players)
{
players = pl;
this.players = players;
bag = new TileBag(3);
players[0].IsPlaying = true;
}
public int PositionPlayerPlay()
public int GetPlayingPlayerPosition()
{
for (int i = 0; i < players.Count; i++)
{
@ -37,7 +35,7 @@ namespace QwirkleClassLibrary
get { return players.Count; }
}
public List<Tile> Bag
public List<Tile> ListTilesBag
{
get { return bag.TilesInBag(); }
}
@ -73,7 +71,7 @@ namespace QwirkleClassLibrary
{
for (int j = 0; j < 6; j++)
{
Tile tile = Bag[j];
Tile tile = ListTilesBag[j];
players[i].AddTilePlayer(tile);
bag.RemoveTileInBag(tile);
}
@ -82,9 +80,9 @@ namespace QwirkleClassLibrary
public string NextPlayer()
{
int posPlayerPlay = PositionPlayerPlay();
int posPlayerPlay = GetPlayingPlayerPosition();
int posPlayerNextPlay = PositionPlayerPlay() + 1;
int posPlayerNextPlay = GetPlayingPlayerPosition() + 1;
if (posPlayerNextPlay >= GetNbPlayers)
{

@ -9,37 +9,35 @@ namespace QwirkleClassLibrary
public class Player
{
private string nameTag;
private List<Tile> tiles;
private bool isPlaying = false;
private List<Tile> playerTiles;
public Player(string name)
{
nameTag = name;
tiles = new List<Tile>();
Tiles = new List<Tile>();
}
public string GetNameTag
{
get { return nameTag; }
set { nameTag = value; }
}
public bool IsPlaying
{
get { return isPlaying; }
set { isPlaying = value; }
}
public bool IsPlaying { get; set; } = false;
public void AddTilePlayer(Tile tile)
{
tiles.Add(tile);
Tiles.Add(tile);
}
public bool RemoveTilePlayer(Tile tile)
{
return tiles.Remove(tile);
return Tiles.Remove(tile);
}
public List<Tile> Tiles // Rajouter un "get" là
public List<Tile> Tiles
{
get{ return tiles; }
get;
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,14 +9,11 @@ namespace QwirkleClassLibrary
{
public class TileBag
{
public ReadOnlyMemory<Tile> Tiles { get ; private set; }
private List<Tile> tiles = new List<Tile>();
public ReadOnlyCollection<Tile> Tiles { get ; private set; }
private readonly List<Tile> tiles = new List<Tile>();
public TileBag(int nbSet)
{
tiles = new List<Tile>();
for (int i = 0; i < nbSet; i++)
{
foreach (Shape s in Enum.GetValues(typeof(Shape)))
@ -26,9 +24,7 @@ namespace QwirkleClassLibrary
tiles.Add(t);
}
}
}
}
public void RemoveTileInBag(Tile tile)

Loading…
Cancel
Save