예제 #1
0
 public override string ToString()
 {
     if (!Modified)
     {
         return(ToStringCache);
     }
     //unlike its parent PoEModData, translation here is done live to allow roll-dependent syntax
     ToStringCache = StatTranslator.TranslateModCraft(this, Quality);
     Modified      = false;
     return(ToStringCache);
 }
예제 #2
0
 public override string ToString()
 {
     if (!Modified)
     {
         return(ToStringCache);
     }
     //unlike its parent PoEModData, translation here is done live to allow roll-dependent syntax
     ToStringCache = StatTranslator.TranslateModCraft(this, Quality);
     if (ToStringCache.Length <= 0)
     {
         ToStringCache = CraftingDatabase.AllMods[SourceData].name;
     }
     Modified = false;
     return(ToStringCache);
 }
예제 #3
0
        private async Task InitializeAsync()
        {
            var modsTask             = DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods");
            var benchOptionsTask     = DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options");
            var npcMastersTask       = DataUtils.LoadRePoEAsync <Dictionary <string, JsonNpcMaster> >("npc_master");
            var statTranslationsTask = DataUtils.LoadRePoEAsync <List <JsonStatTranslation> >("stat_translations");

            ModDatabase    = new ModDatabase(await modsTask, await benchOptionsTask, await npcMastersTask);
            StatTranslator = new StatTranslator(await statTranslationsTask);

            ItemBases   = (await LoadBases()).ToList();
            UniqueBases = (await LoadUniques()).ToList();

            ItemBaseDictionary   = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name);
            UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName);

            _root = new WordSetTreeNode(ItemBases.Select(m => m.Name));
        }
예제 #4
0
        public MainWindow()
        {
            Icons.LoadImages();

            InitializeComponent();

            //must be done first so mod templates are translated as they're loaded
            StatTranslator.LoadStatLocalization(@"Data\stat_translations.min.json");

            CraftingDatabase.LoadPseudoStats(@"Data\pseudo_stats.json", @"user_pseudo_stats.json");
            CraftingDatabase.LoadMods(@"Data\mods.min.json", @"Data\mod_types.min.json");
            CraftingDatabase.LoadBaseItems(@"Data\base_items.min.json", @"Data\item_classes.min.json");
            CraftingDatabase.LoadBenchOptions(@"Data\crafting_bench_options.min.json");
            CraftingDatabase.LoadEssences(@"Data\essences.min.json");
            CraftingDatabase.LoadFossils(@"Data\fossils.min.json");
            CraftingDatabase.LoadPrices("pricedata.json");
            CraftingDatabase.LoadSpecialMods(@"Data\delve_droponly_mods.json", @"Data\incursion_droponly_mods.json");

            CurrencyBox.LoadEssences(CraftingDatabase.Essences.Values);
            CurrencyBox.LoadFossils(CraftingDatabase.Fossils.Values);
            CurrencyBox.LoadCurrencies(CraftingDatabase.Currencies.Values);

            Bench                     = new CraftingBench();
            ModPreview.Bench          = Bench;
            ModPreview.Currency       = CurrencyBox;
            CurrencyTally.ItemsSource = Bench.CurrencySpent;

            PostCraftButton.Content = new Image()
            {
                Source = Icons.Plus
            };
            SearchButton.Content = new Image()
            {
                Source = Icons.Search
            };
            BigBox.Text                 = "";
            BigBox.FontWeight           = FontWeights.Bold;
            BigBox.Foreground           = Brushes.Red;
            RepeatCountBox.Max          = Properties.Settings.Default.BulkCraftLimit;
            RepeatCountBox.TextChanged += CheckRepeatCount;
            RepeatCountBox.Text         = "10000";
        }
예제 #5
0
        //build mod data templates from mods.min.json and mod_types.min.json, also builds search templates for stats used by relevant mods
        //MUST BE DONE AFTER TRANSLATION DEFINITIONS ARE LOADED IN STATTRANSLATOR
        public static int LoadMods(string modsfile, string typesfile)
        {
            Dictionary <string, Dictionary <string, HashSet <string> > > typesdata = JsonSerializer.Deserialize <Dictionary <string, Dictionary <string, HashSet <string> > > >(File.ReadAllText(typesfile));

            AllMods      = JsonSerializer.Deserialize <Dictionary <string, PoEModData> >(File.ReadAllText(modsfile));
            CoreMods     = new Dictionary <string, PoEModData>();
            Enchantments = new Dictionary <string, PoEModData>();
            InitStatTemplates();
            foreach (string k in AllMods.Keys)
            {
                PoEModData d = AllMods[k];
                //translate once and save string as a property
                StatTranslator.FillTranslationData(d);
                //set type_tags field with a lookup
                d.type_tags = typesdata[d.type]["tags"];
                //set key field
                d.key = k;
                if (d.generation_type == ModLogic.Enchantment)
                {
                    Enchantments.Add(k, AllMods[k]);
                }
                //flag relevant mods to move to core dictionary, "misc" domain is for regular jewels
                if ((d.domain == "item" || d.domain == "abyss_jewel" || d.domain == "misc") && (d.generation_type == ModLogic.Prefix || d.generation_type == ModLogic.Suffix))
                {
                    CoreMods.Add(k, AllMods[k]);
                }
                //every mod worth translating into string templates to search by, doesn't include implicits because idk how to include them w/o also including a ton of useless unique item mods
                if ((d.domain == "item" || d.domain == "abyss_jewel" || d.domain == "misc" || d.domain == "crafted" || d.domain == "delve") && (d.generation_type == ModLogic.Prefix || d.generation_type == ModLogic.Suffix))
                {
                    IncludeTranslations(AllMods[k]);
                }
            }
            Debug.WriteLine(CoreMods.Count + " core, " + Enchantments.Count + " enchantment, " + AllMods.Count + " total mods loaded");
            Debug.WriteLine(StatTemplates.Count + " statlines loaded");
            return(CoreMods.Count);
        }
예제 #6
0
 public DynamicTranslation(StatTranslator statTranslator, Affix affix, IEnumerable <int> valueIndices)
 {
     _statTranslator = statTranslator;
     _affix          = affix;
     _valueIndices   = valueIndices.ToList();
 }
예제 #7
0
 public ModSelectorViewModel(StatTranslator statTranslator, bool canDeselect = true)
 {
     _statTranslator = statTranslator;
     CanDeselct      = canDeselect;
 }
        //build mod data templates from mods.min.json and mod_types.min.json, also builds search templates for stats used by relevant mods
        //MUST BE DONE AFTER TRANSLATION DEFINITIONS ARE LOADED IN STATTRANSLATOR
        public static int LoadMods(string modsfile, string typesfile)
        {
            Dictionary <string, Dictionary <string, HashSet <string> > > typesdata = JsonSerializer.Deserialize <Dictionary <string, Dictionary <string, HashSet <string> > > >(File.ReadAllText(typesfile));

            AllMods      = JsonSerializer.Deserialize <Dictionary <string, PoEModData> >(File.ReadAllText(modsfile));
            CoreMods     = new Dictionary <string, PoEModData>();
            Enchantments = new Dictionary <string, PoEModData>();
            InitStatTemplates();
            afflictionmods.Clear();
            Dictionary <string, string> clusterreminders = new Dictionary <string, string>();

            using (StreamReader r = File.OpenText(@"Data\ClusterText.txt"))
            {
                string line;
                string name = null;
                string desc = null;
                while ((line = r.ReadLine()) != null)
                {
                    if (line.Length == 0 && name != null)
                    {
                        clusterreminders.Add(name, desc);
                        name = null;
                        desc = null;
                        continue;
                    }
                    if (name == null)
                    {
                        name = line;
                    }
                    else if (desc == null)
                    {
                        desc = line;
                    }
                    else
                    {
                        desc += "\n" + line;
                    }
                }
                if (name != null)
                {
                    clusterreminders.Add(name, desc);
                }
            }
            //Dictionary<string, List<PoEModWeight>> afflictiondict = new Dictionary<string, List<PoEModWeight>>();
            foreach (string k in AllMods.Keys)
            {
                PoEModData d = AllMods[k];
                //translate once and save string as a property
                StatTranslator.FillTranslationData(d);
                //set type_tags field with a lookup
                d.type_tags = typesdata[d.type]["tags"];
                //set key field
                d.key = k;
                if (d.generation_type == ModLogic.Enchantment)
                {
                    Enchantments.Add(k, AllMods[k]);
                }
                //flag relevant mods to move to core dictionary, "misc" domain is for regular jewels
                if ((d.domain == "item" || d.domain == "abyss_jewel" || d.domain == "misc" || d.domain == "affliction_jewel") && (d.generation_type == ModLogic.Prefix || d.generation_type == ModLogic.Suffix))
                {
                    CoreMods.Add(k, AllMods[k]);
                }
                //every mod worth translating into string templates to search by, doesn't include implicits because idk how to include them w/o also including a ton of useless unique item mods
                if ((d.domain == "item" || d.domain == "abyss_jewel" || d.domain == "misc" || d.domain == "affliction_jewel" || d.domain == "crafted" || d.domain == "delve") && (d.generation_type == ModLogic.Prefix || d.generation_type == ModLogic.Suffix))
                {
                    IncludeTranslations(AllMods[k]);
                }
                if ((d.domain == "affliction_jewel") && (d.generation_type == ModLogic.Prefix || d.generation_type == ModLogic.Suffix))
                {
                    int notableindex = d.full_translation.IndexOf("Skill is");
                    if (notableindex > 0 && !d.full_translation.Contains("Jewel Socket"))
                    {
                        string notablename = d.full_translation.Substring(notableindex + 9);
                        d.tooltip_reminder = clusterreminders[notablename];
                    }
                    //if (d.full_translation.Contains("also grant"))
                    //    Debug.WriteLine(d);
                    foreach (PoEModWeight w in d.spawn_weights)
                    {
                        if (w.tag.Contains("affliction"))
                        {
                            afflictionmods.Add(w.tag);
                            //if (d.full_translation.Contains("also grant"))
                            //    Debug.WriteLine(w.tag);
                            //if (notableindex > 0 && !d.full_translation.Contains("Jewel Socket"))
                            //{
                            //    if (!afflictiondict.ContainsKey(w.tag))
                            //        afflictiondict.Add(w.tag, new List<PoEModWeight>() { new PoEModWeight() { tag = k, weight = w.weight } });
                            //    else
                            //        afflictiondict[w.tag].Add(new PoEModWeight() { tag = k, weight = w.weight });
                            //}
                        }
                    }
                }
            }
            //using (StreamWriter w = File.CreateText("notables.csv"))
            //{
            //    foreach (string s in afflictiondict.Keys)
            //    {
            //        w.WriteLine(s);
            //        foreach (PoEModWeight mw in afflictiondict[s])
            //        {
            //            PoEModData mod = AllMods[mw.tag];
            //            w.WriteLine(mw.weight + ",\"" + mod.full_translation.Substring(mod.full_translation.IndexOf("Skill is") + 9) + "\",\"" + mod.tooltip_reminder + "\"");
            //        }
            //        w.WriteLine("");
            //    }
            //}
            Debug.WriteLine(CoreMods.Count + " core, " + Enchantments.Count + " enchantment, " + AllMods.Count + " total mods loaded");
            Debug.WriteLine(StatTemplates.Count + " statlines loaded");
            IList <string> mediumenchants = new List <string>()
            {
                "affliction_area_damage", "affliction_aura_effect", "affliction_brand_damage", "affliction_critical_chance", "affliction_curse_effect", "affliction_fire_damage_over_time_multiplier", "affliction_chaos_damage_over_time_multiplier", "affliction_physical_damage_over_time_multiplier", "affliction_cold_damage_over_time_multiplier", "affliction_damage_over_time_multiplier", "affliction_effect_of_non-damaging_ailments", "affliction_life_and_mana_recovery_from_flasks", "affliction_flask_duration", "affliction_damage_while_you_have_a_herald", "affliction_minion_damage_while_you_have_a_herald", "affliction_minion_life", "affliction_projectile_damage", "affliction_totem_damage", "affliction_trap_and_mine_damage", "affliction_warcry_buff_effect", "affliction_channelling_skill_damage"
            };
            IList <string> smallenchants = new List <string>()
            {
                "affliction_maximum_life", "affliction_chance_to_dodge_attacks", "affliction_cold_resistance", "affliction_chaos_resistance", "affliction_armour", "affliction_evasion", "affliction_fire_resistance", "affliction_maximum_mana", "affliction_maximum_energy_shield", "affliction_lightning_resistance", "affliction_chance_to_block"
            };
            IList <string> largeenchants = new List <string>()
            {
                "affliction_axe_and_sword_damage", "affliction_mace_and_staff_damage", "affliction_dagger_and_claw_damage", "affliction_bow_damage", "affliction_wand_damage", "affliction_damage_with_two_handed_melee_weapons", "affliction_attack_damage_while_dual_wielding_", "affliction_attack_damage_while_holding_a_shield", "affliction_attack_damage_", "affliction_spell_damage", "affliction_chaos_damage", "affliction_cold_damage", "affliction_elemental_damage", "affliction_fire_damage", "affliction_lightning_damage", "affliction_physical_damage", "affliction_minion_damage"
            };
            IList <PoEModWeight> afflictionmediumspawns = new List <PoEModWeight>
            {
                new PoEModWeight()
                {
                    tag = "expansion_jewel_medium", weight = 100
                },
                new PoEModWeight()
                {
                    tag = "default", weight = 0
                }
            };
            IList <PoEModWeight> afflictionsmallspawns = new List <PoEModWeight>
            {
                new PoEModWeight()
                {
                    tag = "expansion_jewel_small", weight = 100
                },
                new PoEModWeight()
                {
                    tag = "default", weight = 0
                }
            };
            IList <PoEModWeight> afflictionlargespawns = new List <PoEModWeight>
            {
                new PoEModWeight()
                {
                    tag = "expansion_jewel_large", weight = 100
                },
                new PoEModWeight()
                {
                    tag = "default", weight = 0
                }
            };
            IList <PoEModWeight> afflictionnospawns = new List <PoEModWeight>
            {
                new PoEModWeight()
                {
                    tag = "default", weight = 0
                }
            };

            foreach (string s in afflictionmods)
            {
                PoEModData afflictionmod = new PoEModData()
                {
                    adds_tags = new HashSet <string>()
                    {
                        s
                    },
                    domain             = "item",
                    generation_type    = "enchantment",
                    generation_weights = new List <PoEModWeight>(),
                    group           = "SmallPassiveGroup",
                    is_essence_only = false,
                    name            = s.Replace("affliction", "small passives grant: "),
                    required_level  = 1,
                    stats           = null,
                    type            = "SmallPassiveType",
                    key             = s,
                    type_tags       = new HashSet <string>()
                };
                if (mediumenchants.Contains(s))
                {
                    afflictionmod.spawn_weights = afflictionmediumspawns;
                }
                else if (smallenchants.Contains(s))
                {
                    afflictionmod.spawn_weights = afflictionsmallspawns;
                }
                else if (largeenchants.Contains(s))
                {
                    afflictionmod.spawn_weights = afflictionlargespawns;
                }
                else
                {
                    afflictionmod.spawn_weights = afflictionnospawns;
                }
                Enchantments.Add(s, afflictionmod);
                AllMods.Add(s, afflictionmod);
            }
            return(CoreMods.Count);
        }
예제 #9
0
 public static async Task CreateTranslatorAsync()
 {
     _translator = await StatTranslators.CreateFromMainFileAsync().ConfigureAwait(false);
 }