Ajout de 2 méthodes de règles du jeu

pull/45/head
Rémi LAVERGNE 1 year ago
parent 1cd17ebff0
commit 95e45780fb

@ -10,15 +10,35 @@ namespace Models.Rules
{ {
public bool NearCell(Cell playerChoice, List<Cell> cells) public bool NearCell(Cell playerChoice, List<Cell> cells)
{ {
foreach (var item in cells) foreach (var item in cells)
{ {
if(playerChoice.X == item.X +1 || playerChoice.X == item.X - 1 if(playerChoice.Pos.X == item.Pos.X +1 || playerChoice.Pos.X == item.Pos.X - 1
|| playerChoice.Y == item.Y +1 || playerChoice.Y == item.Y -1 ) || playerChoice.Pos.Y == item.Pos.Y +1 || playerChoice.Pos.Y == item.Pos.Y -1 )
{ {
return true; return true;
} }
} }
return false; return false;
} }
public bool IsCellEmpty(Cell playerChoice)
{
if (playerChoice.Value == null)
{
return true;
}
return false;
}
public bool IsCellValid(Cell playerChoice, List<Cell> cells)
{
if (NearCell(playerChoice, cells) && IsCellEmpty(playerChoice))
{
return true;
}
return false;
}
} }
} }

Loading…
Cancel
Save