diff --git a/source/Trek-12/Models/Cell.cs b/source/Trek-12/Models/Cell.cs index 66e5f4f..b9a8b33 100644 --- a/source/Trek-12/Models/Cell.cs +++ b/source/Trek-12/Models/Cell.cs @@ -20,16 +20,16 @@ public class Cell } } - private string Type { get; set; } + public bool IsDangerous { get; set; } - private string? Background { get; set; } + public string? Background { get; set; } public Cell(int x, int y) { Pos = new Position(x, y); } - public string GetCellType() => Type; + public bool GetCellType() => IsDangerous; // Redefinition de l'opérateur == pour comparer deux cellules @@ -48,4 +48,5 @@ public class Cell { return Pos.X * Pos.Y; } + } \ No newline at end of file diff --git a/source/Trek-12/Models/Rules/ruleBox.cs b/source/Trek-12/Models/Rules/ruleBox.cs new file mode 100644 index 0000000..77ea036 --- /dev/null +++ b/source/Trek-12/Models/Rules/ruleBox.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Models; + +namespace Models.Rules +{ + public class ruleBox + { + public int HowMuch(Cell playerChoice, List cells) + { + foreach(var pos in cells) + { + if (pos.Equals(playerChoice)) + { + if (pos.GetCellType()) + { + return 6; + } + return 12; + } + } + return 0; + } + + public void SetValueAndPenalty(int valueChoice, Cell playerChoice, List cells) + { + int val = HowMuch(playerChoice, cells); + foreach (var pos in cells) + { + if (pos.Equals(playerChoice)) + { + if (valueChoice > val) + { + playerChoice.Background = "notcontent"; + } + playerChoice.Value = valueChoice; + } + } + } + + } +}