diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 90f91c4..5a375da 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -40,5 +40,76 @@ namespace Models.Rules return false; } + + public bool IsZone(Cell playerChoice, List cells) + { + foreach (var item in cells) + { + if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1 + || playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1) + { + if (playerChoice.Value == item.Value) + { + return true; + } + } + } + return false; + } + + public bool IsCheminDeCorde(Cell playerChoice, List cells, List cheminsDeCorde) + { + foreach (var item in cells) + { + if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1 + || playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1) + { + if (playerChoice.Value == item.Value+1 || playerChoice.Value == item.Value-1) + { + foreach (var chemin in cheminsDeCorde) + { + if (chemin.Equals(playerChoice)) + { + return true; + } + } + return IsCheminDeCorde(item, cells, cheminsDeCorde); + } + } + } + return false; + } + + public int HowMany(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 = HowMany(playerChoice, cells); + foreach (var pos in cells) + { + if (pos.Equals(playerChoice)) + { + if (valueChoice > val) + { + playerChoice.Background = "notcontent"; + } + playerChoice.Value = valueChoice; + } + } + } } } diff --git a/source/Trek-12/Models/Rules/Zones.cs b/source/Trek-12/Models/Rules/Zones.cs deleted file mode 100644 index bc99d7d..0000000 --- a/source/Trek-12/Models/Rules/Zones.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Models.Rules; - -public class Zones -{ - public bool IsZone(Cell playerChoice, List cells) - { - foreach (var item in cells) - { - if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1 - || playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1) - { - if (playerChoice.Value == item.Value) - { - return true; - } - } - } - return false; - } - - public bool IsCheminDeCorde(Cell playerChoice, List cells, List cheminsDeCorde) - { - foreach (var item in cells) - { - if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1 - || playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1) - { - if (playerChoice.Value == item.Value+1 || playerChoice.Value == item.Value-1) - { - foreach (var chemin in cheminsDeCorde) - { - if (chemin.Equals(playerChoice)) - { - return true; - } - } - return IsCheminDeCorde(item, cells, cheminsDeCorde); - } - } - } - return false; - } -} \ No newline at end of file diff --git a/source/Trek-12/Models/Rules/ruleBox.cs b/source/Trek-12/Models/Rules/ruleBox.cs deleted file mode 100644 index 4f338d1..0000000 --- a/source/Trek-12/Models/Rules/ruleBox.cs +++ /dev/null @@ -1,45 +0,0 @@ -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 HowMany(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 = HowMany(playerChoice, cells); - foreach (var pos in cells) - { - if (pos.Equals(playerChoice)) - { - if (valueChoice > val) - { - playerChoice.Background = "notcontent"; - } - playerChoice.Value = valueChoice; - } - } - } - - } -}