Files
crystall-punk-14/Content.Shared/_CP14/Currency/CP14SharedCurrencySystem.cs
Ed d259191d3d Cargo system (#487)
* simple storeship arriving

* pupu

* ship cycling

* buy positions prototypes

* i hate UI

* PriceControl

* second tab ui

* baloon! pallets!

* update shop in town

* setup billboard timer

* split to sell and buy categories

* renaming gaming

* actually selling

* fix infinity selling

* improve timer

* move description too rigt part UI

* bar selling

* iron cabinet

* purge currency categories

* remove town balance, add money box

* special proposal, FTLImmune anchor

* fix UI

* remove tests buying

* Update CP14StoreWindow.xaml.cs

* currency converter

* currency clean up

* Update CP14CargoSystem.cs

* clean up part 2

* rider petpet

* coins audio

* coin improvment

* Update coins.yml

* translate

* more coins roundstart

* Update wallet.yml

* Update wallet.yml

* generate coin problem fix

* refactor proto reading

* fixes

* huh

* shuttle logshit fix, add to tavern map

* Update CP14StationTravelingStoreShipTargetComponent.cs
2024-10-15 15:22:06 +03:00

55 lines
1.5 KiB
C#

using System.Text;
using Content.Shared.Stacks;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.Currency;
public partial class CP14SharedCurrencySystem : EntitySystem
{
public static readonly KeyValuePair<EntProtoId, int> CP = new("CP14CopperCoin1", 1);
public static readonly KeyValuePair<EntProtoId, int> SP = new("CP14SilverCoin1", 10);
public static readonly KeyValuePair<EntProtoId, int> GP = new("CP14GoldCoin1", 100);
public static readonly KeyValuePair<EntProtoId, int> PP = new("CP14PlatinumCoin1", 1000);
public string GetCurrencyPrettyString(int currency)
{
var total = currency;
if (total <= 0)
return string.Empty;
var gp = total / 100;
total %= 100;
var sp = total / 10;
total %= 10;
var cp = total;
var sb = new StringBuilder();
if (gp > 0)
sb.Append( " " + Loc.GetString("cp14-currency-examine-gp", ("coin", gp)));
if (sp > 0)
sb.Append( " " + Loc.GetString("cp14-currency-examine-sp", ("coin", sp)));
if (cp > 0)
sb.Append( " " + Loc.GetString("cp14-currency-examine-cp", ("coin", cp)));
return sb.ToString();
}
public int GetTotalCurrency(EntityUid uid, CP14CurrencyComponent? currency = null)
{
if (!Resolve(uid, ref currency))
return 0;
var total = currency.Currency;
if (TryComp<StackComponent>(uid, out var stack))
{
total *= stack.Count;
}
return total;
}
}