You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trek-12/source/Trek-12/Models/Rules/Rules.cs

45 lines
1.1 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Rules
{
public class Rules
{
public bool NearCell(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 )
{
return true;
}
}
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;
}
}
}