Пример #1
0
 private static WRLDDAT.Location FindLocationOfShop(ShopData.ShopDefinition shop, ShopData.ShopData shops, WRLDDAT.WRLDDAT locations)
 {
     foreach (var loc in locations.LocationIdDict)
     {
         if (loc.Value.Category == 1)
         {
             foreach (var shopid in loc.Value.ShopsOrEnemyGroups)
             {
                 if (shopid != 0)
                 {
                     if (shopid == shop.InGameID)
                     {
                         return(loc.Value);
                     }
                     uint shopIdEvolve = shopid;
                     while (shops.ShopDictionary[shopIdEvolve].ChangeToShop != 0)
                     {
                         shopIdEvolve = shops.ShopDictionary[shopIdEvolve].ChangeToShop;
                         if (shopIdEvolve == shop.InGameID)
                         {
                             return(loc.Value);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Пример #2
0
        public static string GetItemDataAsHtml(GameVersion version, string versionPostfix, GameLocale locale, WebsiteLanguage websiteLanguage, ItemDat items, ItemDatSingle item, T8BTSK.T8BTSK skills, T8BTEMST.T8BTEMST enemies, COOKDAT.COOKDAT Recipes, WRLDDAT.WRLDDAT Locations, ShopData.ShopData shopData, TOVSEAF.TOVSEAF searchPoints, TSS.TSSFile tss, Dictionary <uint, TSS.TSSEntry> dict, bool phpLinks = false)
        {
            if (dict == null)
            {
                dict = tss.GenerateInGameIdDictionary();
            }
            bool trustItemBookForShops   = true;           // true to use the values of the item book for shop locations; false to parse it out from the actual data
            bool trustItemBookForEnemies = false;          // true to use the values of the item book for enemy drop/steal lists; false to parse it out from the actual data

            var sb = new StringBuilder();

            sb.Append("<tr id=\"item" + item.Data[(int)ItemData.ID] + "\">");
            sb.Append("<td rowspan=\"3\">");

            sb.Append("<img src=\"items/U_" + item.ItemString.TrimNull() + ".png\" height=\"128\" width=\"128\">");
            sb.Append("</td><td colspan=\"2\">");

            uint equip = item.Data[(int)ItemData.EquippableByBitfield];

            if (equip > 0)
            {
                sb.Append("<span class=\"equip\">");
                Website.WebsiteGenerator.AppendCharacterBitfieldAsImageString(sb, dict, version, equip, websiteLanguage.MainJp());
                sb.Append("</span>");
            }


            var nameEntry = dict[item.NamePointer];
            var descEntry = dict[item.DescriptionPointer];

            if (websiteLanguage.WantsJp())
            {
                sb.Append("<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> ");
                sb.Append("<span class=\"itemname\">");
                sb.Append(nameEntry.StringJpnHtml(version, dict));
                sb.Append("</span>");
                sb.Append("<br>");
                sb.Append("<span class=\"itemdesc\">");
                sb.Append(descEntry.StringJpnHtml(version, dict));
                sb.Append("</span>");
            }

            if (websiteLanguage.WantsBoth())
            {
                sb.Append("<br>");
                sb.Append("<br>");
            }

            if (websiteLanguage.WantsEn())
            {
                sb.Append("<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> ");
                sb.Append("<span class=\"itemname\">");
                sb.Append(nameEntry.StringEngHtml(version, dict));
                sb.Append("</span>");
                sb.Append("<br>");
                sb.Append("<span class=\"itemdesc\">");
                sb.Append(descEntry.StringEngHtml(version, dict));
                sb.Append("</span>");
            }

            sb.Append("<span class=\"special\">");
            if (item.Data[(int)ItemData.UsableInBattle] > 0)
            {
                sb.Append("Usable in battle");
            }
            ;
            if (item.Data[(int)ItemData.InCollectorsBook] == 0)
            {
                sb.Append("Not in Collector's Book");
            }
            sb.Append("</span>");
            sb.Append("</td>");

            uint synthCount = item.Data[(int)ItemData.SynthRecipeCount];

            switch (synthCount)
            {
            case 0: break;

            case 1: sb.Append("<td colspan=\"2\">"); break;

            default: sb.Append("<td>"); break;
            }
            for (int j = 0; j < synthCount; ++j)
            {
                uint synthItemCount = item.Data[(int)ItemData.Synth1ItemSlotCount + j * 16];
                sb.Append("Synthesis Level: " + item.Data[(int)ItemData._Synth1Level + j * 16]);
                sb.Append("<br>");
                sb.Append("Price: " + item.Data[(int)ItemData.Synth1Price + j * 16] + " Gald");
                for (int i = 0; i < synthItemCount; ++i)
                {
                    sb.Append("<br>");
                    var    otherItem          = items.itemIdDict[item.Data[(int)ItemData.Synth1Item1Type + i * 2 + j * 16]];
                    var    otherItemNameEntry = dict[otherItem.NamePointer];
                    string otherItemName      = otherItemNameEntry.StringEngOrJpnHtml(version, dict, websiteLanguage);
                    sb.Append("<img src=\"item-icons/ICON" + otherItem.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> ");
                    sb.Append("<a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Item, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)otherItem.Data[(int)ItemData.ID], icon: (int)otherItem.Data[(int)ItemData.Icon]) + "\">");
                    sb.Append(otherItemName + "</a> x" + item.Data[(int)ItemData.Synth1Item1Count + i * 2 + j * 16]);
                }
                if (synthCount > 1 && j == 0)
                {
                    sb.Append("</td><td>");
                }
            }

            sb.Append("</td></tr><tr>");

            uint category = item.Data[(int)ItemData.Category];

            switch (category)
            {
            case 2:
            default:
                sb.Append("<td colspan=\"2\">");
                if (item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0)
                {
                    sb.Append("HP Heal %: " + item.Data[(int)ItemData.MDEF_or_HPHealPercent] + "<br>");
                }
                if (item.Data[(int)ItemData.AGL_TPHealPercent] > 0)
                {
                    sb.Append("TP Heal %: " + item.Data[(int)ItemData.AGL_TPHealPercent] + "<br>");
                }

                // why is this here twice?
                uint physAilAlt = item.Data[(int)ItemData.PDEF];
                uint physAil    = item.Data[(int)ItemData._LUCK];
                if (physAil != physAilAlt)
                {
                    throw new Exception();
                }

                if (physAil > 0)
                {
                    sb.Append("Cures physical ailments: ");
                    if ((physAil & 1) == 1)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-13.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 2) == 2)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-01.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 4) == 4)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-02.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 8) == 8)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-03.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 16) == 16)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-04.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 32) == 32)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-05.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 64) == 64)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-06.png\" height=\"32\" width=\"32\">");
                    }
                    if ((physAil & 128) == 128)
                    {
                        sb.Append("<img src=\"text-icons/icon-status-07.png\" height=\"32\" width=\"32\">");
                    }
                    sb.Append("<br>");
                }

                if (item.Data[(int)ItemData._AGL_Again] > 0)
                {
                    sb.Append("Cures magical ailments<br>");
                }

                if (item.Data[(int)ItemData.PermanentPAtkIncrease] > 0)
                {
                    sb.Append("Permanent PATK increase: " + item.Data[(int)ItemData.PermanentPAtkIncrease] + "<br>");
                }
                if (item.Data[(int)ItemData.PermanentPDefIncrease] > 0)
                {
                    sb.Append("Permanent PDEF increase: " + item.Data[(int)ItemData.PermanentPDefIncrease] + "<br>");
                }
                if (item.Data[(int)ItemData.AttrFire] > 0)
                {
                    sb.Append("Permanent MATK increase: " + item.Data[(int)ItemData.AttrFire] + "<br>");
                }
                if (item.Data[(int)ItemData.AttrWater] > 0)
                {
                    sb.Append("Permanent MDEF increase: " + item.Data[(int)ItemData.AttrWater] + "<br>");
                }
                if (item.Data[(int)ItemData.AttrWind] > 0)
                {
                    sb.Append("Permanent AGL increase: " + item.Data[(int)ItemData.AttrWind] + "<br>");
                }
                if (item.Data[(int)ItemData.Skill1] > 0)
                {
                    sb.Append("Max HP increase: " + item.Data[(int)ItemData.Skill1] + "<br>");
                }
                if (item.Data[(int)ItemData.Skill1Metadata] > 0)
                {
                    sb.Append("Max TP increase: " + item.Data[(int)ItemData.Skill1Metadata] + "<br>");
                }

                for (int i = 0; i < 8; ++i)
                {
                    int recipeId = (int)item.Data[(int)ItemData.UsedInRecipe1 + i];
                    if (recipeId != 0)
                    {
                        var recipe          = Recipes.RecipeList[recipeId];
                        var recipeNameEntry = dict[recipe.NameStringDicID];
                        sb.Append("<a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Recipe, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)recipe.ID) + "\">" + recipeNameEntry.StringEngOrJpnHtml(version, dict, websiteLanguage) + "</a><br>");
                    }
                }

                sb.Append("</td>");
                break;

            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                sb.Append("<td>");
                if ((int)item.Data[(int)ItemData.PATK] > 0)
                {
                    sb.Append("PATK: " + (int)item.Data[(int)ItemData.PATK] + "<br>");
                }
                if ((int)item.Data[(int)ItemData.MATK] > 0)
                {
                    sb.Append("MATK: " + (int)item.Data[(int)ItemData.MATK] + "<br>");
                }
                if ((int)item.Data[(int)ItemData.PDEF] > 0)
                {
                    sb.Append("PDEF: " + (int)item.Data[(int)ItemData.PDEF] + "<br>");
                }
                if ((int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0)
                {
                    sb.Append("MDEF: " + (int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] + "<br>");
                }

                int agl1 = (int)item.Data[(int)ItemData.AGL_TPHealPercent];
                int agl2 = (int)item.Data[(int)ItemData._AGL_Again];

                if (agl2 > 0)
                {
                    sb.Append("AGL: " + agl2 + "<br>");
                }

                if ((int)item.Data[(int)ItemData._LUCK] > 0)
                {
                    sb.Append("LUCK: " + (int)item.Data[(int)ItemData._LUCK] + "<br>");
                }


                int attackElementCount  = 0;
                int defenseElementCount = 0;
                for (int i = 0; i < 6; ++i)
                {
                    if ((int)item.Data[(int)ItemData.AttrFire + i] > 0)
                    {
                        attackElementCount++;
                    }
                    if ((int)item.Data[(int)ItemData.AttrFire + i] < 0)
                    {
                        defenseElementCount++;
                    }
                }

                if (attackElementCount > 0 || defenseElementCount > 0)
                {
                    int fire = (int)item.Data[(int)ItemData.AttrFire];
                    int watr = (int)item.Data[(int)ItemData.AttrWater];
                    int wind = (int)item.Data[(int)ItemData.AttrWind];
                    int eart = (int)item.Data[(int)ItemData.AttrEarth];
                    int lght = (int)item.Data[(int)ItemData.AttrLight];
                    int dark = (int)item.Data[(int)ItemData.AttrDark];
                    if (defenseElementCount > 0)
                    {
                        sb.Append("<table class=\"element\"><tr>");
                        sb.Append("<td colspan=\"" + defenseElementCount + "\">Resistance</td>");
                        sb.Append("</tr><tr>");
                        if (fire < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-02.png\"></td>");
                        }
                        if (eart < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-04.png\"></td>");
                        }
                        if (wind < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-01.png\"></td>");
                        }
                        if (watr < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-05.png\"></td>");
                        }
                        if (lght < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-03.png\"></td>");
                        }
                        if (dark < 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-06.png\"></td>");
                        }
                        sb.Append("</tr><tr>");
                        if (fire < 0)
                        {
                            sb.Append("<td>" + -fire + "%</td>");
                        }
                        if (eart < 0)
                        {
                            sb.Append("<td>" + -eart + "%</td>");
                        }
                        if (wind < 0)
                        {
                            sb.Append("<td>" + -wind + "%</td>");
                        }
                        if (watr < 0)
                        {
                            sb.Append("<td>" + -watr + "%</td>");
                        }
                        if (lght < 0)
                        {
                            sb.Append("<td>" + -lght + "%</td>");
                        }
                        if (dark < 0)
                        {
                            sb.Append("<td>" + -dark + "%</td>");
                        }
                        sb.Append("</tr></table>");
                    }
                    if (attackElementCount > 0)
                    {
                        sb.Append("<table class=\"element\"><tr>");
                        if (category == 3 || category == 4)
                        {
                            // weapons and sub-weapons add elemental attributes to your attack
                            sb.Append("<td colspan=\"" + attackElementCount + "\">Attack Element</td>");
                        }
                        else
                        {
                            // defensive equipment instead uses this field as a weak/resist, with weak as positive and resist as negative values
                            sb.Append("<td colspan=\"" + attackElementCount + "\">Weakness</td>");
                        }
                        sb.Append("</tr><tr>");
                        if (fire > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-02.png\"></td>");
                        }
                        if (eart > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-04.png\"></td>");
                        }
                        if (wind > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-01.png\"></td>");
                        }
                        if (watr > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-05.png\"></td>");
                        }
                        if (lght > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-03.png\"></td>");
                        }
                        if (dark > 0)
                        {
                            sb.Append("<td><img src=\"text-icons/icon-element-06.png\"></td>");
                        }
                        if (!(category == 3 || category == 4))
                        {
                            // weapons always have a "1" here, don't print that, it's not useful
                            sb.Append("</tr><tr>");
                            if (fire > 0)
                            {
                                sb.Append("<td>" + fire + "%</td>");
                            }
                            if (eart > 0)
                            {
                                sb.Append("<td>" + eart + "%</td>");
                            }
                            if (wind > 0)
                            {
                                sb.Append("<td>" + wind + "%</td>");
                            }
                            if (watr > 0)
                            {
                                sb.Append("<td>" + watr + "%</td>");
                            }
                            if (lght > 0)
                            {
                                sb.Append("<td>" + lght + "%</td>");
                            }
                            if (dark > 0)
                            {
                                sb.Append("<td>" + dark + "%</td>");
                            }
                        }
                        sb.Append("</tr></table>");
                    }
                }

                sb.Append("</td><td>");

                for (int i = 0; i < 3; ++i)
                {
                    uint skillId = item.Data[(int)ItemData.Skill1 + i * 2];
                    if (skillId != 0)
                    {
                        var    skill          = skills.SkillIdDict[skillId];
                        var    skillNameEntry = dict[skill.NameStringDicID];
                        string skillName      = skillNameEntry.StringEngOrJpnHtml(version, dict, websiteLanguage);
                        string skillCat       = "<img src=\"skill-icons/category-" + skill.Category.ToString() + ".png\" height=\"16\" width=\"16\">";
                        sb.Append(skillCat);
                        sb.Append("<a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Skill, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)skill.InGameID) + "\">");
                        sb.Append(skillName);
                        sb.Append("</a>, " + item.Data[(int)ItemData.Skill1Metadata + i * 2] + "<br>");
                    }
                }
                sb.Append("</td>");
                break;
            }



            sb.Append("<td>");


            sb.Append(item.Data[(int)ItemData.ShopPrice] + " Gald");

            if (trustItemBookForShops)
            {
                if (item.Data[(int)ItemData.BuyableIn1] > 0 || item.Data[(int)ItemData.BuyableIn2] > 0 || item.Data[(int)ItemData.BuyableIn3] > 0)
                {
                    //sb.Append( "<br>Available at shops in:" );
                    for (int i = 0; i < 3; ++i)
                    {
                        if (item.Data[(int)ItemData.BuyableIn1 + i] > 0)
                        {
                            var loc = Locations.LocationIdDict[item.Data[(int)ItemData.BuyableIn1 + i]];
                            sb.Append("<br><a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Location, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)loc.LocationID) + "\">");
                            sb.Append(loc.GetLastValidName(dict).StringEngOrJpnHtml(version, dict, websiteLanguage) + "</a>");
                        }
                    }
                }
            }
            else
            {
                List <ShopData.ShopDefinition> shops = new List <ShopData.ShopDefinition>();
                foreach (var kvp in shopData.ShopDictionary)
                {
                    ShopData.ShopDefinition shop = kvp.Value;
                    foreach (var shopItem in shop.ShopItems)
                    {
                        if (shopItem.ItemID == item.Data[(int)ItemData.ID])
                        {
                            shops.Add(shop);
                            break;
                        }
                    }
                }

                bool printShopsDirectly = false;
                if (printShopsDirectly)
                {
                    foreach (var shop in shops)
                    {
                        sb.Append("<br><a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Shop, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)shop.InGameID) + "\">");
                        sb.Append(dict[shop.StringDicID].StringEngOrJpnHtml(version, dict, websiteLanguage) + "</a>");
                    }
                }
                else
                {
                    foreach (var shop in shops)
                    {
                        WRLDDAT.Location loc = FindLocationOfShop(shop, shopData, Locations);
                        if (loc != null)
                        {
                            sb.Append("<br><a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Location, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)loc.LocationID) + "\">");
                            sb.Append(loc.GetLastValidName(dict).StringEngOrJpnHtml(version, dict, websiteLanguage) + "</a>");
                        }
                        else
                        {
                            sb.Append("<br><a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Shop, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)shop.InGameID) + "\">");
                            sb.Append(dict[shop.StringDicID].StringEngOrJpnHtml(version, dict, websiteLanguage) + "</a>");
                        }
                    }
                }
            }

            sb.Append("</td><td>");

            List <uint> itemsRequireSynth = FindItemsThatRequireForSynth(item.Data[(int)ItemData.ID], items);

            if (itemsRequireSynth.Count > 0)
            {
                sb.Append("Can be used to synthesize");
                foreach (uint otherItemId in itemsRequireSynth)
                {
                    ItemDatSingle otherItem = items.itemIdDict[otherItemId];
                    sb.Append("<br>");
                    var    otherItemNameEntry = dict[otherItem.NamePointer];
                    string otherItemName      = otherItemNameEntry.StringEngOrJpnHtml(version, dict, websiteLanguage);
                    sb.Append("<img src=\"item-icons/ICON" + otherItem.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> ");
                    sb.Append("<a href=\"" + Website.WebsiteGenerator.GetUrl(Website.WebsiteSection.Item, version, versionPostfix, locale, websiteLanguage, phpLinks, id: (int)otherItem.Data[(int)ItemData.ID], icon: (int)otherItem.Data[(int)ItemData.Icon]) + "\">");
                    sb.Append(otherItemName + "</a>");
                }
            }

            sb.Append("</td></tr><tr>");

            // drops and steals
            List <(uint enemyId, uint dropChance, uint?fatalType, uint?fatalIncrease)>[] enemyIds = new List <(uint enemyId, uint dropChance, uint?fatalType, uint?fatalIncrease)> [3];