Ejemplo n.º 1
0
        public EditManualItemDataViewModel Load(ManualItemData manualItemData, UnitOfWork uow, WarframeItemUtilities itemUtils)
        {
            ManualItemData = manualItemData;
            if (ManualItemData == null)
            {
                ManualItemData = new ManualItemData();
            }

            if (!string.IsNullOrWhiteSpace(ManualItemData.ItemUniqueName))
            {
                WarframeItem item = itemUtils.GetByUniqueName(ManualItemData.ItemUniqueName);
                SelectedItemName = item.Name;
            }

            PropertyNames = new List <string>();
            foreach (PropertyInfo prop in typeof(WarframeItem).GetProperties())
            {
                if (prop.CanRead &&
                    prop.CanWrite &&
                    prop.Name != "UniqueName" &&
                    prop.PropertyType == typeof(string) ||
                    prop.PropertyType == typeof(int?) ||
                    prop.PropertyType == typeof(double?) ||
                    prop.PropertyType == typeof(bool))
                {
                    PropertyNames.Add(prop.Name);
                }
            }
            PropertyNames = PropertyNames.OrderBy(x => x).ToList();

            return(this);
        }
        public void IsPrime_NonPrimeItem_ShouldReturnFalse()
        {
            WarframeItem item = new WarframeItem {
                Name = "Cup"
            };

            Assert.IsFalse(item.IsPrime);
        }
        public void IsPrime_PrimeItem_ShouldReturnTrue()
        {
            WarframeItem item = new WarframeItem {
                Name = "Cup Prime"
            };

            Assert.IsTrue(item.IsPrime);
        }
        public void IsVaulted_VaultDateInFuture_ShouldReturnFalse()
        {
            WarframeItem item = new WarframeItem {
                Name      = "Cup Prime",
                VaultDate = "2400 01 30"
            };

            Assert.IsFalse(item.IsVaulted);
        }
        public void IsVaulted_VaultDateInPast_ShouldReturnTrue()
        {
            WarframeItem item = new WarframeItem {
                Name      = "Cup Prime",
                VaultDate = "2020 01 30"
            };

            Assert.IsTrue(item.IsVaulted);
        }
        public void IsVaulted_Vaulted_ShouldReturnTrue()
        {
            WarframeItem item = new WarframeItem {
                Name    = "Cup Prime",
                Vaulted = "true"
            };

            Assert.IsTrue(item.IsVaulted);
        }
        public void IsVaulted_NotVaulted_ShouldReturnFalse()
        {
            WarframeItem item = new WarframeItem {
                Name    = "Cup Prime",
                Vaulted = "false"
            };

            Assert.IsFalse(item.IsVaulted);
        }
Ejemplo n.º 8
0
        public ActionResult UpdateItemAcquisition(
            [Bind(Prefix = "ItemAcquisition")] ItemAcquisition model,
            [Bind(Prefix = "ComponentAcquisitions")] List <ComponentAcquisition> compModel)
        {
            if (ModelState.IsValid)
            {
                User user = _uow.GetRepo <UserRepository>().GetByUsername(User.Identity.Name);
                model.UserID = user.ID;

                WarframeItem item     = _itemUtils.GetByUniqueName(model.ItemUniqueName);
                ItemCategory category = _uow.GetRepo <ItemCategoryRepository>().GetByID(item.ItemCategoryID);
                if (!category.CanBeMastered)
                {
                    model.IsMastered = false;
                }

                ItemAcquisition existing = _uow.GetRepo <ItemAcquisitionRepository>().GetByPrimaryKeys(user.ID, model.ItemUniqueName);
                if (existing == null)
                {
                    _uow.GetRepo <ItemAcquisitionRepository>().Add(model);
                }
                else
                {
                    _uow.GetRepo <ItemAcquisitionRepository>().Update(model);
                }

                if (compModel != null && compModel.Any())
                {
                    foreach (ComponentAcquisition ca in compModel)
                    {
                        ca.UserID = user.ID;
                        ComponentAcquisition existingComp = _uow.GetRepo <ComponentAcquisitionRepository>().GetByPrimaryKeys(user.ID, ca.ComponentUniqueName, ca.ItemUniqueName);
                        if (existingComp == null)
                        {
                            _uow.GetRepo <ComponentAcquisitionRepository>().Add(ca);
                        }
                        else
                        {
                            _uow.GetRepo <ComponentAcquisitionRepository>().Update(ca);
                        }
                    }
                }

                return(Json(new {
                    success = true,
                    itemName = model.ItemUniqueName,
                    view = RenderViewAsync("AcquisitionIcon", model).Result
                }));
            }
            return(Json(new {
                success = false
            }));
        }
Ejemplo n.º 9
0
        public ActionResult Form(string itemID)
        {
            itemID = itemID.Replace("|", "/");
            WarframeItem item         = _itemUtils.GetByUniqueName(itemID);
            ItemCategory itemCategory = _uow.GetRepo <ItemCategoryRepository>().GetByID(item.ItemCategoryID);

            new EagerLoader(_uow).Load(itemCategory);
            if (itemCategory.CodexTab_Object.CodexSectionID == CodexSection.Relics)
            {
                return(PartialView("_RelicModal", item));
            }

            return(PartialView("_ItemModalContent", new ItemModalViewModel().Load(item, itemCategory, User, _uow, _itemUtils)));
        }
Ejemplo n.º 10
0
        /*public int GetMinimumCredits()
         * {
         *  //Get WarframeItem entry for credits
         *  var item = GetItem("/Lotus/Language/Menu/Monies");
         *  int minCred = GetWarframeItemMinimumQuantity(item);
         *  return minCred;
         * }*/

        public int GetItemMinimum(WarframeItem item)
        {
            int result = 0;

            try
            {
                result = WFDataContext.WFMiscIgnoreOptions.Where(x => x.ItemID == item.ID).Single().MinQuantity;
            }
            catch (Exception)
            {
                result = 0;
            }

            return(result);
        }
        public void Run()
        {
            List <WarframeItem> allMods = warframeItemUtilities.GetAllMods();

            ModSuggestionRepository repo           = uow.GetRepo <ModSuggestionRepository>();
            List <ModSuggestion>    modSuggestions = repo.GetAll();

            foreach (ModSuggestion modSuggestion in modSuggestions)
            {
                WarframeItem item = allMods.SingleOrDefault(x => x.UniqueName == modSuggestion.UniqueName);
                if (item != null)
                {
                    string json = JsonConvert.SerializeObject(item);
                    if (modSuggestion.WarframeItemJson != json)
                    {
                        modSuggestion.WarframeItemJson = json;
                        repo.Update(modSuggestion);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public IActionResult RefreshModSuggestions()
        {
            List <WarframeItem> allMods = itemUtils.GetAllMods();

            ModSuggestionRepository repo           = uow.GetRepo <ModSuggestionRepository>();
            List <ModSuggestion>    modSuggestions = repo.GetAll();

            foreach (ModSuggestion modSuggestion in modSuggestions)
            {
                WarframeItem item = allMods.SingleOrDefault(x => x.UniqueName == modSuggestion.UniqueName);
                if (item != null)
                {
                    string json = JsonConvert.SerializeObject(item);
                    if (modSuggestion.WarframeItemJson != json)
                    {
                        modSuggestion.WarframeItemJson = json;
                        repo.Update(modSuggestion);
                    }
                }
            }
            return(Message("Done"));
        }
 public IActionResult Edit([Bind(Prefix = "ModSuggestion")] ModSuggestion model)
 {
     if (ModelState.IsValid)
     {
         ModSuggestionRepository repo         = uow.GetRepo <ModSuggestionRepository>();
         WarframeItem            warframeItem = warframeItemUtilities.GetAllMods().SingleOrDefault(x => x.UniqueName == model.UniqueName);
         warframeItem.Name      = warframeItem.Name.Replace("'S", "'s");
         model.WarframeItemJson = JsonConvert.SerializeObject(warframeItem);
         if (model.ID == 0)
         {
             repo.Add(model);
             TempData["message"] = "Mod Suggestion Added";
         }
         else
         {
             repo.Update(model);
             TempData["message"] = "Mod Suggestion Updated";
         }
         return(RedirectToAction("Index"));
     }
     return(View(new EditModSuggestionViewModel().Load(model, uow, warframeItemUtilities)));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Fills the selected information panel with the clicked item's information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemLabel_Click(object sender, EventArgs e)
        {
            LinkLabel s = (LinkLabel)sender;

            WarframeItem wfItem = allPrimeItems.FirstOrDefault(o => o.item_name.Equals(s.Text));

            itemIDLabel.Text = wfItem.id;

            //Get the thumbnail of the item and display it in the image label
            Image thumbnail = null;

            using (var client = new WebClient())
            {
                byte[] buffer = client.DownloadData(wfItem.thumb);
                using (var stream = new MemoryStream(buffer))
                {
                    thumbnail = Image.FromStream(stream);
                }
            }

            itemImageLabel.Image = thumbnail;

            //string rawJson = WarframeMarketApi.RequestItemInfo(wfItem.url_name);

            //JObject jsonResults = JObject.Parse(rawJson);
            //List<JToken> filteredResults = jsonResults["payload"]["item"]["items_in_set"][0].ToList();
            //string ducats = "";
            //foreach (JToken item in filteredResults)
            //{
            //    if (item.Path.Contains("ducats"))
            //    {
            //        Console.WriteLine(item.Path);
            //        ducats = new string(item.ToString().Where(char.IsDigit).ToArray());
            //    }
            //}
            //Console.WriteLine(ducats);
        }
Ejemplo n.º 15
0
        public ItemModalViewModel Load(WarframeItem warframeItem, ItemCategory itemCategory, ClaimsPrincipal user, UnitOfWork uow, WarframeItemUtilities itemUtils)
        {
            WarframeItem = warframeItem;
            ItemCategory = itemCategory;

            int?userID = null;

            if (user.Identity.IsAuthenticated)
            {
                userID          = int.Parse(user.FindFirstValue(ClaimTypes.NameIdentifier));
                ItemAcquisition = uow.GetRepo <ItemAcquisitionRepository>().GetByPrimaryKeys(userID.Value, WarframeItem.UniqueName);

                if (ItemAcquisition == null)
                {
                    ItemAcquisition = new ItemAcquisition {
                        UserID         = userID.Value,
                        ItemUniqueName = WarframeItem.UniqueName
                    }
                }
                ;
            }

            if (WarframeItem.Components != null && WarframeItem.Components.Any())
            {
                WarframeItem.Components = WarframeItem.Components.OrderByDescending(x => x.Name == "Blueprint").ThenBy(x => x.Name == "Orokin Cell").ThenBy(x => x.Name).ToList();

                if (userID.HasValue)
                {
                    ComponentAcquisitions = uow.GetRepo <ComponentAcquisitionRepository>()
                                            .GetByItemUniqueNameAndUserID(WarframeItem.UniqueName, userID.Value);
                }
                else
                {
                    ComponentAcquisitions = new List <ComponentAcquisition>();
                }

                ItemCategory        cat    = uow.GetRepo <ItemCategoryRepository>().GetByCodexSection(CodexSection.Relics).FirstOrDefault();
                List <WarframeItem> relics = itemUtils.GetByCategoryID(cat.ID);


                int index = 0;
                foreach (Component comp in WarframeItem.Components)
                {
                    ComponentAcquisition ca = ComponentAcquisitions
                                              .SingleOrDefault(x => x.ComponentUniqueName == comp.UniqueName);
                    if (ca == null)
                    {
                        ComponentAcquisitions.Add(new ComponentAcquisition {
                            UserID = userID ?? 0,
                            ComponentUniqueName = comp.UniqueName,
                            ItemUniqueName      = WarframeItem.UniqueName,
                            ComponentName       = comp.Name
                        });
                    }
                    else
                    {
                        ca.ComponentName = comp.Name;
                    }

                    if (comp.Drops != null && comp.Drops.Any())
                    {
                        for (int i = comp.Drops.Count - 1; i >= 0; i--)
                        {
                            var relic = relics.SingleOrDefault(x => x.Name == comp.Drops[i].Location);
                            //if (relic != null && relic.IsVaulted) {
                            //    comp.Drops.RemoveAt(i);
                            //}
                        }
                    }
                    index++;
                }

                ComponentAcquisitions = ComponentAcquisitions.OrderByDescending(x => x.ComponentName == "Blueprint").ThenBy(x => x.ComponentName == "Orokin Cell").ThenBy(x => x.ComponentName).ToList();
            }
            return(this);
        }
    }
Ejemplo n.º 16
0
        public PrimePredictionViewModel Load(UnitOfWork uow, WarframeItemUtilities itemUtils, AppSettings appSettings)
        {
            List <WarframeItem> frames = itemUtils.GetByCategoryID(appSettings.WarframeItemCategoryID);

            StandardWarframes = frames.Where(x => !x.IsPrime && !x.Name.Contains("Umbra")).OrderBy(x => string.IsNullOrWhiteSpace(x.ReleaseDate)).ThenBy(x => x.ReleaseDate).ToList();
            PrimeWarframes    = frames.Where(x => x.IsPrime).OrderBy(x => x.ReleaseDate).ToList();

            WarframeItem lastPrime = PrimeWarframes.Last();

            LastPrimeReleaseDate = DateTime.Parse(lastPrime.ReleaseDate);

            StandardWithoutPrimeWarframes = new List <WarframeItem>();
            foreach (WarframeItem standard in StandardWarframes)
            {
                WarframeItem primeVariant = PrimeWarframes.SingleOrDefault(x => x.Name == standard.Name + " Prime");
                if (primeVariant == null)
                {
                    StandardWithoutPrimeWarframes.Add(standard);
                }
            }

            StandardWithoutPrimeWarframes = StandardWithoutPrimeWarframes.OrderBy(x => string.IsNullOrWhiteSpace(x.ReleaseDate)).ThenBy(x => x.ReleaseDate).ToList();

            PrimeIndex = 0;
            foreach (WarframeItem item in PrimeWarframes)
            {
                PrimeIndex++;
                if (PrimeIndex % 4 == 0)
                {
                    Gender = "Male";
                }
                else if (PrimeIndex % 4 == 2)
                {
                    Gender = "Female";
                }
            }

            List <int> daysBetweenReleases = new List <int>();

            for (int i = 0; i < PrimeWarframes.Count; i++)
            {
                if (i == 0)
                {
                    continue;
                }

                WarframeItem current  = PrimeWarframes[i];
                WarframeItem previous = PrimeWarframes[i - 1];

                bool currentParsed = DateTime.TryParse(current.ReleaseDate, out DateTime currentRelease);
                bool prevParsed    = DateTime.TryParse(previous.ReleaseDate, out DateTime previousRelease);

                if (currentParsed && prevParsed)
                {
                    TimeSpan diff = currentRelease - previousRelease;
                    daysBetweenReleases.Add((int)Math.Round(diff.TotalDays));
                }
            }

            AverageDaysBetweenPrimes = daysBetweenReleases.Sum() / daysBetweenReleases.Count;

            return(this);
        }