public void Apply(ArcadeUser user) { if (Money > 0) { user.Give(Money); } ulong oldExp = user.Exp; if (Exp > 0) { user.Exp += Exp; } if (user.Config.Notifier.HasFlag(NotifyAllow.Level)) { int oldLevel = ExpConvert.AsLevel(oldExp, user.Ascent); int level = user.Level; if (level > oldLevel) { user.Notifier.Append($"Level up! ({LevelViewer.GetLevel(oldLevel, user.Ascent)} to {LevelViewer.GetLevel(level, user.Ascent)})"); } } if (!Check.NotNullOrEmpty(ItemIds)) { return; } foreach ((string itemId, int amount) in ItemIds) { ItemHelper.GiveItem(user, itemId, amount); } }
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}."); }