コード例 #1
0
        public static string WriteItemValue(Item item, int discount, ShopMode mode, bool showDetails = false)
        {
            var cost = new StringBuilder();

            cost.Append($"{Icons.IconOf(item.Currency)} ");

            if (item.Value == 0)
            {
                cost.Append("**Unknown Cost**");
                return(cost.ToString());
            }

            discount = Math.Clamp(discount, 0, 100);

            if (discount == 100)
            {
                cost.Append(mode == ShopMode.Buy ? "**Free**" : "**Worthless**");
                return(cost.ToString());
            }

            cost.Append($" **{GetCost(item.Value, discount):##,0}**");

            if (showDetails && discount > 0)
            {
                cost.Append($" (**{discount}**% {(mode == ShopMode.Buy ? "discount" : "deduction")})");
            }

            return(cost.ToString());
        }
コード例 #2
0
        public static string Sell(Shop shop, ItemData data, ArcadeUser user)
        {
            if (!CanSell(shop, data))
            {
                return(Format.Warning($"**{shop.Name}** does not accept this item."));
            }

            Item item = ItemHelper.GetItem(data.Id);

            ItemHelper.TakeItem(user, data);

            long value = shop.SellDeduction > 0
                ? (long)Math.Floor(item.Value * (1 - shop.SellDeduction / (double)100))
                : item.Value;

            user.Give(value, item.Currency);
            string icon = (Check.NotNull(item.GetIcon()) ? $"{item.GetIcon()} " : "");
            string name = $"{icon}**{(Check.NotNull(icon) ? item.Name : item.GetName())}**";

            return($"> You have received {Icons.IconOf(item.Currency)} **{value:##,0}** for {name}.");
        }
コード例 #3
0
 public static string WriteCost(long value, CurrencyType currency)
 => value <= 0 ? "**Unknown Cost**" : $"{Icons.IconOf(currency)} **{value:##,0}**";