public static string TeleportToOverworld(Player player, bool root, bool curse, Random rand = null) { rand = rand ?? new Random(); var location = LocationsStatics.GetRandomLocationNotInDungeonOr(LocationsStatics.JOKE_SHOP); if (!Teleport(player, location, rand.Next(2) == 0)) { return(null); } if (root) { CharacterPrankProcedures.GiveEffect(player, JokeShopProcedures.ROOT_EFFECT); root = EffectProcedures.PlayerHasActiveEffect(player.Id, JokeShopProcedures.ROOT_EFFECT); } if (curse && !root) { CharacterPrankProcedures.ApplyLocalCurse(player, location, rand); } return($"All of a sudden the Joke Shop spits you out and you find yourself in {LocationsStatics.GetConnectionName(location)}!"); }
public void SendAs(string message, PlayerFormViewModel me) { string room = Clients.Caller.toRoom; me.Player.UpdateOnlineActivityTimestamp(); if (me.Player.BotId == AIStatics.ActivePlayerBotId && DomainRegistry.Repository.FindSingle(new IsAccountLockedOut { userId = me.Player.MembershipId })) { return; } // Assert player is not banned if (me.Player.IsBannedFromGlobalChat && room == "global") { return; } if (!message.TrimStart().StartsWith("/") && EffectProcedures.PlayerHasActiveEffect(me.Player.ToDbPlayer(), CharacterPrankProcedures.HUSHED_EFFECT)) { String[] denied = { "/me tries to speak but cannot!", "/me puffs profusely but doesn't make a sound!", "/me is unable to utter a single word!", "/me gesticulates wildly in the hope of communicating!", "/me is afflicted by a magical field, leaving them completely mute!", "/me has been hushed!", "/me tries to mouth some words in the hope you can understand!", "/me has lost their voice!", "/me has their lips sealed!", "/me will be unable to speak until the enchantment cast on them has lapsed!", "/me is counting down the minutes until they are able to speak again!", "/me tries to communicate through telepathy!" }; message = denied[new Random().Next(denied.Count())]; } // Get player picture and name var pic = HtmlHelpers.GetImageURL(me, true).ToString(); var descriptor = me.Player.GetDescriptor(); var name = descriptor.Item1; pic = string.IsNullOrWhiteSpace(descriptor.Item2) ? pic : descriptor.Item2; if (me.Player.BotId == AIStatics.ActivePlayerBotId) { if (Context.User.IsInRole(PvPStatics.Permissions_Developer)) { name = name + " (Dev)"; } else if (Context.User.IsInRole(PvPStatics.Permissions_Admin)) { name = name + " (Admin)"; } else if (Context.User.IsInRole(PvPStatics.Permissions_Moderator)) { switch (me.Player.MembershipId) { case "d465db1c-ba4f-4347-b666-4dfd1c9a5e33": //Because Martha wants to be a filthy casual. break; case "08b476c3-d262-45b6-9e6a-7d94b472fefe": break; //So is this one. default: name = name + " (Mod)"; break; } } } // Performs message processing to correctly format any special text var output = ChatMessageProcessor.ProcessMessage(new MessageData(name, message)); if (!string.IsNullOrWhiteSpace(output.Text)) { var colorOut = output.SendPlayerChatColor ? me.Player.ChatColor : ""; if (me.Player.BotId == AIStatics.ActivePlayerBotId) { _chatPersistenceService.TrackMessageSend(me.Player.MembershipId, Context.ConnectionId); } var model = new { User = name, IsStaff = me.Player.BotId == AIStatics.ActivePlayerBotId ? ChatStatics.Staff.ContainsKey(me.Player.MembershipId) : false, Color = colorOut, Pic = pic, Message = WebUtility.HtmlEncode(output.Text), MessageType = Enum.GetName(output.MessageType.GetType(), output.MessageType), Timestamp = DateTime.UtcNow.ToUnixTime(), }; if (me.Player.BotId == AIStatics.ActivePlayerBotId && _chatPersistenceService.HasNameChanged(me.Player.MembershipId, name)) { _chatPersistenceService.TrackPlayerNameChange(me.Player.MembershipId, name); Clients.Caller.nameChanged(name); } Clients.Group(room).addNewMessageToPage(model); DomainRegistry.Repository.Execute(new CreateChatLog { Message = output.Text, Room = room, Name = name, UserId = me.Player.MembershipId, Color = me.Player.ChatColor, PortraitUrl = pic }); } UpdateUserList(room); // NPC dice prank if (room == "global" && me.Player.BotId == AIStatics.ActivePlayerBotId && message.StartsWith("/roll") && message.Contains("4d20") && JokeShopProcedures.IsJokeShopActive()) { var rand = new Random(); if (rand.Next(10) == 0) { IPlayerRepository playerRepo = new EFPlayerRepository(); var npcIds = playerRepo.Players.Where(p => p.BotId <= AIStatics.PsychopathBotId && p.Mobility == PvPStatics.MobilityFull) .Select(p => p.Id).ToArray(); if (npcIds.Any()) { var npcId = npcIds[rand.Next(npcIds.Count())]; SendAs(message, PlayerProcedures.GetPlayerFormViewModel(npcId)); } } } }
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())); }