|
|
|
@ -88,38 +88,48 @@ namespace Models.Game
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddToRopePath(Cell playerChoice, List<List<Cell>> ropePaths,Cell adjacente)
|
|
|
|
|
public void AddToRopePath(Cell playerChoice,List<Cell> adjacentes)
|
|
|
|
|
{
|
|
|
|
|
int index =0;
|
|
|
|
|
|
|
|
|
|
List<List<Cell>> possiblePaths;
|
|
|
|
|
|
|
|
|
|
// {adjacentes} ne doit pas etre egale a {playerChoice}
|
|
|
|
|
if (adjacente.Value == playerChoice.Value) return;
|
|
|
|
|
|
|
|
|
|
// {adjacentes} doit etre croissant ou decroissant
|
|
|
|
|
if ((adjacente.Value - playerChoice.Value > 1) || (adjacente.Value - playerChoice.Value < -1)) return;
|
|
|
|
|
|
|
|
|
|
// Un nombre ne peut appartenir qu'a un seul chemin de corde
|
|
|
|
|
foreach (List<Cell> paths in ropePaths)
|
|
|
|
|
{
|
|
|
|
|
foreach (var cells in paths)
|
|
|
|
|
foreach (var cells in adjacentes)
|
|
|
|
|
{
|
|
|
|
|
// La cellule choisi peut creer/s'ajouter a un chemin de corde
|
|
|
|
|
if (cells.Value - playerChoice.Value == 1 || cells.Value - playerChoice.Value == -1)
|
|
|
|
|
{
|
|
|
|
|
if (adjacente.X == cells.X && adjacente.Y == adjacente.Y)
|
|
|
|
|
// Le cas si il n'existe aucun chemin de corde
|
|
|
|
|
if (UsedMap.RopePaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
possiblePaths.Add(paths);
|
|
|
|
|
// Creer un nouveau chemin de corde avec la cellule choisi par le joueur et celle adjacente
|
|
|
|
|
UsedMap.RopePaths.Add(new List<Cell> {playerChoice, cells});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// A modifier dans le cas ou il est possible de fusionner deux chemins de corde
|
|
|
|
|
if (GameRules.IsInRopePaths(playerChoice, UsedMap.RopePaths, index)) break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// Le cas si il existe des chemins de corde
|
|
|
|
|
|
|
|
|
|
// Est-ce que la cellule adjacentes fait parti d'un chemin de corde
|
|
|
|
|
if (!GameRules.IsInRopePaths(cells,UsedMap.RopePaths,index))
|
|
|
|
|
{
|
|
|
|
|
UsedMap.RopePaths.Add(new List<Cell> { playerChoice, cells });
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Si {ropePaths} est vide, il faut alors creer un chemin de corde entre {playerChoice}
|
|
|
|
|
if (ropePaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!GameRules.AsValue(playerChoice,UsedMap.RopePaths,index))
|
|
|
|
|
{
|
|
|
|
|
UsedMap.RopePaths[index].Add(playerChoice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Si oui, est-ce que le chemin possede deja la valeur correspondante a la valeur de la cellule du joueur choisi
|
|
|
|
|
// {playerChoice.Value} n'est pas dans le chemin de corde
|
|
|
|
|
// Ajouter au chemin
|
|
|
|
|
// {playerChoice.Value} existe dans le chemin de corde pas possible
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|