Exemplo n.º 1
0
        public List <OutboundChatMessage> ParseChatline(ChatMetaData meta)
        {
            var split = ChatHelpers.GetSingleCommandArgument(meta.Arguments);

            if (split == null)
            {
                return(meta.ReplyResponse(new ChatlineObject("Invalid tell command.", ChatlineColor.White)));
            }

            var otherPlayer = _playerManager.GetPlayer(split.Item1);

            if (otherPlayer == null)
            {
                return(meta.ReplyResponse(new ChatlineObject("Username " + split.Item1 + " not found.", ChatlineColor.White)));
            }

            if (!otherPlayer.IsOnline)
            {
                return(meta.ReplyResponse(new ChatlineObject("User " + split.Item1 + " is offline.", ChatlineColor.White)));
            }

            var outboundChats = new List <OutboundChatMessage>();
            var commonText    = new ChatlineFragment(split.Item2, ChatlineColor.White);

            var toOtherPlayer = new List <ChatlineFragment>()
            {
                new ChatlineFragment(meta.Player.Username + " tells you: ", ChatlineColor.Teal),
                commonText
            };

            var toSendingPlayer = new List <ChatlineFragment>()
            {
                new ChatlineFragment("You tell " + otherPlayer.Username + ": ", ChatlineColor.Teal),
                commonText
            };

            // Allows the client to keep track of who we should send replies to via /r
            var replyMetadata = new Dictionary <string, string>();

            replyMetadata["ReplyPlayer"] = meta.Player.Username;

            outboundChats.Add(new OutboundChatMessage(otherPlayer, new ChatlineObject(toOtherPlayer), replyMetadata));
            outboundChats.Add(new OutboundChatMessage(meta.Player, new ChatlineObject(toSendingPlayer)));

            return(outboundChats);
        }
Exemplo n.º 2
0
        public async Task <List <OutboundChatMessage> > ParseChatline(ChatMetaData meta)
        {
            if (meta.Arguments?.Trim() == null)
            {
                return(meta.ReplyResponse(new ChatlineObject("Invalid warp command.", ChatlineColor.White)));
            }

            AreaTypes newAreaType;

            try
            {
                newAreaType = (AreaTypes)Enum.Parse(typeof(AreaTypes), meta.Arguments.Trim(), true);
            }
            catch (Exception e)
            {
                return(meta.ReplyResponse(new ChatlineObject("Invalid warp destination type. Type \"system\". Error: " + e.Message, ChatlineColor.White)));
            }

            var allAreasOfType = await _databaseManager.GetAllAreas(newAreaType);

            var allAreasOfTypeList = allAreasOfType.ToList();

            var newArea = allAreasOfTypeList[_random.Next(allAreasOfTypeList.Count)];

            if (newArea == null)
            {
                return(meta.ReplyResponse(new ChatlineObject("Couldn't locate any areas of type.", ChatlineColor.White)));
            }

            var msg = new NetworkMessageContainer();

            msg.MessageType = MessageTypes.Redis_AdminWarpPlayer;
            msg.MessageData = new MessageAdminWarpPlayerRequest(meta.Player.ActiveShipId.Value, meta.Player.CurrentAreaID.Value, newArea.Id);

            _redisServer.PublishObject(MessageTypes.Redis_AdminWarpPlayer, msg);

            return(meta.ReplyResponse(new ChatlineObject("Warping you to " + newArea.AreaName + ".", ChatlineColor.White)));
        }
Exemplo n.º 3
0
 public List <OutboundChatMessage> ParseChatline(ChatMetaData meta)
 {
     return(meta.ReplyResponse(new ChatlineObject(ChatText.Help, ChatlineColor.White)));
 }
Exemplo n.º 4
0
 public List <OutboundChatMessage> ParseChatline(ChatMetaData meta)
 {
     return(meta.ReplyResponse(new ChatlineObject(ChatText.InvalidChat, ChatlineColor.Red)));
 }