Example #1
0
        public static ItemProperties ParseProperties(ItemCraft item)
        {
            IDictionary <string, int> mods = new Dictionary <string, int>();
            IList <string>            keys = new List <string>()
            {
                "arp", "arf", "evp", "evf", "esp", "esf", "blf", "dp", "mindf", "maxdf", "crp", "asp", "qf"
            };                                                                                                                                       //all possible property modifiers

            foreach (string s in keys)
            {
                mods.Add(s, 0);
            }
            foreach (ModCraft m in item.LiveMods)
            {
                ParsePropMods(m, mods);
            }
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[item.SourceData];
            int             qual         = item.BaseQuality + mods["qf"];

            //zero out quality if item class is mismatched
            if (CraftingDatabase.ItemClassNoQuality.Contains(itemtemplate.item_class))
            {
                qual = 0;
            }
            else if (CraftingDatabase.ItemClassCatalyst.Contains(itemtemplate.item_class))
            {
                if (item.QualityType == null)
                {
                    qual = 0;
                }
            }
            else
            {
                if (item.QualityType != null)
                {
                    qual = 0;
                }
            }
            int propqual = item.QualityType == null ? qual : 0;

            return(new ItemProperties()
            {
                quality = qual,
                armour = (itemtemplate.properties.armour + mods["arf"]) * (100 + mods["arp"] + propqual) / 100,
                evasion = (itemtemplate.properties.evasion + mods["evf"]) * (100 + mods["evp"] + propqual) / 100,
                energy_shield = (itemtemplate.properties.energy_shield + mods["esf"]) * (100 + mods["esp"] + propqual) / 100,
                block = itemtemplate.properties.block + mods["blf"],
                physical_damage_min = (itemtemplate.properties.physical_damage_min + mods["mindf"]) * (100 + mods["dp"] + propqual) / 100,
                physical_damage_max = (itemtemplate.properties.physical_damage_max + mods["maxdf"]) * (100 + mods["dp"] + propqual) / 100,
                critical_strike_chance = itemtemplate.properties.critical_strike_chance * (100 + mods["crp"]) / 100,
                attack_time = itemtemplate.properties.attack_time * 100 / (100 + mods["asp"])
            });
        }
        public FilterResult Evaluate(ItemCraft item, ItemProperties props, IDictionary <string, double> stats)
        {
            if (Subconditions == null)
            {
                return new FilterResult()
                       {
                           Match = true
                       }
            }
            ;
            int count = 0;
            IDictionary <string, double> info = new Dictionary <string, double>()
            {
                { "Count", 0 }
            };

            foreach (FilterCondition c in Subconditions)
            {
                FilterResult r = c.Evaluate(item, props, stats);

                if (r.Match)
                {
                    count++;
                }
                if (r.Info != null)
                {
                    foreach (string s in r.Info.Keys)
                    {
                        string testkey = s;
                        int    n       = 2;
                        while (info.ContainsKey(testkey) && testkey.IndexOf("[pseudo]") < 0)    //guarantee unique key if it's a count or weight
                        {
                            testkey = s + "(" + n + ")";
                            n++;
                        }
                        info.Add(testkey, r.Info[s]);
                    }
                }
            }
            info["Count"] = count;
            bool match = (Min == null || count >= Min) && (Max == null || count <= Max);

            return(new FilterResult()
            {
                Match = match, Info = info
            });
        }
Example #3
0
        public static IDictionary <string, double> ParseItem(ItemCraft item)
        {
            IDictionary <string, double> tr = new Dictionary <string, double>(StringComparer.OrdinalIgnoreCase);

            foreach (ModCraft m in item.LiveMods)
            {
                string stats = m.ToString();
                foreach (string s in stats.Split('\n'))
                {
                    KeyValuePair <string, double> kv = ParseLine(s);
                    if (tr.ContainsKey(kv.Key))
                    {
                        tr[kv.Key] += kv.Value;
                    }
                    else
                    {
                        tr.Add(kv);
                    }
                }
            }
            foreach (ModCraft m in item.LiveImplicits)
            {
                string stats = m.ToString();
                foreach (string s in stats.Split('\n'))
                {
                    KeyValuePair <string, double> kv = ParseLine(s);
                    if (tr.ContainsKey(kv.Key))
                    {
                        tr[kv.Key] += kv.Value;
                    }
                    else
                    {
                        tr.Add(kv);
                    }
                }
            }
            return(tr);
        }
 public static FilterResult Evaluate(ItemCraft item, FilterCondition condition)
 {
     //call ParseProperties and ParseItem here and pass the results so they don't have to be repeatedly called during evaluation
     return(condition.Evaluate(item, ItemParser.ParseProperties(item), ItemParser.ParseItem(item)));
 }
Example #5
0
        public static double?GetValueByName(string s, ItemCraft item, ItemProperties props, IDictionary <string, double> stats)
        {
            if (s.IndexOf("[property]") == 0)
            {
                string p = s.Substring(11);
                switch (p)
                {
                case "Quality":
                    return(props.quality);

                case "Armour":
                    return(props.armour);

                case "Evasion":
                    return(props.evasion);

                case "Energy Shield":
                    return(props.energy_shield);

                case "Block":
                    return(props.block);

                case "Physical Damage":
                    return(((double)props.physical_damage_min + props.physical_damage_max) / 2);

                case "Critical Strike Chance":
                    return((double)props.critical_strike_chance / 100);

                case "Attack Speed":
                    return((double)1000 / props.attack_time);

                case "Physical DPS":
                    return(((double)props.physical_damage_min + props.physical_damage_max) * 1000 / 2 / props.attack_time);

                case "# Prefixes":
                    return(item.ModCountByType(ModLogic.Prefix));

                case "# Suffixes":
                    return(item.ModCountByType(ModLogic.Suffix));

                case "# Open Prefixes":
                    return(item.GetAffixLimit(true) - item.ModCountByType(ModLogic.Prefix));

                case "# Open Suffixes":
                    return(item.GetAffixLimit(true) - item.ModCountByType(ModLogic.Suffix));

                default:
                    if (item.TempProps != null && item.TempProps.ContainsKey(p))
                    {
                        return(item.TempProps[p]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else if (s.IndexOf("[pseudo]") == 0)
            {
                double total = 0;
                if (CraftingDatabase.PseudoStats.ContainsKey(s))
                {
                    IDictionary <string, double> definition = CraftingDatabase.PseudoStats[s];
                    foreach (string k in definition.Keys)
                    {
                        double?v = GetValueByName(k, item, props, stats);
                        if (v != null)
                        {
                            total += v.Value * definition[k];
                        }
                    }
                }
                return(total);
            }
            else
            {
                if (stats.ContainsKey(s))
                {
                    return(stats[s]);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #6
0
        public void UpdateData(ItemCraft item)
        {
            SourceItem = item;
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[item.SourceData];

            if (item != null)
            {
                ItemNameBox.ToolTip    = "tags: " + string.Join(", ", item.LiveTags);
                ItemNameBox.Foreground = new SolidColorBrush(EnumConverter.RarityToColor(item.Rarity));
                ItemNameBox.Text       = item.ItemName;
                ItemDataBox.Text       = "ilvl: " + item.ItemLevel + " ";
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Shaper)]))
                {
                    ItemDataBox.Text += "  Shaper";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Elder)]))
                {
                    ItemDataBox.Text += "  Elder";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Redeemer)]))
                {
                    ItemDataBox.Text += "  Redeemer";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Hunter)]))
                {
                    ItemDataBox.Text += "  Hunter";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Warlord)]))
                {
                    ItemDataBox.Text += "  Warlord";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Crusader)]))
                {
                    ItemDataBox.Text += "  Crusader";
                }
                EnchantmentBox.Children.Clear();
                foreach (ModCraft m in item.LiveEnchantments)
                {
                    TextBlock tb = new TextBlock()
                    {
                        TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242))
                    };
                    tb.Text    = m.ToString();
                    tb.ToolTip = CraftingDatabase.AllMods[m.SourceData].ToString();
                    //HookEvents(tb);
                    EnchantmentBox.Children.Add(tb);
                }
                ImplicitBox.Children.Clear();
                foreach (ModCraft m in item.LiveImplicits)
                {
                    TextBlock tb = new TextBlock()
                    {
                        TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242))
                    };
                    tb.Text    = m.ToString();
                    tb.ToolTip = CraftingDatabase.AllMods[m.SourceData].ToString();
                    HookEvents(tb);
                    ImplicitBox.Children.Add(tb);
                }
                ItemModBox.Children.Clear();
                foreach (ModCraft m in item.LiveMods)
                {
                    PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                    DockPanel  dock        = new DockPanel();

                    string header = "";
                    if (modtemplate.generation_type == ModLogic.Prefix)
                    {
                        header = "[P] ";
                    }
                    else if (modtemplate.generation_type == ModLogic.Suffix)
                    {
                        header = "[S] ";
                    }
                    TextBlock affix = new TextBlock()
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.DarkGray, Text = header
                    };
                    DockPanel.SetDock(affix, Dock.Right);
                    dock.Children.Add(affix);
                    if (AllowEdit)
                    {
                        Button lockbutton = new Button()
                        {
                            Width = 20, Tag = m
                        };
                        Image lockimg = new Image {
                            Source = m.IsLocked ? Icons.Lock : Icons.Unlock
                        };
                        lockbutton.Content    = lockimg;
                        lockbutton.Background = m.IsLocked ? Brushes.Red : Brushes.Green;
                        lockbutton.Click     += LockButton_Click;
                        DockPanel.SetDock(lockbutton, Dock.Left);
                        dock.Children.Add(lockbutton);
                    }
                    StackPanel     sp        = new StackPanel();
                    IList <string> statlines = m.ToString().Split('\n');
                    foreach (string s in statlines)
                    {
                        TextBlock tb = new TextBlock()
                        {
                            TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Text = s, ToolTip = modtemplate.name + ": " + modtemplate
                        };
                        if (modtemplate.domain == "crafted")
                        {
                            tb.Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242));
                        }
                        else
                        {
                            tb.Foreground = new SolidColorBrush(Color.FromRgb(136, 136, 255));
                        }
                        HookEvents(tb);
                        sp.Children.Add(tb);
                    }
                    dock.Children.Add(sp);
                    ItemModBox.Children.Add(dock);
                }
                FillPropertyBox(item);
                if (item.TempProps != null)
                {
                    foreach (string tp in item.TempProps.Keys)
                    {
                        TextBlock tb = new TextBlock()
                        {
                            TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = Brushes.DarkGray, Text = tp + ": " + item.TempProps[tp], Tag = tp
                        };
                        HookEvents(tb);
                        TempPropBox.Children.Add(tb);
                    }
                }
            }
            else
            {
                ItemNameBox.Foreground = Brushes.White;
                ItemNameBox.Text       = "";
                ItemDataBox.Text       = "";
                PropertyBox.Children.Clear();
                ImplicitBox.Children.Clear();
                ItemModBox.Children.Clear();
                TempPropBox.Children.Clear();
            }
        }
Example #7
0
        private void FillPropertyBox(ItemCraft item)
        {
            PropertyBox.Children.Clear();
            PseudoPropBox.Children.Clear();
            SolidColorBrush white = new SolidColorBrush(Colors.White);
            SolidColorBrush blue  = new SolidColorBrush(Color.FromRgb(136, 136, 255));
            SolidColorBrush gray  = new SolidColorBrush(Colors.DarkGray);
            ItemProperties  p     = ItemParser.ParseProperties(item);
            ItemProperties  sp    = CraftingDatabase.AllBaseItems[item.SourceData].properties;
            StackPanel      panel;

            if (p.quality > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                string t;
                switch (item.QualityType)
                {
                case "Prismatic Catalyst":
                    t = "Quality (Resistance Modifiers): ";
                    break;

                case "Fertile Catalyst":
                    t = "Quality (Life and Mana Modifiers): ";
                    break;

                case "Intrinsic Catalyst":
                    t = "Quality (Attribute Modifiers): ";
                    break;

                case "Tempering Catalyst":
                    t = "Quality (Defence Modifiers): ";
                    break;

                case "Abrasive Catalyst":
                    t = "Quality (Attack Modifiers): ";
                    break;

                case "Imbued Catalyst":
                    t = "Quality (Caster Modifiers): ";
                    break;

                case "Turbulent Catalyst":
                    t = "Quality (Elemental Damage): ";
                    break;

                default:
                    t = "Quality: ";
                    break;
                }
                panel.Children.Add(new TextBlock()
                {
                    Text = t, FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = "+" + p.quality + "%", FontWeight = FontWeights.Bold, Foreground = blue, Tag = "Quality"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.block > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Chance to Block: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = p.block.ToString(), FontWeight = FontWeights.Bold, Foreground = (p.block == sp.block) ? white : blue, Tag = "Block"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.armour > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Armour: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = p.armour.ToString(), FontWeight = FontWeights.Bold, Foreground = (p.armour == sp.armour) ? white : blue, Tag = "Armour"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.evasion > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Evasion: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = p.evasion.ToString(), FontWeight = FontWeights.Bold, Foreground = (p.evasion == sp.evasion) ? white : blue, Tag = "Evasion"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.energy_shield > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Energy Shield: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = p.energy_shield.ToString(), FontWeight = FontWeights.Bold, Foreground = (p.energy_shield == sp.energy_shield) ? white : blue, Tag = "Energy Shield"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.physical_damage_max > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Physical Damage: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = p.physical_damage_min + "-" + p.physical_damage_max, FontWeight = FontWeights.Bold, Foreground = (p.physical_damage_max == sp.physical_damage_max) ? white : blue, Tag = "Physical Damage"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.critical_strike_chance > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Critical Strike Chance: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = ((double)p.critical_strike_chance / 100).ToString("N2"), FontWeight = FontWeights.Bold, Foreground = (p.critical_strike_chance == sp.critical_strike_chance) ? white : blue, Tag = "Critical Strike Chance"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.attack_time > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new TextBlock()
                {
                    Text = "Attacks per Second: ", FontWeight = FontWeights.Bold, Foreground = gray
                });
                TextBlock tb = new TextBlock()
                {
                    Text = ((double)1000 / p.attack_time).ToString("N2"), FontWeight = FontWeights.Bold, Foreground = (p.attack_time == sp.attack_time) ? white : blue, Tag = "Attack Speed"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                PropertyBox.Children.Add(panel);
            }
            if (p.physical_damage_max > 0 && p.attack_time > 0)
            {
                panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right, FlowDirection = FlowDirection.RightToLeft
                };
                TextBlock tb = new TextBlock()
                {
                    Text = ((p.physical_damage_min + p.physical_damage_max) * 500 / (double)p.attack_time).ToString("N2"), FontWeight = FontWeights.Bold, Foreground = blue, Tag = "Physical DPS"
                };
                HookEvents(tb);
                panel.Children.Add(tb);
                panel.Children.Add(new TextBlock()
                {
                    Text = "DPS: ", FontWeight = FontWeights.Bold, Foreground = gray, FlowDirection = FlowDirection.LeftToRight
                });
                PseudoPropBox.Children.Add(panel);
            }
        }