/// <summary> /// Helper method for the UseAmmo request, processes the BR gamemode businesss logic. /// Will confirm the player is within the playing radius, if not will disable the player. /// </summary> /// <param name="player">The player who is using the ammo</param> /// <param name="latitude">The latitude of the player.</param> /// <param name="longitude">The longitude of the player.</param> /// <returns></returns> private ActionResult <Response <Player> > BR_UseAmmoLogic(Player player, double latitude, double longitude) { //Decrement the players ammo Response <Player> response = new PlayerDAL().UseAmmo(player); if (!response.IsSuccessful()) { return(response); } player = response.Data; HubInterface hubInterface = new HubInterface(_hubContext); //If the player is not within the zone disable the player if (!player.Game.IsInZone(latitude, longitude)) { //Calculate the the number of minutes the player will be disabled for int totalMinutesDisabled = player.Game.CalculateDisabledTime(); int totalMillisecondsDisabled = totalMinutesDisabled * 60 * 1000; //Disable the player response = new PlayerDAL().BR_DisableOrRenablePlayer(player, totalMinutesDisabled); if (!response.IsSuccessful()) { return(response); } player = response.Data; //Call the hub to update the client that they are now disabled hubInterface.BR_UpdatePlayerDisabled(player, totalMinutesDisabled); //Schedule the player to be re-enabled ScheduledTasks.BR_SchedulePlayerReEnabled(player, hubInterface, totalMillisecondsDisabled); //Set the error code and message to indicate to the client that the player is now disabled. response.ErrorMessage = "Not inside the zone."; response.ErrorCode = ErrorCodes.BR_NOTINZONE; } //Schedule the ammo to be replenished ScheduledTasks.ScheduleReplenishAmmo(player, hubInterface); //Compress the player object before sending back over the network response.Data.Compress(true, true, true); return(response); }