Пример #1
0
        private List<Cell> GetMovesForARangeInDirection(Cell source, int range, Cell.Touching direction)
        {
            var moves = new List<Cell>();

            if (range == 0)
                return moves;

            if (source.GetAdjacent(direction).GetState() == Cell.State.Empty)
            {
                moves.Add(source.GetAdjacent(direction));
                moves.AddRange(GetMovesForARangeInDirection(source.GetAdjacent(direction), --range, direction));
            }
            else if (source.GetAdjacent(direction).GetState() == Cell.State.Occupied &&
                     _cellToMove.GetPieceColor() != source.GetAdjacent(direction).GetPieceColor())
            {
                moves.Add(source.GetAdjacent(direction));
            }

            return moves;
        }
Пример #2
0
 private void Adjacent(Cell source, Cell above, Cell right, Cell below, Cell left)
 {
     Assert.AreEqual(above, source.GetAdjacent(Cell.Touching.Above));
     Assert.AreEqual(right, source.GetAdjacent(Cell.Touching.Right));
     Assert.AreEqual(below, source.GetAdjacent(Cell.Touching.Below));
     Assert.AreEqual(left, source.GetAdjacent(Cell.Touching.Left));
 }