Изменение отображения скидок в аплинке (#266)

* Better sales

* Sale item restrictions
This commit is contained in:
Aviu00
2023-08-04 16:00:49 +03:00
committed by Aviu00
parent b34ade60d8
commit 0c098d9c53
5 changed files with 65 additions and 2 deletions

View File

@@ -38,8 +38,10 @@ public sealed partial class StoreSystem
if (listing.Cost.Any(x => x.Value.Int() != newCost[x.Key].Int()))
{
var key = listing.Cost.First(x => x.Value > 0).Key;
listingData.OldCost = listing.Cost;
listingData.SaleAmount = 100 - (newCost[key] / listing.Cost[key] * 100).Int();
listingData.Cost = newCost;
listingData.SaleAmount = 100 - (int) MathF.Round(sale.Item1 * 100);
listingData.Categories = new() {sale.Item2};
}
}

View File

@@ -183,6 +183,14 @@ public sealed partial class StoreSystem
listing.PurchaseAmount++; //track how many times something has been purchased
_audio.PlayEntity(component.BuySuccessSound, msg.Session, uid); //cha-ching!
//WD START
if (listing.SaleLimit != 0 && listing.SaleAmount > 0 && listing.PurchaseAmount >= listing.SaleLimit)
{
listing.SaleAmount = 0;
listing.Cost = listing.OldCost;
}
//WD END
UpdateUserInterface(buyer, uid, component);
}