diff --git a/source/Trek-12/Models/Interfaces/IRules.cs b/source/Trek-12/Models/Interfaces/IRules.cs
index c2dbd70..b0b6e64 100644
--- a/source/Trek-12/Models/Interfaces/IRules.cs
+++ b/source/Trek-12/Models/Interfaces/IRules.cs
@@ -103,7 +103,7 @@ namespace Models.Interfaces
/// The list of rope paths.
/// The index of the rope path.
/// True if the adjacent cell is in the rope path; otherwise false.
- public bool IsInRopePaths(Cell adjacente, List> ropePaths, int index);
+ public bool IsInRopePaths(Cell adjacente, List> ropePaths, out int index);
///
/// Check if the chosen cell has the same value as the rope path at the given index.
diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs
index 677b562..d272c51 100644
--- a/source/Trek-12/Models/Rules/Rules.cs
+++ b/source/Trek-12/Models/Rules/Rules.cs
@@ -25,7 +25,7 @@ namespace Models.Rules
{
if (!IsCellEmpty(playerChoicePosition)) return false;
- if (playerChoicePosition.Valid == false) return false;
+ if (!playerChoicePosition.Valid) return false;
if (EveryAdjacentCells(playerChoicePosition, cells).Count == 1) return false;
@@ -46,13 +46,10 @@ namespace Models.Rules
public bool IsInRopePaths (Cell adjacente,List> ropePaths, out int index)
{
- foreach (List path in ropePaths)
+ foreach (var path in ropePaths.Where(path => path.Contains(adjacente)))
{
- if (path.Contains(adjacente))
- {
- index=ropePaths.IndexOf(path);
- return true;
- }
+ index=ropePaths.IndexOf(path);
+ return true;
}
index = 0;
@@ -74,7 +71,7 @@ namespace Models.Rules
IEnumerable PlayedCellsQuery =
from cell in cells
- where cell.Valid == true
+ where cell.Valid
select cell;
foreach (var cell in PlayedCellsQuery)
@@ -112,8 +109,6 @@ namespace Models.Rules
}
}
}
-
- return;
}
public bool IsValueInZones(Cell chosenCell, List> zones)
| |