From 54d75d3078f95e6eb291d0cde398945f2da3986c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Sat, 13 Apr 2024 09:25:35 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20r=C3=A8gles=20des=20Box=20et=20pe?= =?UTF-8?q?tite=20modif=20dans=20la=20class=20Cell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Cell.cs | 7 ++-- source/Trek-12/Models/Rules/ruleBox.cs | 45 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 source/Trek-12/Models/Rules/ruleBox.cs 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; + } + } + } + + } +}