diff --git a/source/Trek-12/Models/Game/Game.cs b/source/Trek-12/Models/Game/Game.cs index d7b34cb..da7a179 100644 --- a/source/Trek-12/Models/Game/Game.cs +++ b/source/Trek-12/Models/Game/Game.cs @@ -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; @@ -75,14 +76,40 @@ namespace Models.Game playerChoice.Value = result; } } - - /* - public void AddToRopePath(Cell cell) + + public void AddToRopePath(Cell playerChoice, List> ropePaths,Cell adjacente) { - if (GameRules.IsRopePath(cell, ropePaths)) return; + + List> 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 paths in ropePaths) + { + foreach (var cells in paths) + { + 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) + { + + } } - */ - public void InitializeGame() { @@ -107,5 +134,6 @@ namespace Models.Game await Task.Delay(1000); // 1 seconde } } + } } diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 3f9d9a4..37a505a 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -19,6 +19,11 @@ namespace Models.Rules return true; } + + public bool ropePathCellIsValid (Cell choosenCell, Cell targetCell) + { + if (Math.Abs(choosenCell.Value - targetCell.Value ) + } public bool NearCellIsValid(Cell choosenCell, List cells) {