Exemplo n.º 1
0
        public void PlaceQueens(IEnumerable <Position> positions)
        {
            // Clear board
            ClearImages();

            // Place queens
            positions
            .ToList()
            .ForEach(pos =>
                     Squares.First(sq => pos.RowNo == sq.Position.RowNo && pos.ColumnNo == sq.Position.ColumnNo)
                     .ImagePath = QueenImagePath);
        }
Exemplo n.º 2
0
 private void OnDrawMove(Move obj)
 {
     Squares.ForEach(s =>
     {
         if (s.SquareState == SquareState.History)
         {
             s.SquareState = SquareState.Empty;
         }
     });
     Squares.First(s => s.Position == obj.From).SquareState = SquareState.History;
     Squares.First(s => s.Position == obj.To).SquareState   = SquareState.History;
 }
Exemplo n.º 3
0
        public HitResult IsHit(Square square)
        {
            if (!Squares.Contains(square))
            {
                return(HitResult.Missed);
            }
            var sq = Squares.First(s => s == square);

            sq.Hit = true;
            bool sunk = Squares.Count(s => s.Hit == true) == Squares.Count();

            return(sunk ? HitResult.Sunk : HitResult.Hit);
        }
Exemplo n.º 4
0
 public HitResult Hit(Square square)
 {
     if (!Squares.Contains(square))
     {
         return(HitResult.Missed);
     }
     Squares.First(s => s == square).Hit = true;
     if (Squares.Count(s => s.Hit) == Squares.Count())
     {
         foreach (var s in Squares)
         {
             s.SetState(HitResult.Sunken);
         }
         return(HitResult.Sunken);
     }
     return(HitResult.Hit);
 }