|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Threading.Tasks.Dataflow;
|
|
|
|
|
using Models.Events;
|
|
|
|
|
using Models.Rules;
|
|
|
|
|
|
|
|
|
@ -73,37 +74,37 @@ namespace Models.Game
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddToRopePath(Cell playerChoice, List<Cell> adjacentes, List<List<Cell>> ropePaths)
|
|
|
|
|
public void AddToRopePath(Cell playerChoice, List<List<Cell>> ropePaths,Cell adjacente)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Parmi les {adjacentes} garde seulement les cellules qui peuvent creer un chemin de corde
|
|
|
|
|
foreach (var item in adjacentes)
|
|
|
|
|
{
|
|
|
|
|
if (item.Value == playerChoice.Value && ((playerChoice.Value - item.Value) > 1 || (playerChoice.Value - item.Value) < -1)) adjacentes.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
List<List<Cell>> possiblePaths;
|
|
|
|
|
|
|
|
|
|
// Apres le foreach si la liste {adjacentes} est vide, plus aucune possiblite de creer ou d'ajouter a un chemin de corde
|
|
|
|
|
if (adjacentes.Count == 0) return;
|
|
|
|
|
// {adjacentes} ne doit pas etre egale a {playerChoice}
|
|
|
|
|
if (adjacente.Value == playerChoice.Value) return;
|
|
|
|
|
|
|
|
|
|
// Si {ropePaths} est vide, il faut alors creer un chemin de corde entre {playerChoice} et une cellule {d'adjacentes}
|
|
|
|
|
if (ropePaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
// Deux cas de figure soit la liste {adjacentes} contient une seul valeur soit plusieurs
|
|
|
|
|
|
|
|
|
|
// Si {adjacentes} contient une valeur, ajouter dans ropePaths un nouveau chemin de corde
|
|
|
|
|
|
|
|
|
|
// Si {adjacentes} contient plusieurs valeurs, permettre aux joueurs de choisir la cellule pour creer un nouveau chemin de corde
|
|
|
|
|
}
|
|
|
|
|
// {adjacentes} doit etre croissant ou decroissant
|
|
|
|
|
if ((adjacente.Value - playerChoice.Value > 1) || (adjacente.Value - playerChoice.Value < -1)) return;
|
|
|
|
|
|
|
|
|
|
foreach (var item in adjacentes)
|
|
|
|
|
// Un nombre ne peut appartenir qu'a un seul chemin de corde
|
|
|
|
|
foreach (List<Cell> paths in ropePaths)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in ropePaths)
|
|
|
|
|
foreach (var cells in paths)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item2 in item1)
|
|
|
|
|
if (adjacente.X == cells.X && adjacente.Y == adjacente.Y)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
possiblePaths.Add(paths);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Si {ropePaths} est vide, il faut alors creer un chemin de corde entre {playerChoice}
|
|
|
|
|
if (ropePaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|