Skip to content

Commit

Permalink
Engine.Tests: Code cleanup in GameComparers.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fayti1703 committed Nov 2, 2024
1 parent 4b70948 commit 08b9cc2
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions BinaryMatrixEngine.Tests/GameComparers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace BinaryMatrix.Engine.Tests;

public class GameBoardComparer : IEqualityComparer<GameBoard> {
private IEqualityComparer<Cell> cellComparer;
private readonly IEqualityComparer<Cell> cellComparer;

public GameBoardComparer(IEqualityComparer<Cell> cellComparer) {
this.cellComparer = cellComparer;
Expand All @@ -31,18 +31,18 @@ public static GameBoardComparer CreateDefault() =>
}

public class CellComparer : IEqualityComparer<Cell> {
private IEqualityComparer<CardList> cardsComparerer;
private readonly IEqualityComparer<CardList> cardsComparer;

public CellComparer(IEqualityComparer<CardList> cardsComparerer) {
this.cardsComparerer = cardsComparerer;
public CellComparer(IEqualityComparer<CardList> cardsComparer) {
this.cardsComparer = cardsComparer;
}

public bool Equals(Cell? x, Cell? y) {
if(x == null || y == null) return x == null && y == null;
return
x.name == y.name &&
x.Revealed == y.Revealed &&
this.cardsComparerer.Equals(x.cards, y.cards)
this.cardsComparer.Equals(x.cards, y.cards)
;
}

Expand Down Expand Up @@ -124,14 +124,6 @@ IEqualityComparer<IReadOnlyList<CardMoveLog>> resultsComparer
this.resultsComparer = resultsComparer;
this.cardIDsComparer = new ElementwiseComparer<CardID>(EqualityComparer<CardID>.Default);
}

public static CombatLogComparer CreateDefault() {
IEqualityComparer<IReadOnlyList<CardMoveLog>> cardMoveLogComparer = new ElementwiseComparer<CardMoveLog>(new CardMoveLogComparer());
return new CombatLogComparer(
new ElementwiseComparer<CombatSpecialLog>(new CombatSpecialLogComparer(cardMoveLogComparer)),
cardMoveLogComparer
);
}

public bool Equals(CombatLog x, CombatLog y) {
if(x.inLane != y.inLane) return false;
Expand Down

0 comments on commit 08b9cc2

Please sign in to comment.