Ejemplo n.º 1
0
        public MessagePiece ParseSysMsgItem(Dictionary <string, string> info)
        {
            var id  = ChatUtils.GetId(info, "item");
            var uid = ChatUtils.GetItemUid(info);

            var rawLink = new StringBuilder("1#####");

            rawLink.Append(id.ToString());
            if (uid != 0)
            {
                rawLink.Append("@" + uid.ToString());
            }

            var username = SessionManager.CurrentPlayer.Name;

            if (info.ContainsKey("UserName"))
            {
                username = info["UserName"];
                rawLink.Append("@" + username);
            }
            var mp = new MessagePiece(id.ToString());

            if (SessionManager.ItemsDatabase.Items.TryGetValue(id, out var i))
            {
                var txt = $"<{i.Name}>";
                mp = new MessagePiece(txt)
                {
                    Type = MessagePieceType.Item,
                    //BoundType = i.BoundType,
                    ItemId    = id,
                    ItemUid   = uid,
                    OwnerName = username,
                    RawLink   = rawLink.ToString()
                };
                mp.SetColor(ChatUtils.GetItemColor(i));
            }
            return(mp);
        }