Изменение отображения скидок в аплинке (#266)
* Better sales * Sale item restrictions
This commit is contained in:
@@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user