// Method called on each click on opponentgrid to process shot result. public void FireShot(int idGame, string shooterPlayerConnectionId, int row, int column) { Game game = Gamelist.GetGame(idGame); if (game != null) { Player targetPlayer = game.GetOpponentPlayer(shooterPlayerConnectionId); Player shooterPlayer = game.GetPlayer(shooterPlayerConnectionId); Coordinate coordinate = new Coordinate(row, column); ShotResult result = targetPlayer.ProcessShot(coordinate); shooterPlayer.ProcessShotResult(coordinate, result); if (result.Equals(ShotResult.Miss)) { Clients.Caller.updateShotGridOnMissedShot(shooterPlayer.ShotGrid); Clients.Client(targetPlayer.ConnectionId).setTurn(); } else if (result.Equals(ShotResult.Hit)) { Clients.Caller.updateShotGridOnSuccessfullShot(shooterPlayer.ShotGrid); Clients.Client(targetPlayer.ConnectionId).notifyHit(); } else { if (!targetPlayer.HasLost) { Clients.Caller.updateShotGridOnSunkShip(shooterPlayer.ShotGrid); Clients.Client(targetPlayer.ConnectionId).notifyShipHasBeenSink(); } else { shooterPlayer.UpdateScoreOnVictory(); targetPlayer.UpdateScoreOnDefeat(); Clients.Caller.notifyPlayerVictory(shooterPlayer.ShotGrid); Clients.Client(targetPlayer.ConnectionId).notifyPlayerDefeat(); Gamelist.Remove(game); log.Info("Game : " + idGame + " winner : " + shooterPlayer.Name + " looser : " + targetPlayer.Name); } } } }