Skip to content

Commit bd94a38

Browse files
author
RUBIUS\chebanovdd
committed
Added onlyMovable param to GetSolvedGridSlots method.
1 parent c6fee4c commit bd94a38

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/Match3.App/SolvedData.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ public SolvedData(IReadOnlyCollection<ItemSequence<TGridSlot>> solvedSequences,
1515
public IReadOnlyCollection<TGridSlot> SpecialItemGridSlots { get; }
1616
public IReadOnlyCollection<ItemSequence<TGridSlot>> SolvedSequences { get; }
1717

18-
public IEnumerable<TGridSlot> GetSolvedGridSlots()
18+
public IEnumerable<TGridSlot> GetSolvedGridSlots(bool onlyMovable = false)
1919
{
2020
foreach (var sequence in SolvedSequences)
2121
{
2222
foreach (var solvedGridSlot in sequence.SolvedGridSlots)
2323
{
24+
if (onlyMovable && solvedGridSlot.IsMovable == false)
25+
{
26+
continue;
27+
}
28+
2429
yield return solvedGridSlot;
2530
}
2631
}

src/Match3.Infrastructure/Extensions/ItemsSequenceExtensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ public static IEnumerable<TGridSlot> GetUniqueSolvedGridSlots<TGridSlot>(this So
1111
{
1212
var solvedGridSlots = new HashSet<TGridSlot>();
1313

14-
foreach (var solvedGridSlot in solvedData.GetSolvedGridSlots())
14+
foreach (var solvedGridSlot in solvedData.GetSolvedGridSlots(onlyMovable))
1515
{
16-
if (onlyMovable && solvedGridSlot.IsMovable == false)
17-
{
18-
continue;
19-
}
20-
2116
if (solvedGridSlots.Add(solvedGridSlot) == false)
2217
{
2318
continue;

src/Match3.Infrastructure/GameBoardSolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Match3.Infrastructure
1111
{
12-
public class GameBoardSolver<TGridSlot> : IGameBoardSolver<TGridSlot> where TGridSlot : class, IGridSlot
12+
public class GameBoardSolver<TGridSlot> : IGameBoardSolver<TGridSlot> where TGridSlot : IGridSlot
1313
{
1414
private readonly ISpecialItemDetector<TGridSlot>[] _specialItemDetectors;
1515
private readonly ISequenceDetector<TGridSlot>[] _sequenceDetectors;

src/Match3.UnityPackage/Assets/Plugins/Match3/Runtime/Match3.App/SolvedData.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ public SolvedData(IReadOnlyCollection<ItemSequence<TGridSlot>> solvedSequences,
1515
public IReadOnlyCollection<TGridSlot> SpecialItemGridSlots { get; }
1616
public IReadOnlyCollection<ItemSequence<TGridSlot>> SolvedSequences { get; }
1717

18-
public IEnumerable<TGridSlot> GetSolvedGridSlots()
18+
public IEnumerable<TGridSlot> GetSolvedGridSlots(bool onlyMovable = false)
1919
{
2020
foreach (var sequence in SolvedSequences)
2121
{
2222
foreach (var solvedGridSlot in sequence.SolvedGridSlots)
2323
{
24+
if (onlyMovable && solvedGridSlot.IsMovable == false)
25+
{
26+
continue;
27+
}
28+
2429
yield return solvedGridSlot;
2530
}
2631
}

src/Match3.UnityPackage/Assets/Plugins/Match3/Runtime/Match3.Infrastructure/Extensions/ItemsSequenceExtensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ public static IEnumerable<TGridSlot> GetUniqueSolvedGridSlots<TGridSlot>(this So
1111
{
1212
var solvedGridSlots = new HashSet<TGridSlot>();
1313

14-
foreach (var solvedGridSlot in solvedData.GetSolvedGridSlots())
14+
foreach (var solvedGridSlot in solvedData.GetSolvedGridSlots(onlyMovable))
1515
{
16-
if (onlyMovable && solvedGridSlot.IsMovable == false)
17-
{
18-
continue;
19-
}
20-
2116
if (solvedGridSlots.Add(solvedGridSlot) == false)
2217
{
2318
continue;

src/Match3.UnityPackage/Assets/Plugins/Match3/Runtime/Match3.Infrastructure/GameBoardSolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Match3.Infrastructure
1111
{
12-
public class GameBoardSolver<TGridSlot> : IGameBoardSolver<TGridSlot> where TGridSlot : class, IGridSlot
12+
public class GameBoardSolver<TGridSlot> : IGameBoardSolver<TGridSlot> where TGridSlot : IGridSlot
1313
{
1414
private readonly ISpecialItemDetector<TGridSlot>[] _specialItemDetectors;
1515
private readonly ISequenceDetector<TGridSlot>[] _sequenceDetectors;

0 commit comments

Comments
 (0)