diff --git a/Match3Maker/Match3Maker.csproj b/Match3Maker/Match3Maker.csproj index 1a27c07..3259619 100644 --- a/Match3Maker/Match3Maker.csproj +++ b/Match3Maker/Match3Maker.csproj @@ -14,7 +14,7 @@ Ninetailsrabbit.Match3Maker - 1.1.2 + 1.1.3 This lightweight library provides the core logic and functionality you need to build engaging match-3 games. Focus on game design and mechanics while leaving the complex logic to this library © 2024 Ninetailsrabbit Ninetailsrabbit diff --git a/Match3Maker/src/components/Board.cs b/Match3Maker/src/components/Board.cs index eda4faf..cb44aa4 100644 --- a/Match3Maker/src/components/Board.cs +++ b/Match3Maker/src/components/Board.cs @@ -461,6 +461,21 @@ public void RemoveMatchesFromBoard() { #endregion #region Pieces + + public void GenerateRandomPieceOnCells(IEnumerable cells, IEnumerable? only = null) { + foreach (GridCell cell in cells) + GenerateRandomPieceOnCell(cell, only); + } + public void GenerateRandomPieceOnCell(GridCell cell, IEnumerable? only = null) { + cell.AssignPiece(GenerateRandomPiece(only)); + } + public Piece GenerateRandomPiece(IEnumerable? only = null) { + if (AvailablePieces.IsEmpty()) + throw new InvalidOperationException("The available pieces on this board is empty, piece cannot be generated"); + + return PieceGenerator.Roll(AvailablePieces, only); + } + public Board AddAvailablePieces(IList pieces) { AvailablePieces.AddRange(pieces); AvailablePieces = AvailablePieces.RemoveDuplicates().ToList();