Cr🚩 Cration des règles pour les zones et chemins de corde

pull/50/head
Rémi LAVERGNE 1 year ago
parent 95e45780fb
commit 77ee9e93b7
No known key found for this signature in database
GPG Key ID: CA264B55E97FD220

@ -0,0 +1,43 @@
namespace Models.Rules;
public class Zones
{
public bool IsZone(Cell playerChoice, List<Cell> 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<Cell> cells, List<Cell> 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;
}
}
Loading…
Cancel
Save