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.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
// ReSharper disable All
namespace QwirkleClassLibrary namespace QwirkleClassLibrary
{ {
@ -12,7 +13,6 @@ namespace QwirkleClassLibrary
public Board() public Board()
{ {
//Console.WriteLine("BOARD created !");
Cells = new List<Cell>(); Cells = new List<Cell>();
for (int i = 0; i < 12; i++) 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 (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 else
{ {
//Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile.");
return false; 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; return false;
} }
} }

@ -13,7 +13,6 @@ public class Cell
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
//Console.WriteLine("Cell (" + x + ", " + y + ") created");
} }
public int GetX public int GetX
@ -41,12 +40,10 @@ public class Cell
if(tile == null) if(tile == null)
{ {
tile = addedTile; 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; return true;
} }
else else
{ {
//Console.WriteLine("There already is a tile in this cell !!");
return false; return false;
} }
} }

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

@ -9,37 +9,35 @@ namespace QwirkleClassLibrary
public class Player public class Player
{ {
private string nameTag; private string nameTag;
private List<Tile> tiles; private List<Tile> playerTiles;
private bool isPlaying = false;
public Player(string name) public Player(string name)
{ {
nameTag = name; nameTag = name;
tiles = new List<Tile>(); Tiles = new List<Tile>();
} }
public string GetNameTag public string GetNameTag
{ {
get { return nameTag; } get { return nameTag; }
set { nameTag = value; }
} }
public bool IsPlaying public bool IsPlaying { get; set; } = false;
{
get { return isPlaying; }
set { isPlaying = value; }
}
public void AddTilePlayer(Tile tile) public void AddTilePlayer(Tile tile)
{ {
tiles.Add(tile); Tiles.Add(tile);
} }
public bool RemoveTilePlayer(Tile 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,14 +9,11 @@ namespace QwirkleClassLibrary
{ {
public class TileBag public class TileBag
{ {
public ReadOnlyMemory<Tile> Tiles { get ; private set; } public ReadOnlyCollection<Tile> Tiles { get ; private set; }
private List<Tile> tiles = new List<Tile>(); private readonly List<Tile> tiles = new List<Tile>();
public TileBag(int nbSet) public TileBag(int nbSet)
{ {
tiles = new List<Tile>();
for (int i = 0; i < nbSet; i++) for (int i = 0; i < nbSet; i++)
{ {
foreach (Shape s in Enum.GetValues(typeof(Shape))) foreach (Shape s in Enum.GetValues(typeof(Shape)))
@ -26,9 +24,7 @@ namespace QwirkleClassLibrary
tiles.Add(t); tiles.Add(t);
} }
} }
} }
} }
public void RemoveTileInBag(Tile tile) public void RemoveTileInBag(Tile tile)

Loading…
Cancel
Save