@ -13,9 +13,9 @@ namespace QwirkleClassLibrary.Tiles
{
{
[DataMember]
[DataMember]
private readonly List < Tile > tiles = [ ] ;
private readonly List < Tile > tiles = [ ] ;
public ReadOnlyCollection < Tile > ? TilesBag { get ; private set ; }
public ReadOnlyCollection < Tile > ? TilesBag { get ; private set ; }
/// <summary>
/// <summary>
/// This is the constructor for the TileBag. It will create a tile of each of the possibilities among the Color and Shape Enums.
/// This is the constructor for the TileBag. It will create a tile of each of the possibilities among the Color and Shape Enums.
@ -24,29 +24,23 @@ namespace QwirkleClassLibrary.Tiles
/// <exception cref="ArgumentException">Throw an exception if the number of copies is negative (impossible) or superior to 3 (contradiction with the rules).</exception>
/// <exception cref="ArgumentException">Throw an exception if the number of copies is negative (impossible) or superior to 3 (contradiction with the rules).</exception>
public TileBag ( int nbSet )
public TileBag ( int nbSet )
{
{
/ * if ( nbSet < 0 | | nbSet > 3 )
if ( nbSet < 0 | | nbSet > 3 )
{
{
throw new ArgumentException ( nbSet . ToString ( ) ) ;
throw new ArgumentException ( nbSet . ToString ( ) ) ;
}
}
for ( int i = 0 ; i < nbSet ; i + + )
{
foreach ( Shape s in Enum . GetValues ( typeof ( Shape ) ) )
{
foreach ( Color c in Enum . GetValues ( typeof ( Color ) ) )
{
Tile t = new ( s , c ) ;
tiles . Add ( t ) ;
}
}
} * /
Tile t1 = new Tile ( Shape . Club , Color . Yellow ) ;
for ( int i = 0 ; i < nbSet ; i + + )
Tile t2 = new Tile ( Shape . Round , Color . Orange ) ;
{
foreach ( Shape s in Enum . GetValues ( typeof ( Shape ) ) )
{
foreach ( Color c in Enum . GetValues ( typeof ( Color ) ) )
{
Tile t = new ( s , c ) ;
tiles . Add ( t ) ;
}
}
}
tiles . Add ( t1 ) ;
tiles . Add ( t2 ) ;
Init ( ) ;
Init ( ) ;
}
}
@ -76,7 +70,7 @@ namespace QwirkleClassLibrary.Tiles
}
}
return false ;
return false ;
}
}
[OnDeserialized]
[OnDeserialized]
private void Init ( StreamingContext sc = new ( ) )
private void Init ( StreamingContext sc = new ( ) )
{
{