public void Unload()
        {
            Log.Info(Log.LogSource.PoxDB, "Database.Unload() called");
            if (!ready)
            {
                return;
            }
            // todo: what if it is loading?

            Champions.Clear();
            Abilities.Clear();
            Abilities_similar.Clear();
            Spells.Clear();
            Relics.Clear();
            Equipments.Clear();

            Factions.Clear();
            Races.Clear();
            Classes.Clear();
            Rarities.Clear();
            Expansions.Clear();
            AbilityNames.Clear();

            ready = false;
        }
Exemple #2
0
        public void UpdateInventoryCategories()
        {
            Potions.Clear();
            Weapons.Clear();
            Treasure.Clear();
            Relics.Clear();

            foreach (var gameItemQuantity in _inventory)
            {
                if (gameItemQuantity.GameItem is Potions)
                {
                    Potions.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is Weapon)
                {
                    Weapons.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is Treasure)
                {
                    Treasure.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is Relic)
                {
                    Relics.Add(gameItemQuantity);
                }
            }
        }
Exemple #3
0
        public static void Initialize()
        {
            var httpClient = new HttpClient();

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://drops.warframestat.us/data/all.json");

            var httpResponse = httpClient.SendAsync(request);

            httpResponse.Wait();
            var result  = httpResponse.Result;
            var content = result.Content.ReadAsStringAsync().Result;

            var response = JsonConvert.DeserializeObject <WarframeDropDataModels.AllDataReponse>(content);

            #region Missions
            Missions.Clear();

            var missionRewardsEnumerator = response.MissionRewards.GetEnumerator();

            while (missionRewardsEnumerator.MoveNext())
            {
                var planetKeyValuePair = missionRewardsEnumerator.Current;

                var missionsEnumerator = planetKeyValuePair.Value.GetEnumerator();

                while (missionsEnumerator.MoveNext())
                {
                    var missionModelKeyValuePair = missionsEnumerator.Current;

                    var mission = new SearchResultModels.Mission
                    {
                        Planet = planetKeyValuePair.Key,
                        Name   = missionModelKeyValuePair.Key,
                        Type   = missionModelKeyValuePair.Value.GameMode
                    };

                    for (int i = 0; i < missionModelKeyValuePair.Value.MissionRewards.Count; i++)
                    {
                        var missionReward = missionModelKeyValuePair.Value.MissionRewards[i];

                        if (mission.Rewards == null)
                        {
                            mission.Rewards = new List <SearchResultModels.Item>();
                        }

                        mission.Rewards.Add(missionReward.ToItem());
                    }

                    if (missionModelKeyValuePair.Value.MissionRewards.A != null)
                    {
                        for (int i = 0; i < missionModelKeyValuePair.Value.MissionRewards.A.Count; i++)
                        {
                            var missionReward = missionModelKeyValuePair.Value.MissionRewards.A[i];

                            if (mission.RotationA == null)
                            {
                                mission.RotationA = new List <SearchResultModels.Item>();
                            }

                            mission.RotationA.Add(missionReward.ToItem());
                        }
                    }

                    if (missionModelKeyValuePair.Value.MissionRewards.B != null)
                    {
                        for (int i = 0; i < missionModelKeyValuePair.Value.MissionRewards.B.Count; i++)
                        {
                            var missionReward = missionModelKeyValuePair.Value.MissionRewards.B[i];

                            if (mission.RotationB == null)
                            {
                                mission.RotationB = new List <SearchResultModels.Item>();
                            }

                            mission.RotationB.Add(missionReward.ToItem());
                        }
                    }

                    if (missionModelKeyValuePair.Value.MissionRewards.C != null)
                    {
                        for (int i = 0; i < missionModelKeyValuePair.Value.MissionRewards.C.Count; i++)
                        {
                            var missionReward = missionModelKeyValuePair.Value.MissionRewards.C[i];

                            if (mission.RotationC == null)
                            {
                                mission.RotationC = new List <SearchResultModels.Item>();
                            }

                            mission.RotationC.Add(missionReward.ToItem());
                        }
                    }

                    Missions.Add(mission);
                }
            }
            #endregion

            #region Bounties
            Bounties.Clear();

            ConvertBounties(response.CetusBountyRewards, "Earth");
            ConvertBounties(response.SolarisBountyRewards, "Venus");
            ConvertBounties(response.DeimosRewards, "Deimos");
            #endregion

            #region Relics
            Relics.Clear();

            for (int i = 0; i < response.Relics.Count; i++)
            {
                var relicModel = response.Relics[i];

                if (i == 0 || i % 4 != 0)
                {
                    continue;
                }

                var relic = new SearchResultModels.Relic
                {
                    Era         = relicModel.Tier,
                    Description = relicModel.RelicName,
                    Locations   = new List <SearchResultModels.ItemLocation>()
                };

                relic.Rewards = relicModel.Rewards.Select(j => j.ToItem()).OrderByDescending(i => i.DropChance).ToList();

                var relicName = $"{relic.Era} {relic.Description} Relic";

                var locations = Missions.Where(j => j.Rewards?.Any(k => k.Name == relicName) == true).ToList();

                for (int j = 0; j < locations.Count; j++)
                {
                    var location = locations[j];

                    var chance = location.Rewards.FirstOrDefault(k => k.Name == relicName).DropChance;

                    relic.Locations.Add(new SearchResultModels.ItemLocation
                    {
                        Mission = location,
                        Chance  = chance
                    });
                }

                locations = Missions.Where(j => j.RotationA?.Any(k => k.Name == relicName) == true).ToList();

                for (int j = 0; j < locations.Count; j++)
                {
                    var location = locations[j];

                    var chance = location.RotationA.FirstOrDefault(k => k.Name == relicName).DropChance;

                    relic.Locations.Add(new SearchResultModels.ItemLocation
                    {
                        Rotation = "A",
                        Chance   = chance,
                        Mission  = location
                    });
                }

                locations = Missions.Where(j => j.RotationB?.Any(k => k.Name == relicName) == true).ToList();

                for (int j = 0; j < locations.Count; j++)
                {
                    var location = locations[j];

                    var chance = location.RotationB.FirstOrDefault(k => k.Name == relicName).DropChance;

                    relic.Locations.Add(new SearchResultModels.ItemLocation
                    {
                        Rotation = "B",
                        Chance   = chance,
                        Mission  = location
                    });
                }

                locations = Missions.Where(j => j.RotationC?.Any(k => k.Name == relicName) == true).ToList();

                for (int j = 0; j < locations.Count; j++)
                {
                    var location = locations[j];

                    var chance = location.RotationC.FirstOrDefault(k => k.Name == relicName).DropChance;

                    relic.Locations.Add(new SearchResultModels.ItemLocation
                    {
                        Rotation = "C",
                        Chance   = chance,
                        Mission  = location
                    });
                }

                relic.Locations = relic.Locations.OrderByDescending(i => i.Chance).ToList();

                Relics.Add(relic);
            }
            #endregion
        }