servuo/Scripts/Services/UltimaStore/SystemConfig.cs

86 lines
2.8 KiB
C#
Raw Permalink Normal View History

2018-06-17 21:29:08 -07:00
using Server.Engines.Points;
2020-04-14 14:04:34 -04:00
using System;
2018-06-17 21:29:08 -07:00
namespace Server.Engines.UOStore
{
public enum CurrencyType
{
None,
Sovereigns,
2018-06-17 21:29:08 -07:00
Gold,
PointsSystem,
Custom
}
public delegate int CustomCurrencyHandler(Mobile m, int consume);
2018-06-17 21:29:08 -07:00
public static class Configuration
{
public static bool Enabled { get; set; }
public static string Website { get; set; }
2018-06-17 21:29:08 -07:00
/// <summary>
/// A hook to allow handling of custom currencies.
/// This implementation should be treated as such;
/// If 'consume' is less than zero, return the currency total.
/// Else deduct from the currency total, return the amount consumed.
2018-06-17 21:29:08 -07:00
/// </summary>
public static CustomCurrencyHandler ResolveCurrency { get; set; }
public static CurrencyType CurrencyImpl { get; set; }
public static string CurrencyName { get; set; }
public static bool CurrencyDisplay { get; set; }
2020-04-14 14:04:34 -04:00
public static PointsType PointsImpl { get; set; }
public static double CostMultiplier { get; set; }
public static int CartCapacity { get; set; }
static Configuration()
2018-06-17 21:29:08 -07:00
{
Enabled = Config.Get("Store.Enabled", true);
Website = Config.Get("Store.Website", "https://uo.com/ultima-store/");
2018-06-17 21:29:08 -07:00
ResolveCurrency = Config.GetDelegate("Store.ResolveCurrency", (CustomCurrencyHandler)null);
CurrencyImpl = Config.GetEnum("Store.CurrencyImpl", CurrencyType.Sovereigns);
CurrencyName = Config.Get("Store.CurrencyName", "Sovereigns");
CurrencyDisplay = Config.Get("Store.CurrencyDisplay", true);
PointsImpl = Config.GetEnum("Store.PointsImpl", PointsType.None);
2018-06-17 21:29:08 -07:00
CostMultiplier = Config.Get("Store.CostMultiplier", 1.0);
CartCapacity = Config.Get("Store.CartCapacity", 10);
2018-06-17 21:29:08 -07:00
}
2020-04-14 14:04:34 -04:00
public static int GetCustomCurrency(Mobile m)
{
if (ResolveCurrency != null)
{
return ResolveCurrency(m, -1);
}
2018-06-17 21:29:08 -07:00
m.SendMessage(1174, "Currency is not set up for this system. Contact a shard administrator.");
Utility.WriteConsoleColor(ConsoleColor.Red, "[Ultima Store]: No custom currency method has been implemented.");
2020-04-14 14:04:34 -04:00
return 0;
}
public static int DeductCustomCurrecy(Mobile m, int amount)
2018-06-17 21:29:08 -07:00
{
if (ResolveCurrency != null)
{
return ResolveCurrency(m, amount);
}
m.SendMessage(1174, "Currency is not set up for this system. Contact a shard administrator.");
2018-06-17 21:29:08 -07:00
Utility.WriteConsoleColor(ConsoleColor.Red, "[Ultima Store]: No custom currency deduction method has been implemented.");
2020-04-14 14:04:34 -04:00
return 0;
2018-06-17 21:29:08 -07:00
}
}
2018-06-18 08:30:32 -07:00
}