|
|
|
@ -317,7 +317,7 @@ namespace Models.Game
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="playerChoice">The cell chosen by the player to place the result.</param>
|
|
|
|
|
/// <param name="result">The result of the dice operation to be placed in the cell.</param>
|
|
|
|
|
private void PlaceResult(Cell playerChoice, int result)
|
|
|
|
|
private void PlaceResult(Cell playerChoice)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<Cell> ValidCell =
|
|
|
|
|
from cell in UsedMap.Boards
|
|
|
|
@ -326,8 +326,11 @@ namespace Models.Game
|
|
|
|
|
select cell;
|
|
|
|
|
foreach (var item in ValidCell)
|
|
|
|
|
{
|
|
|
|
|
if(item.X == playerChoice.X && item.Y == playerChoice.Y)
|
|
|
|
|
item.Value = result;
|
|
|
|
|
if (item.X == playerChoice.X && item.Y == playerChoice.Y)
|
|
|
|
|
{
|
|
|
|
|
item.Value = PlayerCell.Value;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,35 +339,32 @@ namespace Models.Game
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="playerChoice"></param>
|
|
|
|
|
/// <param name="adjacentes"></param>
|
|
|
|
|
private void AddToRopePath(Cell playerChoice,List<Cell> adjacentes)
|
|
|
|
|
private void AddToRopePath(Cell playerChoice,List<Cell> board)
|
|
|
|
|
{
|
|
|
|
|
int index =0;
|
|
|
|
|
|
|
|
|
|
foreach (var cells in adjacentes.Where(cells => cells.Value - playerChoice.Value == 1 || cells.Value - playerChoice.Value == -1))
|
|
|
|
|
{
|
|
|
|
|
// Le cas si il n'existe aucun chemin de corde
|
|
|
|
|
if (UsedMap.RopePaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
// Creer un nouveau chemin de corde avec la cellule choisi par le joueur et celle adjacente
|
|
|
|
|
UsedMap.RopePaths.Add(new List<Cell> {playerChoice, cells});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Turn==1) return;
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
IEnumerable<Cell> ValidCell =
|
|
|
|
|
from cell in UsedMap.Boards
|
|
|
|
|
where cell.Value != null && cell.Valid == true && cell != playerChoice
|
|
|
|
|
select cell;
|
|
|
|
|
|
|
|
|
|
// 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 });
|
|
|
|
|
foreach (var item in ValidCell)
|
|
|
|
|
{
|
|
|
|
|
if (!GameRules.IsCellAdjacent(playerChoice, item))
|
|
|
|
|
continue;
|
|
|
|
|
if (!((playerChoice.Value - item.Value) == 1 || (playerChoice.Value - item.Value) == -1))
|
|
|
|
|
continue;
|
|
|
|
|
if (!GameRules.IsInRopePaths(item,UsedMap.RopePaths,index))
|
|
|
|
|
{
|
|
|
|
|
UsedMap.RopePaths.Add(new List<Cell> { playerChoice, item });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!GameRules.AsValue(playerChoice,UsedMap.RopePaths,index))
|
|
|
|
|
if (!GameRules.AsValue(playerChoice, UsedMap.RopePaths, index))
|
|
|
|
|
{
|
|
|
|
|
UsedMap.RopePaths[index].Add(playerChoice);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -410,17 +410,17 @@ namespace Models.Game
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GameLoop()
|
|
|
|
|
{
|
|
|
|
|
int res = 0,turn = 1;
|
|
|
|
|
Cell cell;
|
|
|
|
|
while (IsRunning)
|
|
|
|
|
{
|
|
|
|
|
RollAllDice();
|
|
|
|
|
res = PlayerChooseOperation();
|
|
|
|
|
PlayerOption?.Invoke(this,new PlayerOptionEventArgs(UsedMap.Boards.ToList(),res,turn));
|
|
|
|
|
int res = PlayerChooseOperation();
|
|
|
|
|
PlayerOption?.Invoke(this,new PlayerOptionEventArgs(UsedMap.Boards.ToList(),res,Turn));
|
|
|
|
|
PlayerSelectionCell();
|
|
|
|
|
PlaceResult(PlayerCell,res);
|
|
|
|
|
PlayerCell.Value = res;
|
|
|
|
|
AddToRopePath(PlayerCell,UsedMap.Boards.ToList());
|
|
|
|
|
PlaceResult(PlayerCell);
|
|
|
|
|
BoardUpdated?.Invoke(this, new BoardsUpdateEventArgs(UsedMap.Boards.ToList()));
|
|
|
|
|
turn++;
|
|
|
|
|
Turn++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|