Files
crystall-punk-14/Content.Shared/_CP14/Currency/CP14SharedCurrencySystem.cs
Ed c1acf81541 NewTrade (#969)
* trading portal replace traveling storeship

* clean up content

* clean up content 2

* seel and buy realization

* fixes

* Update migration.yml

* Update migration.yml

* Update dev_map.yml

* Update dev_map.yml

* thats work correctly now

* bugfies and visual

* factions

* faction restruct + name reduce

* unnesting sell cargo positions

* unnesting cargo positions

* more cargo content

* Update buy.yml

* improve tradeportal visual

* Update migration.yml

* Bank ad Commandant removal

* merchant objectives

* finish

* clean up content

* Update migration.yml

* fix goal calculation

* Update comoss.yml

* Update dev_map.yml
2025-03-06 12:01:43 +03:00

55 lines
1.6 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)
{
var ev = new CP14GetCurrencyEvent();
RaiseLocalEvent(uid, ev);
return (int)(ev.Currency * ev.Multiplier);
}
}
public sealed class CP14GetCurrencyEvent(int currency = 0, int multiplier = 1) : EntityEventArgs
{
public HashSet<EntityUid> CheckedEntities = new();
public int Currency = currency;
public float Multiplier = multiplier;
}