Пример #1
0
        public static string[] GetDisplayStrings(Unit unit, bool inherent = false)
        {
            if (Manager == null) throw new Exception("FileManager Null");

            var strings = new List<string>();
            var itemDisplay = Manager.GetDataTable("ITEMDISPLAY");
            Evaluator = new Evaluator {Unit = unit, Context = new Context(), Manager = Manager};

            DataRow last = null;

            foreach (DataRow row in itemDisplay.Rows)
            {
                if (inherent)
                {
                    if (((int)row["toolTipArea"]) != 20)
                        continue;
                }
                else
                {
                    if (((int)row["toolTipArea"]) != 0 && !row["exampleDescription"].ToString().Contains("thorns"))
                        continue;
                }

                var rule1 = (Display.Rule)row["rule1"];
                var rule2 = (Display.Rule)row["rule2"];
                var rule3 = (Display.Rule)row["rule3"];

                if (rule1 == Display.Rule.Ditto) row["displayCondition1"] = last["displayCondition1"];
                if (rule2 == Display.Rule.Ditto) row["displayCondition2"] = last["displayCondition2"];
                if (rule3 == Display.Rule.Ditto) row["displayCondition3"] = last["displayCondition3"];

                var condition1 = (string) row["displayCondition1"];
                var condition2 = (string) row["displayCondition2"];
                var condition3 = (string) row["displayCondition3"];

                last = row;

                if (IsConditionMet(condition1) == false) continue;
                if (IsConditionMet(condition2) == false) continue;
                if (IsConditionMet(condition3) == false) continue;

                var result = GetDisplayString(row);
                if (String.IsNullOrEmpty(result)) continue;

                if (result.Contains("Thorns"))
                    result = FormatThorns(result);

                strings.Add(result);
            }

            string skill = GetSkillBonus(unit);
            if (!String.IsNullOrWhiteSpace(skill))
                strings.Add(skill);

            return strings.ToArray();
        }
Пример #2
0
 private string GetAffixes(int i)
 {
     if (i == -1) return string.Empty;
     var table = Manager.GetDataTable("AFFIXES");
     var affix = table.Rows[i]["property1"].ToString();
     var evaluator = new Evaluator { Unit = new Item() };
     evaluator.Evaluate(affix);
     var result = ItemDisplay.GetDisplayStrings(evaluator.Unit);
     var transform = ConcatStrings(result);
     return transform;
 }
Пример #3
0
        public override string ExportTableInsertScript()
        {
            SQLTableScript table = new SQLTableScript("id", "code",
                "id INT NOT NULL",
                "code VARCHAR(6) NOT NULL",
                //"isBossAffix BOOL NOT NULL",
                "name TEXT NOT NULL",
                "formatted_name TEXT NOT NULL",
                "display_string TEXT NOT NULL"
            );

            var affixes = Manager.GetDataTable("AFFIXES");

            string id, code, magicName, formattedName, displayString;
            string quality, property1;
            object shields;
            bool isBoss = false;

            Evaluator evaluator = new Evaluator();
            ItemDisplay.Manager = Manager;
            evaluator.Manager = Manager;

            foreach (DataRow row in affixes.Rows)
            {
                //don't show affixes that aren't used/implemented
                //if ((int)row["spawn"] == 0) continue;
                isBoss = false;

                magicName = row["magicNameString_string"].ToString();
                if (String.IsNullOrWhiteSpace(magicName)) continue;
                if (row["allowTypes1_string"].ToString() != "monster") continue;

                Unit unit = new Monster();
                Game3 game3 = new Game3();
                evaluator.Unit = unit;
                evaluator.Game3 = game3;
                for (int i = 1; i < 7; i++)
                {
                    property1 = row["property" + i].ToString();
                    evaluator.Evaluate(property1);
                }

                String[] displayStrings = ItemDisplay.GetDisplayStrings(unit);

                id = row["Index"].ToString();
                code = GetSqlString(((int)row["code"]).ToString("X"));

                magicName = magicName.Replace("[item]", string.Empty).Trim();
                isBoss = magicName.Contains("Sydonai");
                if (isBoss) continue;   //don't think we need boss titles
                formattedName = String.Format("'''{0}'''", magicName);

                quality = row["affixType1_string"].ToString();
                switch (quality)
                {
                    case "common":
                        //just leave it bold
                        break;
                    case "rare":
                        formattedName = Colorize(formattedName, WikiColors.Rare);
                        break;
                    case "legendary":
                        formattedName = Colorize(formattedName, WikiColors.Legendary);
                        break;
                    case "mythic":
                        formattedName = Colorize(formattedName, WikiColors.Mythic);
                        break;
                    default:
                        throw new NotImplementedException(String.Format("Apparently we need '{0}'?", quality));
                }
                magicName = GetSqlString(magicName);
                formattedName = GetSqlString(formattedName);
                displayString = displayStrings.Aggregate(string.Empty, (current, affix) => current + affix + "<br />");
                displayString = displayString.Replace(" you get", "");   //display "when hit" instead of "when you get hit"
                //manually add shields if needed (never a number)
                shields = unit.GetStat("shield_buffer_max");
                if (!(shields is int))
                    displayString = displayString.Replace("ilevel", shields.ToString());    //hacky, but whatever
                //add procs and skills
                displayString += AddOtherProperties(unit);
                displayString = GetSqlString(displayString);
                //Debug.WriteLine(id + ", " + row["affix"] + ", " + displayString);

                table.AddRow(id, code, /*Convert.ToInt32(isBoss).ToString(),*/ magicName, formattedName, displayString);

            }

            return table.GetFullScript();
        }
Пример #4
0
        private string GetDamage(DataRow item,Unit unit)
        {
            if (string.IsNullOrEmpty(item["minBaseDmg"].ToString())) return string.Empty;

            //var unit = new Item();
            var evaluator = new Evaluator { Unit = unit, Manager = Manager, Game3 = new Game3() };
            //var level = !string.IsNullOrEmpty(item["fixedLevel"].ToString()) ? Int32.Parse(item["fixedLevel"].ToString().Replace(";", "")) : (int)item["level"];
            //if (item["itemQuality"].ToString() == "12") level = 63; //manually correct mythic (although it seems to use a different ilvl anyway)
            var dmgMin = Int32.Parse(item["minBaseDmg"].ToString().Replace(";", ""));
            var dmgMax = Int32.Parse(item["maxBaseDmg"].ToString().Replace(";", ""));
            var dmgIncrement = (int) item["dmgIncrement"];
            var radialIncrement = (int) item["radialDmgIncrement"];
            var fieldIncrement = (int) item["fieldDmgIncrement"];
            //var dotIncrement = (int) item["dotDmgIncrement"]; // doesnt seem to be used
            //custom stuff for beam and hive damage (temporary until the type stuff is redone)
            //beam - direct damage of any element, or HARP
            bool isBeam = item["unitType_string"].ToString().Contains("beam") || item["unitType_string"].ToString().Contains("harp");
            //hive - any hive/funky bug thing weapon, used for eel (direct) and swarm (splash, never used)
            bool isHive = item["unitType_string"].ToString().Contains("hive") || item["unitType_string"].ToString().Contains("cabalist_bug2h_achiev");
            unit.SetStat("isBeam", isBeam ? 1 : 0);
            unit.SetStat("isHive", isHive ? 1 : 0);

            unit.SetStat("damage_min", dmgMin);
            unit.SetStat("damage_max", dmgMax);
            //unit.SetStat("level", level);
            unit.SetStat("dmg_increment", dmgIncrement);
            unit.SetStat("radial_increment", radialIncrement);
            unit.SetStat("field_increment", fieldIncrement);

            var scripts = item["props1"].ToString() + item["props2"] + item["props3"] + item["props4"] + item["props5"];
            evaluator.Evaluate(scripts);

            var builder = new StringBuilder();

            var values = unit.GetStat("dmg_fire");
            if (!(values is int))
            {
                string fireDmg;
                if (isBeam)
                    fireDmg = FormatBeamDmg((Dictionary<string, object>)values, "Fire");
                else
                    fireDmg = FormatDirectDmg((Dictionary<string, object>)values, "Fire");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dmg_spec");
            if (!(values is int))
            {
                string fireDmg;
                if (isBeam)
                    fireDmg = FormatBeamDmg((Dictionary<string, object>)values, "Spectral");
                else
                    fireDmg = FormatDirectDmg((Dictionary<string, object>)values, "Spectral");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dmg_phys");
            if (!(values is int))
            {
                string fireDmg;
                if (isBeam)
                    fireDmg = FormatBeamDmg((Dictionary<string, object>)values, "Physical");
                else
                    fireDmg = FormatDirectDmg((Dictionary<string, object>)values, "Physical");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dmg_toxic");
            if (!(values is int))
            {
                string fireDmg;
                if (isBeam)
                    fireDmg = FormatBeamDmg((Dictionary<string, object>)values, "Toxic");
                else
                    fireDmg = FormatDirectDmg((Dictionary<string, object>)values, "Toxic");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dmg_elec");
            if (!(values is int))
            {
                string fireDmg;
                if (isBeam)
                    fireDmg = FormatBeamDmg((Dictionary<string, object>)values, "Electricity");
                else if (isHive)
                    fireDmg = FormatEelDmg((Dictionary<string, object>)values, "Electricity");  //item display says it uses splash, but IT LIES
                else
                    fireDmg = FormatDirectDmg((Dictionary<string, object>)values, "Electricity");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_fire");
            if (!(values is int))
            {
                var fireDmg = FormatSplashDmg((Dictionary<string, object>)values, "Fire");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_spec");
            if (!(values is int))
            {
                var fireDmg = FormatSplashDmg((Dictionary<string, object>)values, "Spectral");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_phys");
            if (!(values is int))
            {
                var fireDmg = FormatSplashDmg((Dictionary<string, object>)values, "Physical");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_toxic");
            if (!(values is int))
            {
                string fireDmg;
                if (isHive)
                    fireDmg = FormatSwarmDmg((Dictionary<string, object>)values, "Toxic");
                else
                    fireDmg = FormatSplashDmg((Dictionary<string, object>)values, "Toxic");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_elec");
            if (!(values is int))
            {
                string fireDmg;
                //if (isHive)
                    //fireDmg = FormatEelDmg((Dictionary<string, object>)values, "Electricity");
                //else
                    fireDmg = FormatSplashDmg((Dictionary<string, object>)values, "Electricity");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("field_fire");
            if (!(values is int))
            {
                var fireDmg = FormatFieldDmg((Dictionary<string, object>)values, "Fire");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("field_spec");
            if (!(values is int))
            {
                var fireDmg = FormatFieldDmg((Dictionary<string, object>)values, "Spectral");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("field_phys");
            if (!(values is int))
            {
                var fireDmg = FormatFieldDmg((Dictionary<string, object>)values, "Physical");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("field_toxic");
            if (!(values is int))
            {
                var fireDmg = FormatFieldDmg((Dictionary<string, object>)values, "Toxic");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("field_elec");
            if (!(values is int))
            {
                var fireDmg = FormatFieldDmg((Dictionary<string, object>)values, "Electricity");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dot_fire");
            if (!(values is int))
            {
                var fireDmg = FormatDotDmg((Dictionary<string, object>)values, "Fire");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dot_spec");
            if (!(values is int))
            {
                var fireDmg = FormatDotDmg((Dictionary<string, object>)values, "Spectral");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dot_phys");
            if (!(values is int))
            {
                var fireDmg = FormatDotDmg((Dictionary<string, object>)values, "Physical");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dot_toxic");
            if (!(values is int))
            {
                var fireDmg = FormatDotDmg((Dictionary<string, object>)values, "Toxic");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("dot_elec");
            if (!(values is int))
            {
                var fireDmg = FormatDotDmg((Dictionary<string, object>)values, "Electricity");
                builder.Append(fireDmg);
            }

            values = unit.GetStat("rad_toxic_hive");
            if (!(values is int))
            {
                var fireDmg = FormatSwarmDmg((Dictionary<string, object>)values, "Toxic");
                builder.Append(fireDmg);
            }

            //if there's no damage to display, it must be a focus item that has power damage
            if (builder.Length == 0)
            {
                DataRow lvlRow = Manager.GetDataTable("ITEM_LEVELS").Rows[(int)unit.GetStat("level")];
                builder.Append(string.Format("'''Power''': {0}-{1}",
                    (int)(dmgMin / 100.0 * (int)lvlRow["baseDamageMultiplyer"]),
                    (int)(dmgMax / 100.0 * (int)lvlRow["baseDamageMultiplyer"])
                    ));
            }

            return builder.ToString();
        }
Пример #5
0
        private IList<string> GetAffixes(DataRow item, Unit unit)
        {
            var evaluator = new Evaluator {Unit = unit, Manager = Manager, Game3 = new Game3()};
            var table = Manager.GetDataTable("AFFIXES");
            var affixes = item["affix"].ToString();

            //var level = !string.IsNullOrEmpty(item["fixedLevel"].ToString()) ?  Int32.Parse(item["fixedLevel"].ToString().Replace(";", "")) : (int)item["level"];
            //if (level == 0) level = 55;
            //evaluator.Unit.SetStat("level", level);

            string[] split = affixes.Split(',');
            foreach (var i in split)
            {
                var affix = int.Parse(i);
                if (affix == -1) break; // no more affixes
                var script = table.Rows[affix]["property1"].ToString();
                script += table.Rows[affix]["property2"].ToString();
                script += table.Rows[affix]["property3"].ToString();
                script += table.Rows[affix]["property4"].ToString();
                script += table.Rows[affix]["property5"].ToString();
                script += table.Rows[affix]["property6"].ToString();
                script = RemoveLevelSetters(script);
                if (String.IsNullOrEmpty(script)) continue; // no affix script
                evaluator.Evaluate(script);
            }

            return ItemDisplay.GetDisplayStrings(evaluator.Unit);
        }
Пример #6
0
        private string GetModSlots(string modsScript)
        {
            var evaluator = new Evaluator { Unit = new Item() };
            evaluator.Evaluate(modsScript);

            var strings = new StringBuilder();
            var itemSlots = evaluator.Unit.GetStat("item_slots");
            if (itemSlots is int) return strings.ToString();

            var noSlots = string.Empty;
            int slotsAdded = 0;

            strings.Append("<div class=\"simple_line\"></div>");
            strings.Append("<div class=\"item_mods\">");
            strings.Append("<table>");
            strings.Append("<tr>");
            foreach (var slot in (Dictionary<string, object>)itemSlots)
            {
                //skip slots with 0
                if (slot.Value is double && ((double)slot.Value) == 0) continue;

                slotsAdded++;

                //int maxSlot = (slot.Value is Evaluator.Range) ? ((Evaluator.Range) slot.Value).End : Convert.ToInt32(slot.Value);
                strings.Append("<td>");
                //for (int i = 0; i < maxSlot; i++)
                    strings.Append(GetImage(slot.Key + ".png", 48));
                strings.Append("</td>");
                noSlots += "<td>" + slot.Value + "</td>";
            }
            strings.Append("</tr>");
            strings.Append("<tr>" + noSlots + "</tr>");
            strings.Append("</table>");
            strings.Append("</div>");

            //if no slots were added, return blank (might not be able to effectively determine this before the loop)
            if (slotsAdded == 0) return string.Empty;

            return strings.ToString();
        }
Пример #7
0
        private IList<string> GetInherentAffixes(DataRow item, Unit baseUnit)
        {
            Unit unit = new Item();
            unit.SetStat("level", baseUnit.GetStat("level"));   //copy the level into a new unit so it won't re-display everything
            var evaluator = new Evaluator { Unit = unit, Manager = Manager, Game3 = new Game3() };
            var scripts = item["props1"].ToString() + item["props2"] + item["props3"] + item["props4"] + item["props5"];

            //it might be hidden but it's a fraction that's likely rounded to 0, so it's not worth displaying
            scripts = scripts.Replace("SetStat673('hp_regen', 1);", "").Replace("SetStat673('power_regen', 1);", "");
            //also get rid of any explicit level-setting
            scripts = RemoveLevelSetters(scripts);

            //var level = !string.IsNullOrEmpty(item["fixedLevel"].ToString()) ?  Int32.Parse(item["fixedLevel"].ToString().Replace(";", "")) : (int)item["level"];
            //evaluator.Unit.SetStat("level", level);

            evaluator.Evaluate(scripts);
            return ItemDisplay.GetDisplayStrings(evaluator.Unit);
        }
Пример #8
0
        private string GetFeeds(int itemid, Unit unit)
        {
            //Unit unit = new Item();
            var evaluator = new Evaluator { Unit = unit, Manager = Manager };
            var item = Manager.GetDataTable("ITEMS").Rows[itemid];
            var table = Manager.GetDataTable("AFFIXES");
            var affixes = item["affix"].ToString();
            var scripts = item["perLevelProps1"].ToString();
            scripts += item["perLevelProps2"].ToString();

            //var level = !string.IsNullOrEmpty(item["fixedLevel"].ToString()) ?  Int32.Parse(item["fixedLevel"].ToString().Replace(";", "")) : (int)item["level"];
            //evaluator.Unit.SetStat("level", level);

            string[] split = affixes.Split(',');
            foreach (var i in split)
            {
                var affix = int.Parse(i);
                if (affix == -1) break; // no more affixes
                var script = table.Rows[affix]["property1"].ToString();
                script += table.Rows[affix]["property2"].ToString();
                script += table.Rows[affix]["property3"].ToString();
                script += table.Rows[affix]["property4"].ToString();
                script += table.Rows[affix]["property5"].ToString();
                script += table.Rows[affix]["property6"].ToString();
                script = RemoveLevelSetters(script);
                if (String.IsNullOrEmpty(script)) continue; // no affix script
                evaluator.Evaluate(script);
            }

            if (scripts != string.Empty) evaluator.Evaluate(scripts);

            var strings = new List<string>();

            string feed = string.Empty;

            var accuracy = unit.GetStat("accuracy_feed");
            if ((accuracy is double && (double)accuracy != 0)
                || accuracy is string || accuracy is Evaluator.Range)
            {
                feed = ItemDisplay.FormatFeed(accuracy);
                strings.Add(feed + " Acc");
            }

            var strength = unit.GetStat("strength_feed");
            if ((strength is double && (double)strength != 0)
                || strength is string || strength is Evaluator.Range)
            {
                feed = ItemDisplay.FormatFeed(strength);
                strings.Add(feed + " Str");
            }

            var stamina = unit.GetStat("stamina_feed");
            if ((stamina is double && (double)stamina != 0)
                || stamina is string || stamina is Evaluator.Range)
            {
                feed = ItemDisplay.FormatFeed(stamina);
                strings.Add(feed + " Stam");
            }

            var willpower = unit.GetStat("willpower_feed");
            if ((willpower is double && (double)willpower != 0)
                || willpower is string || willpower is Evaluator.Range)
            {
                feed = ItemDisplay.FormatFeed(willpower);
                strings.Add(feed + " Will");
            }

            if (strings.Count == 0) return string.Empty;
            return "<div class=\"simple_line\"></div><div class=\"item_feed\">" + GetCSVString(strings) + "</div>";
        }
Пример #9
0
        public override string ExportTableInsertScript()
        {
            SQLTableScript table = new SQLTableScript("id", "code",
                "id INT NOT NULL",
                "code VARCHAR(6) NOT NULL",
                "name TEXT NOT NULL",
                "formatted_name TEXT NOT NULL",
                "display_string TEXT NOT NULL",
                "ilvl_range TEXT NOT NULL",
                "allowed_types TEXT NOT NULL",
                "faction TEXT"
                , "feed_costs TEXT NOT NULL"
            );

            var affixes = Manager.GetDataTable("AFFIXES");

            string id, code, magicName, formattedName, displayString, levelRange, typeList, faction;
            string[] feeds;
            string quality, property1, allowType;
            bool isMonster = false;

            Evaluator evaluator = new Evaluator();
            ItemDisplay.Manager = Manager;
            evaluator.Manager = Manager;

            foreach (DataRow row in affixes.Rows)
            {
                //don't show affixes that aren't used/implemented
                if ((int)row["spawn"] == 0) continue;
                isMonster = false;

                magicName = row["magicNameString_string"].ToString();
                if (String.IsNullOrWhiteSpace(magicName)) continue;

                typeList = string.Empty;
                faction = row["onlyOnItemsRequiringUnitType_string"].ToString();
                if (!String.IsNullOrWhiteSpace(faction))
                    faction = GetSqlString(faction);

                for (int i = 1; i < 7; i++)
                {
                    allowType = row[String.Format("allowTypes{0}_string", i)].ToString();
                    if (String.IsNullOrWhiteSpace(allowType))
                        break;
                    else if (allowType.CompareTo("monster") == 0)
                    {
                        isMonster = true;
                        break;
                    }

                    if (!String.IsNullOrWhiteSpace(typeList))
                        typeList += ", ";

                    typeList += GetItemType(allowType);
                }

                if (isMonster) continue;

                typeList = GetSqlString(typeList);
                levelRange = GetSqlString(row["minLevel"].ToString() + "-" + row["maxLevel"].ToString());

                Unit unit = new Item();
                Game3 game3 = new Game3();
                evaluator.Unit = unit;
                evaluator.Game3 = game3;
                for (int i = 1; i < 7; i++)
                {
                    property1 = row["property" + i].ToString();
                    evaluator.Evaluate(property1);
                }

                String[] displayStrings = ItemDisplay.GetDisplayStrings(unit);
                feeds = ItemDisplay.GetFeedCosts(unit);

                id = row["Index"].ToString();
                code = GetSqlString(((int)row["code"]).ToString("X"));

                magicName = magicName.Replace("[item]", string.Empty).Trim();
                formattedName = String.Format("'''{0}'''", magicName);

                quality = row["affixType1_string"].ToString();
                switch (quality)
                {
                    case "common":
                        //just leave it bold
                        break;
                    case "rare":
                        formattedName = Colorize(formattedName, WikiColors.Rare);
                        break;
                    case "legendary":
                        formattedName = Colorize(formattedName, WikiColors.Legendary);
                        break;
                    case "mythic":
                        formattedName = Colorize(formattedName, WikiColors.Mythic);
                        break;
                    default:
                        throw new NotImplementedException(String.Format("Apparently we need '{0}'?", quality));
                }
                magicName = GetSqlString(magicName);
                formattedName = GetSqlString(formattedName);
                displayString = GetSqlString(FormatAffixList(displayStrings));

                Debug.WriteLine(id + ", " + row["affix"] + ", " + displayString);

                table.AddRow(id, code, magicName, formattedName, displayString, levelRange, typeList, faction, GetSqlString(FormatAffixList(feeds)));
            }

            return table.GetFullScript();
        }