Skip to content

Commit

Permalink
more helper methods to manage pieces and the actions they can do
Browse files Browse the repository at this point in the history
  • Loading branch information
ninetailsrabbit committed Jun 9, 2024
1 parent 4ab0a9f commit 3436e33
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Match3Maker/Match3Maker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<PropertyGroup>
<Title>Ninetailsrabbit.Match3Maker</Title>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<Description>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</Description>
<Copyright>© 2024 Ninetailsrabbit</Copyright>
<Authors>Ninetailsrabbit</Authors>
Expand Down
5 changes: 3 additions & 2 deletions Match3Maker/src/components/GridCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void AssignPiece(Piece piece) {

return previousPiece;
}

public bool SwapPieceWith(GridCell otherCell) {
if (CanSwapPieceWith(otherCell)) {

Expand Down Expand Up @@ -85,7 +84,9 @@ public bool CanSwapPieceWith(GridCell otherCell) {
&& !Piece.Locked
&& !otherCell.Piece.Locked
&& !Equals(otherCell)
&& !Piece.Equals(otherCell.Piece);
&& !Piece.Equals(otherCell.Piece)
&& Piece.Type.CanBeSwapped()
&& otherCell.Piece.Type.CanBeSwapped();
}

public bool InSameRowAs(GridCell cell) => cell.Row.Equals(Row);
Expand Down
4 changes: 4 additions & 0 deletions Match3Maker/src/interfaces/IPieceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ public interface IPieceType {
public bool MatchWith(Piece piece);
public bool CanBeShuffled();
public bool CanBeMoved();
public bool CanBeSwapped();
public bool CanBeTriggered();
public bool CanBeReplaced();

}
}
3 changes: 3 additions & 0 deletions Match3Maker/src/pieces/NormalPieceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ public bool MatchWith(Piece piece) {

public bool CanBeShuffled() => true;
public bool CanBeMoved() => true;
public bool CanBeSwapped() => true;
public bool CanBeTriggered() => false;
public bool CanBeReplaced() => true;
}
}
3 changes: 3 additions & 0 deletions Match3Maker/src/pieces/ObstaclePieceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public ObstaclePieceType(string shape, Color? color = null) {
public bool MatchWith(Piece piece) => false;
public bool CanBeShuffled() => false;
public bool CanBeMoved() => false;
public bool CanBeSwapped() => false;
public bool CanBeTriggered() => false;
public bool CanBeReplaced() => false;

}

Expand Down
3 changes: 3 additions & 0 deletions Match3Maker/src/pieces/SpecialPieceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public bool MatchWith(Piece piece) {

public bool CanBeShuffled() => true;
public bool CanBeMoved() => true;
public bool CanBeSwapped() => true;
public bool CanBeTriggered() => true;
public bool CanBeReplaced() => false;
}

}

0 comments on commit 3436e33

Please sign in to comment.