예제 #1
0
        public static SimpleMessagePiece BuildSysMsgItem(string msgText)
        {
            var dictionary = Utils.ChatUtils.BuildParametersDictionary(msgText);

            var id  = Utils.ChatUtils.GetId(dictionary, "item");
            var uid = Utils.ChatUtils.GetItemUid(dictionary);

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

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

            if (dictionary.TryGetValue("UserName", out var username))
            {
                rawLink.Append("@" + username);
            }

            var name  = $"Unknown item [{id}]";
            var grade = RareGrade.Common;

            if (Game.DB.ItemsDatabase.Items.TryGetValue(id, out var i))
            {
                name  = i.Name;
                grade = i.RareGrade;
            }

            var enchant = dictionary.TryGetValue("enchantCount", out var enchCount)
                            ? $"+{enchCount} "
                            : "";

            return(new ActionMessagePiece($"<{enchant}{name}>", rawLink.ToString())
            {
                Color = TccUtils.GradeToColorString(grade)
            });
        }
        public BrokerChatMessage(uint playerId, uint listing, int item, long amount, long sellerPrice, long offeredPrice, string name)
        {
            ContainsPlayerName = true;
            Channel            = ChatChannel.Bargain;
            Author             = name;
            ListingId          = listing;
            PlayerId           = playerId;

            Amount = new SimpleMessagePiece("Offer for " + amount, App.Settings.FontSize, false)
            {
                Container = this
            };
            OfferedPrice = new MoneyMessagePiece(new Money(offeredPrice))
            {
                Container = this
            };
            StartingPrice = new MoneyMessagePiece(new Money(sellerPrice))
            {
                Container = this
            };
            Listing = new SimpleMessagePiece("")
            {
                Container = this
            };

            Game.DB !.ItemsDatabase.Items.TryGetValue((uint)item, out var i);
            if (i == null)
            {
                return;
            }
            Listing.Text = "<" + i.Name + ">";
            //TODO: //Listing.ItemId = i.Id;
            Listing.Color = TccUtils.GradeToColorString(i.RareGrade);

            PlainMessage = Listing.Text;
            //Listing.Type = MessagePieceType.Item;
        }