private static void ScaleSavings_OnCommand(CommandEventArgs e) { SavingsOption option = SavingsOption.Both; int percent = 100; if (1 <= e.Length) { string str = e.GetString(0).ToLower(); if (str.Equals("-g")) { option = SavingsOption.Gold; } else if (str.Equals("-t") && EnableTokens) { option = SavingsOption.Tokens; } try { percent = Math.Abs(int.Parse(e.GetString(e.Length - 1))); } catch (Exception exc) { World.Broadcast(59, true, "Error - {0}", exc.Message); percent = -1; } } if (percent >= 0) { ScaleSavingsAccounts(e.Mobile, option, ((double)percent) / 100.00); } }
private static void ScaleSavingsAccounts(Mobile from, SavingsOption option, double percent) { ArrayList items = new ArrayList(World.Items.Values); int accountsScaled = 0; string optionText = option == SavingsOption.Both ? "gold & tokens" : option == SavingsOption.Gold ? "gold" : "tokens"; foreach (Item i in items) { Arya.Savings.SavingsAccount sa = i as Arya.Savings.SavingsAccount; if (null != sa) { accountsScaled++; if (option == SavingsOption.Both || option == SavingsOption.Gold) { sa.Gold = (int)(((double)sa.Gold) * percent); } if (option == SavingsOption.Both || option == SavingsOption.Tokens) { sa.Tokens = (int)(((double)sa.Tokens) * percent); } } } World.Broadcast(59, true, "Scaling complete, {0} accounts ({1}) scaled by {2}%", accountsScaled, optionText, percent * 100); }
private static void ScaleSavingsAccounts( Mobile from, SavingsOption option, double percent ) { ArrayList items = new ArrayList( World.Items.Values ); int accountsScaled = 0; string optionText = option == SavingsOption.Both ? "gold & tokens" : option == SavingsOption.Gold ? "gold" : "tokens"; foreach ( Item i in items ) { Arya.Savings.SavingsAccount sa = i as Arya.Savings.SavingsAccount; if ( null != sa ) { accountsScaled++; if ( option == SavingsOption.Both || option == SavingsOption.Gold ) sa.Gold = (int)(((double)sa.Gold) * percent); if ( option == SavingsOption.Both || option == SavingsOption.Tokens ) sa.Tokens = (int)(((double)sa.Tokens) * percent); } } World.Broadcast( 59, true, "Scaling complete, {0} accounts ({1}) scaled by {2}%", accountsScaled, optionText, percent * 100 ); }