2024-10-15 15:22:06 +03:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 00:51:58 +03:00
|
|
|
public int GetTotalCurrencyRecursive(EntityUid uid)
|
2024-10-15 15:22:06 +03:00
|
|
|
{
|
2024-10-26 18:18:30 +03:00
|
|
|
var ev = new CP14GetCurrencyEvent();
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2024-10-15 15:22:06 +03:00
|
|
|
|
2024-10-26 18:18:30 +03:00
|
|
|
return (int)(ev.Currency * ev.Multiplier);
|
2024-10-19 01:09:15 +03:00
|
|
|
}
|
2024-10-26 18:18:30 +03:00
|
|
|
}
|
2024-10-19 01:09:15 +03:00
|
|
|
|
2025-03-06 12:01:43 +03:00
|
|
|
public sealed class CP14GetCurrencyEvent(int currency = 0, int multiplier = 1) : EntityEventArgs
|
2024-10-26 18:18:30 +03:00
|
|
|
{
|
2025-03-06 12:01:43 +03:00
|
|
|
public HashSet<EntityUid> CheckedEntities = new();
|
|
|
|
|
public int Currency = currency;
|
|
|
|
|
public float Multiplier = multiplier;
|
2024-10-15 15:22:06 +03:00
|
|
|
}
|