Пример #1
0
        // st has been loaded from a file, and is the same spawn as "this" one.

        // Glean all useful information.

        public void Merge(SPAWNTIMER st)

        {
            LogLib.WriteLine("Merging spawn timers:", LogLevel.Debug);

            LogLib.WriteLine($"  Old: {GetAsString()}", LogLevel.Debug);

            LogLib.WriteLine($"  Other: {st.GetAsString()}", LogLevel.Debug);

            SpawnCount = st.SpawnCount; // usually makes it > 1

            SpawnTimer = st.SpawnTimer; // woot!

            //this.SpawnTimer =   // NOT!

            if (KillTimeDT == DateTime.MinValue) // woot!

            {
                KillTimeStr = st.KillTimeStr;

                TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                NextSpawnDT = KillTimeDT.Add(Diff);

                NextSpawnStr = NextSpawnDT.ToLongTimeString() + " " + NextSpawnDT.ToShortDateString();
            }
            else
            {
                // Enable the timer to start on first kill

                if (st.SpawnTimer > 10)

                {
                    TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                    if (DateTime.Now.Subtract(Diff) < st.SpawnTimeDT)

                    {
                        SpawnTimeDT = st.SpawnTimeDT;

                        SpawnTimeStr = st.SpawnTimeStr;
                    }

                    if (DateTime.Now.Subtract(Diff) > st.KillTimeDT)

                    {
                        KillTimeDT = DateTime.MinValue;
                    }
                    else
                    {
                        KillTimeDT = st.KillTimeDT;

                        KillTimeStr = st.KillTimeStr;
                    }

                    if (DateTime.Now > st.NextSpawnDT)

                    {
                        NextSpawnDT = DateTime.MinValue;

                        NextSpawnStr = "";
                    }
                    else
                    {
                        NextSpawnDT = st.NextSpawnDT;

                        NextSpawnStr = st.NextSpawnStr;

                        KillTimeDT = st.KillTimeDT.Subtract(Diff);
                    }
                }
            }

            int namecount = 1;

            foreach (var name in st.AllNames.Split(','))
            {
                var bname = RegexHelper.TrimName(name);
                if (AllNames.IndexOf(bname) < 0 && namecount < 11)
                {
                    AllNames += ", " + bname;
                    namecount++;
                }
            }

            // update last spawn name to be what looks like named mobs
            foreach (var tname in AllNames.Split(','))
            {
                var mname = RegexHelper.TrimName(tname);
                if (RegexHelper.RegexMatch(mname))
                {
                    LastSpawnName = mname;
                    break;
                }
            }

            listNeedsUpdate = true;
            LogLib.WriteLine($"  New: {GetAsString()}", LogLevel.Debug);
        }
Пример #2
0
        // st has been loaded from a file, and is the same spawn as "this" one.

        // Glean all useful information.

        public void Merge(SPAWNTIMER st)

        {
            LogLib.WriteLine("Merging spawn timers:", LogLevel.Debug);



            LogLib.WriteLine("  Old: " + GetAsString(), LogLevel.Debug);

            LogLib.WriteLine("  Other: " + st.GetAsString(), LogLevel.Debug);



            this.SpawnCount = st.SpawnCount; // usually makes it > 1

            this.SpawnTimer = st.SpawnTimer; // woot!

            //this.SpawnTimer =   // NOT!

            if (this.KillTimeDT == DateTime.MinValue) // woot!

            {
                this.KillTimeStr = st.KillTimeStr;



                TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                NextSpawnDT = KillTimeDT.Add(Diff);

                NextSpawnStr = NextSpawnDT.ToLongTimeString() + " " + NextSpawnDT.ToShortDateString();
            }

            else

            {
                // Enable the timer to start on first kill

                if (st.SpawnTimer > 10)

                {
                    //TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                    //this.KillTimeDT = this.SpawnTimeDT.Subtract(Diff);

                    TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                    if (DateTime.Now.Subtract(Diff) < st.SpawnTimeDT)

                    {
                        this.SpawnTimeDT = st.SpawnTimeDT;

                        this.SpawnTimeStr = st.SpawnTimeStr;
                    }



                    if (DateTime.Now.Subtract(Diff) > st.KillTimeDT)

                    {
                        this.KillTimeDT = DateTime.MinValue;
                    }

                    else

                    {
                        this.KillTimeDT = st.KillTimeDT;

                        this.KillTimeStr = st.KillTimeStr;
                    }

                    //this.KillTimeStr = "";

                    if (DateTime.Now > st.NextSpawnDT)

                    {
                        this.NextSpawnDT = DateTime.MinValue;

                        this.NextSpawnStr = "";
                    }

                    else

                    {
                        this.NextSpawnDT = st.NextSpawnDT;

                        this.NextSpawnStr = st.NextSpawnStr;

                        this.KillTimeDT = st.KillTimeDT.Subtract(Diff);
                    }
                }
            }

            int namecount = 1;

            string[] names = st.AllNames.Split(',');

            foreach (string name in names)

            {
                string bname = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                if (AllNames.IndexOf(bname) < 0)

                {
                    if (namecount < 11)

                    {
                        AllNames += ", " + bname;

                        namecount++;
                    }
                }
            }

            // update last spawn name to be what looks like named mobs
            string[] bnames = AllNames.Split(',');
            foreach (string tname in bnames)
            {
                string mname = Regex.Replace(tname.Replace("_", " "), "[0-9]", "").Trim();
                if (Regex.IsMatch(mname, "^[A-Z#]"))
                {
                    this.LastSpawnName = mname;
                    break;
                }
            }

            listNeedsUpdate = true;



            LogLib.WriteLine("  New: " + GetAsString(), LogLevel.Debug);
        }