+ RunUO 2.7 with initial TOL expansion support.
This commit is contained in:
parent
64272798c3
commit
7af0579875
41 changed files with 3181 additions and 499 deletions
|
|
@ -1,12 +1,15 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
|
|
@ -19,10 +22,140 @@ namespace Server.Accounting
|
|||
public static readonly TimeSpan YoungDuration = TimeSpan.FromHours( 40.0 );
|
||||
|
||||
public static readonly TimeSpan InactiveDuration = TimeSpan.FromDays( 180.0 );
|
||||
|
||||
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays( 30.0 );
|
||||
|
||||
private string m_Username, m_PlainPassword, m_CryptPassword, m_NewCryptPassword;
|
||||
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays(30.0);
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
CommandSystem.Register("ConvertCurrency", AccessLevel.Owner, ConvertCurrency);
|
||||
}
|
||||
|
||||
private static void ConvertCurrency(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.SendMessage(
|
||||
"Converting All Banked Gold from {0} to {1}. Please wait...",
|
||||
AccountGold.Enabled ? "checks and coins" : "account treasury",
|
||||
AccountGold.Enabled ? "account treasury" : "checks and coins");
|
||||
|
||||
NetState.Pause();
|
||||
|
||||
double found = 0.0, converted = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
BankBox box;
|
||||
List<Gold> gold;
|
||||
List<BankCheck> checks;
|
||||
long share = 0, shared;
|
||||
int diff;
|
||||
|
||||
foreach (var a in Accounts.GetAccounts().OfType<Account>().Where(a => a.Count > 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!AccountGold.Enabled)
|
||||
{
|
||||
share = (int)Math.Truncate((a.TotalCurrency / a.Count) * CurrencyThreshold);
|
||||
found += a.TotalCurrency * CurrencyThreshold;
|
||||
}
|
||||
|
||||
foreach (var m in a.m_Mobiles.Where(m => m != null))
|
||||
{
|
||||
box = m.FindBankNoCreate();
|
||||
|
||||
if (box == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AccountGold.Enabled)
|
||||
{
|
||||
foreach (var o in checks = box.FindItemsByType<BankCheck>())
|
||||
{
|
||||
found += o.Worth;
|
||||
|
||||
if (!a.DepositGold(o.Worth))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
converted += o.Worth;
|
||||
o.Delete();
|
||||
}
|
||||
|
||||
checks.Clear();
|
||||
checks.TrimExcess();
|
||||
|
||||
foreach (var o in gold = box.FindItemsByType<Gold>())
|
||||
{
|
||||
found += o.Amount;
|
||||
|
||||
if (!a.DepositGold(o.Amount))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
converted += o.Amount;
|
||||
o.Delete();
|
||||
}
|
||||
|
||||
gold.Clear();
|
||||
gold.TrimExcess();
|
||||
}
|
||||
else
|
||||
{
|
||||
shared = share;
|
||||
|
||||
while (shared > 0)
|
||||
{
|
||||
if (shared > 60000)
|
||||
{
|
||||
diff = (int)Math.Min(10000000, shared);
|
||||
|
||||
if (a.WithdrawGold(diff))
|
||||
{
|
||||
box.DropItem(new BankCheck(diff));
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = (int)Math.Min(60000, shared);
|
||||
|
||||
if (a.WithdrawGold(diff))
|
||||
{
|
||||
box.DropItem(new Gold(diff));
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
converted += diff;
|
||||
shared -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
box.UpdateTotals();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
NetState.Resume();
|
||||
|
||||
e.Mobile.SendMessage("Operation complete: {0:#,0} of {1:#,0} Gold has been converted in total.", converted, found);
|
||||
}
|
||||
|
||||
private string m_Username, m_Email, m_PlainPassword, m_CryptPassword, m_NewCryptPassword;
|
||||
private AccessLevel m_AccessLevel;
|
||||
private int m_Flags;
|
||||
private DateTime m_Created, m_LastLogin;
|
||||
|
|
@ -115,6 +248,15 @@ namespace Server.Accounting
|
|||
set { m_Username = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Account email address.
|
||||
/// </summary>
|
||||
public string Email
|
||||
{
|
||||
get { return m_Email; }
|
||||
set { m_Email = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Account password. Plain text. Case sensitive validation. May be null.
|
||||
/// </summary>
|
||||
|
|
@ -673,6 +815,8 @@ namespace Server.Accounting
|
|||
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
|
||||
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
|
||||
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
|
||||
|
||||
TotalCurrency = Utility.GetXMLDouble( Utility.GetText(node["totalCurrency"], "0" ), 0 );
|
||||
|
||||
m_Mobiles = LoadMobiles( node );
|
||||
m_Comments = LoadComments( node );
|
||||
|
|
@ -1100,6 +1244,10 @@ namespace Server.Accounting
|
|||
xml.WriteEndElement();
|
||||
}
|
||||
|
||||
xml.WriteStartElement("totalCurrency");
|
||||
xml.WriteString(XmlConvert.ToString(TotalCurrency));
|
||||
xml.WriteEndElement();
|
||||
|
||||
xml.WriteEndElement();
|
||||
}
|
||||
|
||||
|
|
@ -1203,5 +1351,242 @@ namespace Server.Accounting
|
|||
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
#region Gold Account
|
||||
/// <summary>
|
||||
/// This amount specifies the value at which point Gold turns to Platinum.
|
||||
/// By default, when 1,000,000,000 Gold is accumulated, it will transform
|
||||
/// into 1 Platinum.
|
||||
/// </summary>
|
||||
public static int CurrencyThreshold
|
||||
{
|
||||
get { return AccountGold.CurrencyThreshold; }
|
||||
set { AccountGold.CurrencyThreshold = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This amount represents the total amount of currency owned by the player.
|
||||
/// It is cumulative of both Gold and Platinum, the absolute total amount of
|
||||
/// Gold owned by the player can be found by multiplying this value by the
|
||||
/// CurrencyThreshold value.
|
||||
/// </summary>
|
||||
[CommandProperty(AccessLevel.Administrator, true)]
|
||||
public double TotalCurrency { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// This amount represents the current amount of Gold owned by the player.
|
||||
/// The value does not include the value of Platinum and ranges from
|
||||
/// 0 to 999,999,999 by default.
|
||||
/// </summary>
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public int TotalGold
|
||||
{
|
||||
get { return (int)Math.Floor((TotalCurrency - Math.Truncate(TotalCurrency)) * Math.Max(1.0, CurrencyThreshold)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This amount represents the current amount of Platinum owned by the player.
|
||||
/// The value does not include the value of Gold and ranges from
|
||||
/// 0 to 2,147,483,647 by default.
|
||||
/// One Platinum represents the value of CurrencyThreshold in Gold.
|
||||
/// </summary>
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public int TotalPlat { get { return (int)Math.Truncate(TotalCurrency); } }
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deposit the given amount of Gold and Platinum into this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to deposit.</param>
|
||||
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
|
||||
public bool DepositCurrency(double amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TotalCurrency += amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deposit the given amount of Gold into this account.
|
||||
/// If the given amount is greater than the CurrencyThreshold,
|
||||
/// Platinum will be deposited to offset the difference.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to deposit.</param>
|
||||
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
|
||||
public bool DepositGold(int amount)
|
||||
{
|
||||
return DepositCurrency(amount / Math.Max(1.0, CurrencyThreshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deposit the given amount of Gold into this account.
|
||||
/// If the given amount is greater than the CurrencyThreshold,
|
||||
/// Platinum will be deposited to offset the difference.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to deposit.</param>
|
||||
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
|
||||
public bool DepositGold(long amount)
|
||||
{
|
||||
return DepositCurrency(amount / Math.Max(1.0, CurrencyThreshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deposit the given amount of Platinum into this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to deposit.</param>
|
||||
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
|
||||
public bool DepositPlat(int amount)
|
||||
{
|
||||
return DepositCurrency(amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deposit the given amount of Platinum into this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to deposit.</param>
|
||||
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
|
||||
public bool DepositPlat(long amount)
|
||||
{
|
||||
return DepositCurrency(amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to withdraw the given amount of Platinum and Gold from this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to withdraw.</param>
|
||||
/// <returns>True if successful, false if balance was too low.</returns>
|
||||
public bool WithdrawCurrency(double amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (amount > TotalCurrency)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TotalCurrency -= amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to withdraw the given amount of Gold from this account.
|
||||
/// If the given amount is greater than the CurrencyThreshold,
|
||||
/// Platinum will be withdrawn to offset the difference.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to withdraw.</param>
|
||||
/// <returns>True if successful, false if balance was too low.</returns>
|
||||
public bool WithdrawGold(int amount)
|
||||
{
|
||||
return WithdrawCurrency(amount / Math.Max(1.0, CurrencyThreshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to withdraw the given amount of Gold from this account.
|
||||
/// If the given amount is greater than the CurrencyThreshold,
|
||||
/// Platinum will be withdrawn to offset the difference.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to withdraw.</param>
|
||||
/// <returns>True if successful, false if balance was too low.</returns>
|
||||
public bool WithdrawGold(long amount)
|
||||
{
|
||||
return WithdrawCurrency(amount / Math.Max(1.0, CurrencyThreshold));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to withdraw the given amount of Platinum from this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to withdraw.</param>
|
||||
/// <returns>True if successful, false if balance was too low.</returns>
|
||||
public bool WithdrawPlat(int amount)
|
||||
{
|
||||
return WithdrawCurrency(amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to withdraw the given amount of Platinum from this account.
|
||||
/// </summary>
|
||||
/// <param name="amount">Amount to withdraw.</param>
|
||||
/// <returns>True if successful, false if balance was too low.</returns>
|
||||
public bool WithdrawPlat(long amount)
|
||||
{
|
||||
return WithdrawCurrency(amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Gold for this account.
|
||||
/// </summary>
|
||||
/// <param name="gold">Gold value, Platinum exclusive</param>
|
||||
/// <param name="totalGold">Gold value, Platinum inclusive</param>
|
||||
public void GetGoldBalance(out int gold, out double totalGold)
|
||||
{
|
||||
gold = TotalGold;
|
||||
totalGold = TotalCurrency * Math.Max(1.0, CurrencyThreshold);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Gold for this account.
|
||||
/// </summary>
|
||||
/// <param name="gold">Gold value, Platinum exclusive</param>
|
||||
/// <param name="totalGold">Gold value, Platinum inclusive</param>
|
||||
public void GetGoldBalance(out long gold, out double totalGold)
|
||||
{
|
||||
gold = TotalGold;
|
||||
totalGold = TotalCurrency * Math.Max(1.0, CurrencyThreshold);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Platinum for this account.
|
||||
/// </summary>
|
||||
/// <param name="plat">Platinum value, Gold exclusive</param>
|
||||
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
|
||||
public void GetPlatBalance(out int plat, out double totalPlat)
|
||||
{
|
||||
plat = TotalPlat;
|
||||
totalPlat = TotalCurrency;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Platinum for this account.
|
||||
/// </summary>
|
||||
/// <param name="plat">Platinum value, Gold exclusive</param>
|
||||
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
|
||||
public void GetPlatBalance(out long plat, out double totalPlat)
|
||||
{
|
||||
plat = TotalPlat;
|
||||
totalPlat = TotalCurrency;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Gold and Platinum for this account.
|
||||
/// </summary>
|
||||
/// <param name="gold">Gold value, Platinum exclusive</param>
|
||||
/// <param name="totalGold">Gold value, Platinum inclusive</param>
|
||||
/// <param name="plat">Platinum value, Gold exclusive</param>
|
||||
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
|
||||
public void GetBalance(out int gold, out double totalGold, out int plat, out double totalPlat)
|
||||
{
|
||||
GetGoldBalance(out gold, out totalGold);
|
||||
GetPlatBalance(out plat, out totalPlat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total balance of Gold and Platinum for this account.
|
||||
/// </summary>
|
||||
/// <param name="gold">Gold value, Platinum exclusive</param>
|
||||
/// <param name="totalGold">Gold value, Platinum inclusive</param>
|
||||
/// <param name="plat">Platinum value, Gold exclusive</param>
|
||||
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
|
||||
public void GetBalance(out long gold, out double totalGold, out long plat, out double totalPlat)
|
||||
{
|
||||
GetGoldBalance(out gold, out totalGold);
|
||||
GetPlatBalance(out plat, out totalPlat);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue