private StringBuilder GeneratePoint(Point point, IList <GeneratedShip> generatedShips, IList <Point> shoots) { StringBuilder generatedPoint = new StringBuilder(); ShootResult shootResult = shootChecker.CheckShot(point, generatedShips, shoots); switch (shootResult) { case ShootResult.Hit: generatedPoint.Append(" x |"); break; case ShootResult.HitAndSink: case ShootResult.SinkAllShips: generatedPoint.Append(" X |"); break; case ShootResult.Miss: generatedPoint.Append(" o |"); break; default: generatedPoint.Append(" |"); break; } return(generatedPoint); }
public override StringBuilder Process(string enteredData) { StringBuilder output = new StringBuilder(); try { Point shootCoordinates = ParseEnteredDataToPoint(enteredData); Game.Board.Shoots.Add(shootCoordinates); ShootResult shootResult = shootChecker.CheckShot(shootCoordinates, Game.Board.GeneratedShips, Game.Board.Shoots); switch (shootResult) { case ShootResult.Hit: output.AppendLine("You hit"); return(output); case ShootResult.Miss: output.AppendLine("You miss"); return(output); case ShootResult.HitAndSink: output.AppendLine("You hit and sink"); return(output); case ShootResult.SinkAllShips: output.AppendLine("You sink all ships"); Game.TransitionTo(serviceProvider.GetService <EndGameState>()); return(output); } } catch (Exception e) { logger.LogError(e, e.Message); } output.AppendLine("Wrong coordinates. Try again."); return(output); }