Example #1
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);
        }
Example #2
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);
 }