public virtual ActionResult ChangeBlacklistType(int id, int playerId, string type) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var target = PlayerProcedures.GetPlayer(playerId); // assert that this player is not a bot if (target.BotId < AIStatics.ActivePlayerBotId) { TempData["Error"] = "You cannot blacklist an AI character."; return(RedirectToAction(MVC.PvP.Play())); } // assert that this player owns this blacklist entry // assert that this player has not been friended if (FriendProcedures.PlayerIsMyFriend(me, target)) { TempData["Error"] = "You cannot blacklist one of your friends."; TempData["SubError"] = "Cancel your friendship with this player first."; return(RedirectToAction(MVC.PvP.Play())); } TempData["Result"] = BlacklistProcedures.TogglePlayerBlacklistType(id, type, me, target); return(RedirectToAction(MVC.PvP.Play())); }
public virtual ActionResult MyBlacklistEntries() { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var output = BlacklistProcedures.GetMyBlacklistEntries(me); return(View(MVC.Settings.Views.MyBlacklistEntries, output)); }
public virtual ActionResult SendMessage(MessageSubmitViewModel input) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var receiver = PlayerProcedures.GetPlayer(input.ReceiverId); // assert player is not banned from chat if (me.IsBannedFromGlobalChat) { TempData["Error"] = "You have been banned and cannot send any messages."; TempData["SubError"] = "If you feel this is in error or wish to make an appeal you may do so on the forums."; return(RedirectToAction(MVC.PvP.Play())); } // assert no blacklist exists if (BlacklistProcedures.PlayersHaveBlacklistedEachOther(me, receiver, "message")) { TempData["Error"] = "This player has blacklisted you or is on your own blacklist."; TempData["SubError"] = "You cannot send messages to players who have blacklisted you. Remove them from your blacklist or ask them to remove you from theirs."; return(RedirectToAction(MVC.PvP.Play())); } if (EffectProcedures.PlayerHasActiveEffect(me, CharacterPrankProcedures.HUSHED_EFFECT)) { TempData["ErrorMessage"] = "You have been hushed and cannot currently send a message. Try again once the effect has worn off."; TempData["MessageText"] = input.MessageText; return(RedirectToAction(MVC.Messages.Write(input.ReceiverId, input.responseToId))); } if (input.MessageText.IsNullOrEmpty()) { TempData["ErrorMessage"] = "You need to write something to send to this person."; TempData["MessageText"] = input.MessageText; return(RedirectToAction(MVC.Messages.Write(input.ReceiverId, input.responseToId))); } if (input.MessageText.Length > 1000) { TempData["ErrorMessage"] = "Your message is too long."; TempData["MessageText"] = input.MessageText; return(RedirectToAction(MVC.Messages.Write(input.ReceiverId, input.responseToId))); } MessageDetail repliedMsg = null; if (input.responseToId > 0) { repliedMsg = DomainRegistry.Repository.FindSingle(new GetMessage { MessageId = input.responseToId, OwnerId = me.Id }); } DomainRegistry.Repository.Execute(new CreateMessage { ReceiverId = receiver.Id, SenderId = me.Id, Text = input.MessageText, ReplyingToThisMessage = repliedMsg }); NoticeService.PushNotice(receiver, "<b>" + me.GetFullName() + " has sent you a new message.</b>", NoticeService.PushType__PlayerMessage); TempData["Result"] = "Your message has been sent."; if (me.Mobility != PvPStatics.MobilityFull) { ItemProcedures.UpdateSouledItem(me); } return(RedirectToAction(MVC.Messages.Index())); }
public virtual ActionResult IssueChallenge(int id) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); // assert player is animate if (me.Mobility != PvPStatics.MobilityFull) { TempData["Error"] = "You must be animate in order to challenge someone to a duel."; return(RedirectToAction(MVC.PvP.Play())); } // assert player is not already in a duel if (me.InDuel > 0) { TempData["Error"] = "You are already actively participating in a duel."; TempData["SubError"] = "You must finish your currently active duel before you can start a new one."; return(RedirectToAction(MVC.PvP.Play())); } // assert that this player is not in a quest if (me.InQuest > 0) { TempData["Error"] = "You must finish your quest before you can participate in a duel."; return(RedirectToAction(MVC.PvP.Play())); } // assert that the player has not been in recent combat var minutesAgo = Math.Abs(Math.Floor(me.GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalMinutes)); if (minutesAgo < TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling()) { TempData["Error"] = "You must wait another " + (TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling() - minutesAgo) + " minutes without being in combat in order to challenge this opponent to a duel."; return(RedirectToAction(MVC.PvP.Play())); } var duelTarget = PlayerProcedures.GetPlayer(id); // assert target is not a bot if (duelTarget.BotId != AIStatics.ActivePlayerBotId) { TempData["Error"] = "You cannot challenge an NPC to a duel."; return(RedirectToAction(MVC.PvP.Play())); } // assert target is animate if (duelTarget.Mobility != PvPStatics.MobilityFull) { TempData["Error"] = "Your target must be animate in order to challenge someone to a duel."; return(RedirectToAction(MVC.PvP.Play())); } // assert no blacklist exists if (BlacklistProcedures.PlayersHaveBlacklistedEachOther(me, duelTarget, "attack")) { TempData["Error"] = "This player has blacklisted you or is on your own blacklist."; TempData["SubError"] = "You cannot duel players who are on your blacklist. Remove them from your blacklist first or ask them to remove you from theirs."; return(RedirectToAction(MVC.PvP.Play())); } // assert target is not already in a duel if (duelTarget.InDuel > 0) { TempData["Error"] = "Your target is already actively participating in a duel."; TempData["SubError"] = "Your target must finish their currently active duel before they can start a new one."; return(RedirectToAction(MVC.PvP.Play())); } // assert that this player is not in a quest if (duelTarget.InQuest > 0) { TempData["Error"] = "Your target must finish their quest before you can duel them."; return(RedirectToAction(MVC.PvP.Play())); } // assert that the target has not been in recent combat minutesAgo = Math.Abs(Math.Floor(me.GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalMinutes)); if (minutesAgo < TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling()) { TempData["Error"] = "Your target must wait longer without being in combat in order to duel you."; return(RedirectToAction(MVC.PvP.Play())); } // assert both players are in the same location if (me.dbLocationName != duelTarget.dbLocationName) { TempData["Error"] = "You must be in the same location as your target in order to challenge them to a duel."; return(RedirectToAction(MVC.PvP.Play())); } // assert both players are in an okay game mode var weAreFriends = FriendProcedures.PlayerIsMyFriend(me, duelTarget); if (!weAreFriends) { // player is in PvP; target is not if (me.GameMode == (int)GameModeStatics.GameModes.PvP && duelTarget.GameMode < (int)GameModeStatics.GameModes.PvP) { TempData["Error"] = "You must either be friends with your target or in the same game mode to challenge them to a duel."; return(RedirectToAction(MVC.PvP.Play())); } // player is not in PvP; target is else if (me.GameMode < (int)GameModeStatics.GameModes.PvP && duelTarget.GameMode == (int)GameModeStatics.GameModes.PvP) { TempData["Error"] = "You must either be friends with your target or in the same game mode to challenge them to a duel."; return(RedirectToAction(MVC.PvP.Play())); } } // TODO: assert player does not already have a pending duel request DuelProcedures.SendDuelChallenge(me, duelTarget); TempData["Result"] = "You have sent out a challenge to a duel to " + duelTarget.GetFullName() + "."; return(RedirectToAction(MVC.PvP.Play())); }