Ejemplo n.º 1
0
        public Spawntimer(string str)
        {
            var parts = str.Split(';');

            SpawnLoc = parts[0];

            SpawnCount = int.Parse(parts[1]);

            SpawnTimer = int.Parse(parts[2]);

            SpawnTimeStr = parts[3];

            SpawnTimeDT = GetDateTime(SpawnTimeStr);

            KillTimeStr = parts[4];

            KillTimeDT = GetDateTime(KillTimeStr);

            NextSpawnStr = parts[5];

            NextSpawnDT = GetDateTime(NextSpawnStr);

            LastSpawnName = parts[6];

            AllNames = parts[7];

            // split up the All Names, and parse out spawn numbers in parenthesis
            _ = AllNames.Split(',').GetUpperBound(0);

            X = float.Parse(parts[8]);

            Y = float.Parse(parts[9]);

            Z = float.Parse(parts[10]);
        }
Ejemplo n.º 2
0
        public SPAWNTIMER(string str)

        {
            string[] parts = str.Split(';');

            SpawnLoc = parts[0];

            SpawnCount = int.Parse(parts[1]);

            SpawnTimer = int.Parse(parts[2]);

            SpawnTimeStr = parts[3];

            if (SpawnTimeStr.Length > 0)
            {
                SpawnTimeDT = Convert.ToDateTime(SpawnTimeStr);
            }

            KillTimeStr = parts[4];

            if (KillTimeStr.Length > 0)
            {
                KillTimeDT = Convert.ToDateTime(KillTimeStr);
            }

            NextSpawnStr = parts[5];

            if (NextSpawnStr.Length > 0)
            {
                NextSpawnDT = Convert.ToDateTime(NextSpawnStr);
            }

            LastSpawnName = parts[6];

            AllNames = parts[7];

            // split up the All Names, and parse out spawn numbers in parenthesis
            string[] subparts = AllNames.Split(',');

            int jj = subparts.GetUpperBound(0);

            X = float.Parse(parts[8]);

            Y = float.Parse(parts[9]);

            Z = float.Parse(parts[10]);
        }
Ejemplo n.º 3
0
        private StringBuilder StBuilder()
        {
            StringBuilder spawnTimer = new StringBuilder();

            spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

            string names_to_add = "Names encountered: ";

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

            int namecount = 0;

            NameCount(spawnTimer, ref names_to_add, names, ref namecount);

            if (names_to_add.Length > 0)
            {
                spawnTimer.Append(names_to_add);
            }

            return(spawnTimer);
        }
Ejemplo n.º 4
0
 public static void AssureIsName(string name)
 {
     if (IsName(name) == false)
     {
         string msg = name + " is not a keyword keywords are /n" + string.Join("\n\t", AllNames.ToArray());
         throw new System.Exception(msg);
     }
 }
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        for (int i = 0; i < amountLevel; i++)
        {
            CreateDirectory(i);
            if (Exists("SaveFiles", i))
            {
                NamesByteSavefile saveFile = LoadNames(i);
                names.Add((AllNames)ByteArrayToObject(saveFile.saveFile));
                if (i < allHighscore.Count)
                {
                    if (allHighscore[i] == null)
                    {
                        allHighscore[i] = new AllHighscore();
                    }
                }
                else
                {
                    allHighscore.Add(new AllHighscore());
                }

                if (names[i] == null)
                {
                    names[i] = new AllNames();
                }
                allHighscore[i].names = names[i].names;

                for (int o = 0; o < names[i].names.Count; o++)
                {
                    if (Exists(names[i].names[o], i))
                    {
                        if (o < allHighscore[i].scores.Count)
                        {
                            allHighscore[i].scores[o] = LoadScore(names[i].names[o], i);
                        }
                        else
                        {
                            allHighscore[i].scores.Add(LoadScore(names[i].names[o], i));
                        }

                        if (o < allHighscore[i].levelPlayed.Count)
                        {
                            Highscore temp = LoadScore(names[i].names[o], i);
                            allHighscore[i].levelPlayed[o] = temp.level;
                        }
                        else
                        {
                            Highscore temp = LoadScore(names[i].names[o], i);
                            allHighscore[i].levelPlayed.Add(temp.level);
                        }
                    }
                }
            }
            else
            {
                if (i < allHighscore.Count)
                {
                    if (allHighscore[i] == null)
                    {
                        allHighscore[i] = new AllHighscore();
                    }
                }
                else
                {
                    allHighscore.Add(new AllHighscore());
                }
                if (i < names.Count)
                {
                    names[i] = new AllNames();
                }
                else
                {
                    names.Add(new AllNames());
                }
            }

            if (File.Exists(Application.persistentDataPath + "/Deaths" + "/SavedDeaths_" + (i + 1).ToString() + ".xml"))
            {
                if (i < deaths.Count)
                {
                    deaths[i] = LoadDeaths(i);
                }
                else
                {
                    deaths.Add(LoadDeaths(i));
                }
            }
            else
            {
                if (i < deaths.Count)
                {
                    deaths[i] = new DeathSaveFile();
                }
                else
                {
                    deaths.Add(new DeathSaveFile());
                }
            }
        }
    }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            using (StoreApplicationContext dbContext = CreateDbContext())
                using (IStoreRepository storeRepository = new StoreRepository(dbContext))
                {
                    while (true)
                    {
                        try
                        {
                            _logger.Info($"Saving");
                            storeRepository.Save();
                        }
                        catch (DbUpdateException ex)
                        {
                            _logger.Error($"Failed to Save");
                            Console.WriteLine(ex.Message);
                        }

                        Console.WriteLine();
                        Console.WriteLine("1:\tDisplay All Names");
                        Console.WriteLine("2:\tSearch By Last Name");
                        Console.WriteLine("3:\tDisplay Order History of each location");
                        Console.WriteLine("4:\tQuit");
                        Console.WriteLine();

                        int                              input = IntValidation(1, 4);
                        string                           input2;
                        var                              count = 0;
                        Customer                         customer;
                        Product                          ProductValue;
                        var                              products  = storeRepository.DisplayProducts();
                        var                              products2 = products.ToList();
                        List <OrderDetails>              orderDetails;
                        IEnumerable <Order>              OrderValue;
                        IEnumerable <Customer>           AllNames;
                        IEnumerable <Inventories>        LocationInventory;
                        IEnumerable <ProductCat>         prodCategories;
                        IEnumerable <Product>            getRecoProduct;
                        IEnumerable <ComponentInventory> componentInventories;
                        List <Product>                   Cart;
                        List <Product>                   ComponentCart;
                        decimal                          Total = 0;
                        int                              tempOrderId;
                        Dictionary <string, int>         HashProducts;
                        HashSet <Product>                HashLoop;
                        int                              inventoryId;
                        switch (input)
                        {
                        case 1:
                            AllNames = storeRepository.GetNames();
                            Console.WriteLine();
                            count = 0;
                            _logger.Info($"Choosing Customer to Order for");
                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }

                            if (count == 0)
                            {
                                Console.WriteLine("There are 0 Customers");
                                break;
                            }
                            var AllNamesList = AllNames.ToList();

                            Console.WriteLine($"Choose Customer to interact with or Press {AllNames.Count()} to go back");

                            input = IntValidation(0, AllNames.Count());
                            if (input != AllNames.Count())
                            {
                                customer   = AllNames.ElementAt(input);
                                OrderValue = storeRepository.GetOrders(customer);

                                _logger.Info($"Displaying orders for {customer.FName} {customer.LName} {customer.CustomerId}");
                                List <OrderDetails> temp2 = new List <OrderDetails>();
                                while (true)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Do you want to view and sort Customer Order History?");
                                    Console.WriteLine("1:\tYes");
                                    Console.WriteLine("2:\tNo");
                                    Console.WriteLine();
                                    input = IntValidation(1, 2);
                                    if (input == 2)
                                    {
                                        break;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine("What do you want to sort by?");
                                    Console.WriteLine("1:\tEarliest");
                                    Console.WriteLine("2:\tLatest");
                                    Console.WriteLine("3:\tCheapest");
                                    Console.WriteLine("4:\tExpensive");
                                    Console.WriteLine();
                                    input = IntValidation(1, 4);
                                    List <Order> orderList = OrderValue.ToList();
                                    if (input == 1)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Early);
                                    }
                                    else if (input == 2)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Late);
                                    }
                                    else if (input == 3)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Cheap);
                                    }
                                    else if (input == 4)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Expensive);
                                    }
                                    count = 0;
                                    foreach (var x in orderList)
                                    {
                                        Console.WriteLine();
                                        Console.WriteLine($"Order {count}:\tTime:{x.TimeStamp}  \nStore: {x.Location.Name}\tCost: ${x.TotalAmount}");
                                        orderDetails = storeRepository.GetOrderDetails(x).ToList();
                                        temp2.AddRange(orderDetails);
                                        var y = orderDetails;
                                        foreach (var z in y)
                                        {
                                            var i = Order.GetProductName(products.ToList(), z.ProductId);
                                            Console.WriteLine($"\t{i}\tAmount:{z.Quantity} ");
                                        }
                                        count++;
                                    }
                                }
                                Cart = new List <Product>();

                                LocationInventory = storeRepository.GetInventories(customer);
                                List <Inventories> LocationInventoryList = LocationInventory.ToList();
                                Total = 0;
                                while (true)
                                {
                                    count    = 4;
                                    products = storeRepository.DisplayProducts();
                                    Console.WriteLine();
                                    foreach (var x in products)
                                    {
                                        if (count % 3 == 0)
                                        {
                                            Console.WriteLine($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        else
                                        {
                                            Console.Write($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        count++;
                                    }
                                    _logger.Info($"Get Recommended Items");
                                    Product product = new Product();

                                    List <Product> tempP     = new List <Product>();
                                    List <Order>   orderList = OrderValue.ToList();
                                    foreach (var x in orderList)
                                    {
                                        var y = storeRepository.GetOrderDetails(x).ToList();
                                        foreach (var z in y)
                                        {
                                            foreach (var t in products)
                                            {
                                                if (t.ProductId == z.ProductId)
                                                {
                                                    tempP.Add(t);
                                                }
                                            }
                                        }
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine("Recommended Items:\n");
                                    var getStuff = dbContext.Products.Where(x => x.ProductCategoryId == tempP[tempP.Count - 1].CategoryId).ToList();
                                    count = 0;
                                    foreach (var x in getStuff)
                                    {
                                        if (count > 2)
                                        {
                                            break;
                                        }
                                        Console.Write($"   {x.ProductName}");
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine($"Add Product to cart or Enter {products.Count()} to purchase it\n");
                                    Console.WriteLine($"Purchasing from Default Location: {customer.DefaultLocation.Name}");
                                    Console.WriteLine($"There are {Cart.Count} Items in cart for a total of ${Total}");
                                    input = IntValidation(0, products.Count());
                                    _logger.Info($"Choose item to add to cart");
                                    if (input != products.Count())
                                    {
                                        ProductValue = products.ElementAt(input);
                                        _logger.Info($"Item chosen = {ProductValue.ProductName}");
                                        if (ProductValue.HasComponents)
                                        {
                                            componentInventories = storeRepository.GetComponents(ProductValue);
                                            ComponentCart        = new List <Product>();
                                            foreach (var x in componentInventories)
                                            {
                                                foreach (var y in products2)
                                                {
                                                    if (x.ComponentProductId == y.ProductId)
                                                    {
                                                        ComponentCart.Add(y);
                                                    }
                                                }
                                            }
                                            List <Inventories> tempInv = new List <Inventories>();
                                            tempInv.AddRange(LocationInventoryList);
                                            Decimal        tempTotal = Total;
                                            List <Product> tempCart  = new List <Product>();
                                            tempCart.AddRange(Cart);

                                            foreach (var x in ComponentCart)
                                            {
                                                if (Order.CheckCart(x, LocationInventoryList))
                                                {
                                                    Console.WriteLine($"\t{x.ProductName} has been added to cart");
                                                    Total += x.ProductCost;
                                                    Cart.Add(x);
                                                }
                                                else
                                                {
                                                    LocationInventoryList.Clear();
                                                    LocationInventoryList.AddRange(tempInv);
                                                    Cart.Clear();
                                                    Cart.AddRange(tempCart);
                                                    Total = tempTotal;

                                                    Console.WriteLine();
                                                    Console.WriteLine("Inventory is out");

                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (Order.CheckCart(ProductValue, LocationInventoryList))
                                            {
                                                Console.WriteLine($"\t{ProductValue.ProductName} has been added to cart");
                                                Total += ProductValue.ProductCost;
                                                Cart.Add(ProductValue);
                                            }
                                            else
                                            {
                                                Console.WriteLine();
                                                Console.WriteLine("Inventory is out");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Cart.Count == 0)
                                        {
                                            Console.WriteLine();
                                            Console.WriteLine("The cart is empty, so nothing was purchased!");
                                            Console.WriteLine();
                                            break;
                                        }
                                        else
                                        {
                                            //SA.Orders(ConsumerId,StoreId,TotalAmount)
                                            Order newOrder = new Order
                                            {
                                                CustomerId  = customer.CustomerId,
                                                StoreId     = customer.DefaultLocation.LocationId,
                                                TotalAmount = Total,
                                                Location    = customer.DefaultLocation,
                                                Customer    = customer,
                                                TimeStamp   = DateTime.Now,
                                            };
                                            storeRepository.AddOrder(newOrder, customer.DefaultLocation, customer);
                                            try
                                            {
                                                _logger.Info($"Saving");
                                                storeRepository.Save();
                                            }
                                            catch (DbUpdateException ex)
                                            {
                                                _logger.Error($"Failed to Save");
                                                Console.WriteLine(ex.Message);
                                            }
                                            Thread.Sleep(50);
                                            tempOrderId  = dbContext.Orders.OrderByDescending(y => y.OrderId).Select(a => a.OrderId).FirstOrDefault();
                                            HashProducts = new Dictionary <string, int>();
                                            HashLoop     = new HashSet <Product>();
                                            foreach (var x in Cart)
                                            {
                                                if (HashProducts.ContainsKey(x.ProductName))
                                                {
                                                    HashProducts[x.ProductName] += 1;
                                                }
                                                else
                                                {
                                                    HashProducts.Add(x.ProductName, 1);
                                                }
                                                HashLoop.Add(x);
                                            }
                                            count = 0;
                                            foreach (var x in HashLoop)
                                            {
                                                count++;
                                                Console.WriteLine(count);
                                                OrderDetails newOrderDetails = new OrderDetails
                                                {
                                                    OrderId   = tempOrderId,
                                                    ProductId = x.ProductId,
                                                    Quantity  = HashProducts[x.ProductName],
                                                };

                                                storeRepository.AddOrderDetails(newOrderDetails, newOrder, x);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                                inventoryId = dbContext.Inventory.Where(y => y.ProductId == x.ProductId && y.StoreId == customer.DefaultLocation.LocationId).Select(a => a.InventoryId).First();
                                                Thread.Sleep(50);
                                                Inventories inventories = new Inventories
                                                {
                                                    Quantity    = Order.getInventory(LocationInventoryList, x.ProductId),
                                                    StoreId     = customer.DefaultLocation.LocationId,
                                                    ProductId   = x.ProductId,
                                                    InventoryId = inventoryId,
                                                };
                                                storeRepository.UpdateInventory(inventories);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                            break;

                        case 2:
                            _logger.Info($"Search for name name");
                            do
                            {
                                Console.WriteLine("Please enter Full/Parital Last Name to search by");
                                input2 = Console.ReadLine();
                                if (input2.Length < 200 && input2.Length > 0)
                                {
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Please enter word with 1 - 199 characters, ");
                                }
                            } while (true);

                            AllNames = storeRepository.GetNames(input2);
                            Console.WriteLine();
                            count = 0;

                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }
                            if (count == 0)
                            {
                                Console.WriteLine("Your search had 0 results");
                            }
                            break;

                        case 3:
                            _logger.Info($"Display All orders by each location");
                            var n = storeRepository.GetOrders().ToList();
                            var p = n.OrderByDescending(k => k.Location.LocationId);


                            foreach (var a in p)
                            {
                                var    b    = dbContext.Consumer.ToList();
                                var    z    = dbContext.Store.ToList();
                                string name = "John Albert";
                                foreach (var m in z)
                                {
                                    if (m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.ConsumerId).FirstOrDefault() == a.CustomerId)
                                    {
                                        name = m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Fname).FirstOrDefault() + " " + m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Lname).FirstOrDefault();
                                    }
                                }
                                Console.WriteLine($"{ a.Location.Name}");
                                Console.WriteLine($"\t{name}\t{a.TimeStamp}\t{a.TotalAmount}");
                                Console.WriteLine();
                            }
                            break;

                        case 4:
                            _logger.Info($"Exiting Application");
                            return;
                        }
                    }
                }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        // A true re-spawn has been detected

        public string ReSpawn(string name)

        {
            string log = "";

            try

            {
                SpawnCount++;

                // if it looks like a named, leave last spawn name alone
                if (LastSpawnName.Length > 0)
                {
                    // See if mob name starts with capital letter or #
                    if (!RegexHelper.RegexMatch(LastSpawnName))
                    {
                        LastSpawnName = name;
                    }
                }
                else
                {
                    LastSpawnName = name;
                }
                NextSpawnStr = "";

                NextSpawnDT = DateTime.MinValue;

                SpawnTimeDT = DateTime.Now;

                SpawnTimeStr = SpawnTimeDT.ToLongTimeString() + " " + SpawnTimeDT.ToShortDateString();

                // put name at beginning of list of AllNames

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

                AllNames = newnames;

                if (KillTimeDT != DateTime.MinValue)

                {
                    // This mob has been killed already - now we can calculate

                    // the respawn time

                    int last_Timer = SpawnTimer;

                    TimeSpan Diff = SpawnTimeDT.Subtract(KillTimeDT);

                    SpawnTimer = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds;

                    if (Settings.Instance.MaxLogLevel > 0)
                    {
                        string spawnTimer = $"{Diff.Hours:00}:{Diff.Minutes:00}:{Diff.Seconds:00}";

                        log = $"Setting Timer for Spawn: {SpawnLoc} Name: {name} Count: {SpawnCount} Last Kill Time: {KillTimeStr} Current Spawn Time: {SpawnTimeStr} Timer: {spawnTimer} = {SpawnTimer} secs Old: {last_Timer} secs";
                    }

                    // ... and forget about the kill

                    KillTimeDT = DateTime.MinValue;

                    KillTimeStr = "";
                }
            }
            catch (Exception ex) { LogLib.WriteLine("Error updating Timer SPAWNTIMER for " + name + ": ", ex); }

            listNeedsUpdate = true;

            return(log);
        }
Ejemplo n.º 9
0
 public void AddName(PYNamesManager.NameData name)
 {
     AllNames.Add(name);
 }
Ejemplo n.º 10
0
 public int GetClassId()
 {
     return(AllNames.Find(name => name.Name == LabelText).ClassId);
 }
Ejemplo n.º 11
0
        // A true re-spawn has been detected

        public string ReSpawn(string name)

        {
            string log = "";

            try

            {
                this.SpawnCount++;

                // if it looks like a named, leave last spawn name alone
                if (this.LastSpawnName.Length > 0)
                {
                    // See if mob name starts with capital letter or #
                    if (!Regex.IsMatch(this.LastSpawnName, "^[A-Z#]"))
                    {
                        this.LastSpawnName = name;
                    }
                }
                else
                {
                    this.LastSpawnName = name;
                }
                this.NextSpawnStr = "";

                this.NextSpawnDT = DateTime.MinValue;

                this.SpawnTimeDT = DateTime.Now;

                this.SpawnTimeStr = SpawnTimeDT.ToLongTimeString() + " " + SpawnTimeDT.ToShortDateString();



                // put name at beginning of list of AllNames



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

                string newnames = namet;

                int namecount = 1;

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

                foreach (string tname in names)

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

                    if (newnames.IndexOf(bname) < 0)

                    {
                        if (namecount < 12)

                        {
                            newnames += ", " + bname;

                            namecount++;
                        }
                    }
                }

                AllNames = newnames;



                if (this.KillTimeDT != DateTime.MinValue)

                {
                    // This mob has been killed already - now we can calculate

                    // the respawn time


                    int last_Timer = this.SpawnTimer;

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

                    this.SpawnTimer = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds;

                    if (Settings.Instance.MaxLogLevel > 0)
                    {
                        string spawnTimer = String.Format("{0}:{1}:{2}", Diff.Hours.ToString("00"), Diff.Minutes.ToString("00"), Diff.Seconds.ToString("00"));

                        log = String.Format("Setting Timer for Spawn: {0} Name: {1} Count: {2} Last Kill Time: {3} Current Spawn Time: {4} Timer: {5} = {6} secs Old: {7} secs",

                                            SpawnLoc, name, this.SpawnCount, this.KillTimeStr, this.SpawnTimeStr, spawnTimer, this.SpawnTimer, last_Timer);
                    }

                    // ... and forget about the kill



                    this.KillTimeDT = DateTime.MinValue;

                    this.KillTimeStr = "";
                }
            }

            catch (Exception ex) { LogLib.WriteLine("Error updating Timer SPAWNTIMER for " + name + ": ", ex); }



            listNeedsUpdate = true;



            return(log);
        }
Ejemplo n.º 12
0
        public String GetDescription()

        {
            String descr = null;



            int countTime = 0;

            string countTimer = "";

            if (NextSpawnDT != DateTime.MinValue)
            {
                TimeSpan Diff = NextSpawnDT.Subtract(DateTime.Now);

                countTimer = Diff.Hours.ToString("00") + ":" + Diff.Minutes.ToString("00") + ":" + Diff.Seconds.ToString("00");

                countTime = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds;
            }



            if (countTime > 0)

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");
                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", NextSpawnStr);

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer);

                spawnTimer.AppendFormat("Spawning In: {0}\n", countTimer);

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            else if (SpawnTimer > 0)

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");

                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer);

                spawnTimer.AppendFormat("Spawning In: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            else

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");

                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", "0");

                spawnTimer.AppendFormat("Spawning In: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            return(descr);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
 private void button_sort_Click(object sender, EventArgs e)
 {
     AllNames.Sort();
     Init(AllNames.ToArray());
 }