From 77ee9e93b770e40e044596abbf2b1b654033a9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sat, 13 Apr 2024 09:12:50 +0200 Subject: [PATCH] =?UTF-8?q?Cr=F0=9F=9A=A9=20Cration=20des=20r=C3=A8gles=20?= =?UTF-8?q?pour=20les=20zones=20et=20chemins=20de=20corde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Rules/Zones.cs | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 source/Trek-12/Models/Rules/Zones.cs diff --git a/source/Trek-12/Models/Rules/Zones.cs b/source/Trek-12/Models/Rules/Zones.cs new file mode 100644 index 0000000..bc99d7d --- /dev/null +++ b/source/Trek-12/Models/Rules/Zones.cs @@ -0,0 +1,43 @@ +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