AdvancedLogParser.InfoGather.CountpChestValue C# (CSharp) Method

CountpChestValue() public static method

public static CountpChestValue ( ) : void
return void
        public static void CountpChestValue()
        {
            currentLoader.status.Text = "Counting pChests...";
            Application.DoEvents();
            try
            {
                using (MySqlDataReader reader = MySqlHelper.ExecuteReader(ConnectionString, "SELECT * FROM alandsyu_live.logs WHERE Event='Persistant Storage, Opened'"))
                {
                    while (reader.Read())
                    {
                        uint characterId = (uint)reader.GetValue(2);
                        string desc = (string)reader.GetValue(4);
                        string chest = desc.Substring(18, desc.IndexOf(" contains") - 18);
                        int valueStart = desc.IndexOf(" worth ");
                        int valueEnd = desc.IndexOf(" total gp ");
                        valueStart += 7;
                        string value = desc.Substring(valueStart, valueEnd - valueStart);
                        uint chestValue = 0;
                        uint.TryParse(value, out chestValue);
                        Character ch = Characters.List[characterId];
                        if (ch.PersStorage.Keys.Contains(chest))
                        {
                            ch.PersStorage[chest] = chestValue;
                        }
                        else
                        {
                            ch.PersStorage.Add(chest, chestValue);
                        }
                    }
                }
            }
            catch { }
            foreach (Character ch in Characters.List.Values)
            {
                foreach (uint val in ch.PersStorage.Values)
                {
                    ch.Wealth += val;
                }
            }
        }

Usage Example

Beispiel #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            InfoGather.DatabasePassword = ConfigurationSettings.AppSettings["DatabasePassword"];
            InfoGather.DatabaseSchema   = ConfigurationSettings.AppSettings["DatabaseSchema"];
            InfoGather.DatabaseServer   = ConfigurationSettings.AppSettings["DatabaseServer"];
            InfoGather.DatabasePort     = ConfigurationSettings.AppSettings["DatabasePort"];
            InfoGather.DatabaseUser     = ConfigurationSettings.AppSettings["DatabaseUser"];
            InfoGather.BuildConnectionString();
            Players.ListByPlayerId = new Dictionary <uint, Player>();
            Players.ListByKey      = new Dictionary <string, Player>();
            Characters.List        = new Dictionary <uint, Character>();
            Logs.AdvancementAlerts = new Dictionary <uint, Log>();
            Logs.DeathAlerts       = new Dictionary <uint, Log>();
            Logs.EnforcementAlerts = new Dictionary <uint, Log>();
            Logs.RecentLogins      = new Dictionary <uint, Log>();
            Servers.List           = new Dictionary <uint, Server>();
            if (InfoGather.GetPlayers())
            {
                InfoGather.GetCharacters();
                InfoGather.CountBankValue();
                InfoGather.CountpChestValue();
                InfoGather.GetAlerts();
                InfoGather.GetLogins();
                InfoGather.IdentifyLogins();
                InfoGather.GetDMTime();
                InfoGather.currentLoader.Close();
                InfoGather.currentLoader.Dispose();
                if (ServerFocus >= 0)
                {
                    foreach (Server srv in Servers.List.Values)
                    {
                        if (srv.ServerId == Math.Abs(ServerFocus))
                        {
                            Application.Run(new ServerView(srv));
                        }
                    }
                }
                else
                {
                    foreach (Server srv in Servers.List.Values)
                    {
                        new ServerView(srv).Show();
                    }
                    new ServerView(null).Show();
                    Application.Run(new PrimaryDisplay());
                }
            }
        }