Exemple #1
0
        private static FFXIVItem ReadReducedItem(System.Windows.Forms.TextBox iLogBox, JToken reducedToken)
        {
            FFXIVItem        item;
            FFXIVReducedItem reducedItem = new FFXIVReducedItem();

            reducedItem.Type = FFXIVItem.TypeItem.Reduced;

            string    idReducedFrom = reducedToken[0].Value <string>();
            FFXIVItem ingredient    = RecBuildCraftingTree(iLogBox, idReducedFrom, 5);

            if (null != ingredient)
            {
                reducedItem.ReducedFrom = ingredient;

                if (ingredient is FFXIVGatheredItem)
                {
                    FFXIVGatheredItem gatheredItem = ingredient as FFXIVGatheredItem;
                    if (null != gatheredItem)
                    {
                        gatheredItem.AsCollectable = true;
                    }
                }
            }
            else
            {
                Service_Misc.LogText(iLogBox, "Oups... failed to retrieve one reduced reference : ID=" + idReducedFrom);
            }

            item = reducedItem;
            return(item);
        }
Exemple #2
0
        public static string GetCraftingPreset(string gatheringType, string iSlot, FFXIVGatheredItem iGatheredItem, string iRotation, string iGridName, string iTime)
        {
            if (null == iGatheredItem)
            {
                return("");
            }

            //Looking into cache directory
            string        presetItemName = iGatheredItem.Name + " preset";
            DirectoryInfo exeDirectory   = new DirectoryInfo(Service_Misc.GetExecutionPath());
            DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGatheringPreset"));

            if (!cacheDirectory.Exists)
            {
                cacheDirectory.Create();
            }

            FileInfo cacheGridFile = new FileInfo(Path.Combine(cacheDirectory.FullName, presetItemName + ".txt"));
            string   rawPreset     = "";

            if (cacheGridFile.Exists)
            {
                rawPreset = System.IO.File.ReadAllText(cacheGridFile.FullName);
            }
            else
            {
                string useCompass = "******";
                if (gatheringType == "1" || gatheringType == "3")
                {
                    useCompass = "******";
                }
                string useCompass2 = "false";
                if (gatheringType == "1" || gatheringType == "3")
                {
                    useCompass2 = "true";
                }
                rawPreset = "gatherpreset." + presetItemName + Environment.NewLine;
                string nodeName = "";
                string slot     = "";
                string useTruth = "false";
                if (iTime != "")
                {
                    useTruth = "true";
                    //fullScenario += "afkUntil(" + time.Split(',')[0] + ":00et)" + Environment.NewLine;
                }
                {
                    slot     = "0";
                    nodeName = iGatheredItem.Name;

                    {
                        nodeName = nodeName + "\",\"Crystal\",\"Shard";
                    }
                }
                rawPreset += "{\"owntab\":0,\"assistmode\":false,\"nodename\":\"\",\"slot\":" + slot + ",\"maxcount\":32,\"usecompass\":" + useCompass + ",\"usecompass2\":" + useCompass2 + ",\"usetruth\":" + useTruth + ",\"userotation\":true,\"usemacro\":false,\"macro\":\"\",\"speargig\":0,\"spearshadows\":0,\"usecordials\":true,\"usefavors\":false,\"spearcollect\":true,\"spearcollectability\":1,\"byname\":[\"" + nodeName + "\"],\"veterantradebyname\":[],\"gridname\":\"" + iGridName + "\",\"rotationname\":\"" + "" + "\"}" + Environment.NewLine;
            }

            //System.IO.File.WriteAllText(cacheGridFile.FullName, rawPreset);

            rawPreset = rawPreset.Replace("ROTATION_TO_USE", iRotation);

            return(rawPreset);
        }
Exemple #3
0
        public static string GenerateScenario(List <FFXIVItem> iItemToGenerate, MiqobotScenarioOption iOptions, System.Windows.Forms.TextBox iLogBox, out string fullScenario)
        {
            fullScenario = "";
            if (null == iOptions)
            {
                Service_Misc.LogText(iLogBox, "Whoooops wrong options selected...");
                return(null);
            }
            Service_Misc.LogText(iLogBox, "Let's whisper to miqobot ears...");

            MiqoCraftOptions options = new MiqoCraftOptions();

            options.Load(OptionLocation.UserOption);

            //Login to miqobot forums
            CookieCollection logMiqobotCookies = Miqobot.LogInForum();

            if (null != logMiqobotCookies)
            {
                Service_Misc.LogText(iLogBox, "I'm logged into miqobot forum !");
            }
            else
            {
                Service_Misc.LogText(iLogBox, "Failed to log into miqobot forum... well you'll have to manually gather stuff, sorry !");
            }

            //Listing items
            List <FFXIVItem> allItems         = new List <FFXIVItem>();
            List <int>       allItemsQuantity = new List <int>();
            string           scenarioName     = "";

            foreach (FFXIVItem iItem in iItemToGenerate)
            {
                if (null == iItem)
                {
                    continue;
                }
                if (scenarioName != "")
                {
                    scenarioName += ",";
                }
                scenarioName += iItem.Name;
                RecFindItems(iItem, iOptions.Quantity, ref allItems, ref allItemsQuantity, iOptions.CustomQuantities);
            }
            if (iItemToGenerate.Count > 5)
            {
                scenarioName = iItemToGenerate.Count + " Items";
            }

            fullScenario = "";
            string allGrids     = "";
            string allRotations = "";
            string allPreset    = "";

            List <string> catalysts = GetCatalysts();

            if (!iOptions.IgnoreCatalysts)
            {
                catalysts.Clear();
            }

            //Creating rotations
            allRotations += "gatherrotation.Collect Gathering +15%" + Environment.NewLine;
            allRotations += "[31,9,22,26,25,[34,[35,29,36,26]],25,[34,[35,29,36,26]],23,1,32]" + Environment.NewLine;
            allRotations += "gatherrotation.Collect Gathering +5%" + Environment.NewLine;
            allRotations += "[31,9,22,26,25,[34,[35,29,36,26]],25,[34,[35,29,36,26]],23,0]" + Environment.NewLine;
            allRotations += "gatherrotation.Gathering +15%/HQ +10%" + Environment.NewLine;
            allRotations += "[31,1,3]" + Environment.NewLine;
            allRotations += "gatherrotation.HQ +10%" + Environment.NewLine;
            allRotations += "[31,3]" + Environment.NewLine;
            allRotations += "gatherrotation.Gathering +5%/HQ +10%" + Environment.NewLine;
            allRotations += "[31,0,3]" + Environment.NewLine;
            allRotations += MiqoCraftCore.GetCacheRotations() + Environment.NewLine;;

            //Creating default preset
            allPreset += "solverpreset.recommended" + Environment.NewLine;
            allPreset += "{\"cpchunk\":4,\"skillinnovation\":true,\"skillmanipulation\":false,\"skillwastenot1\":false,\"skillwastenot2\":false,\"skillwhistle\":false,\"progresssolver\":true,\"enforcebb100\":true,\"enforcepbp100\":true,\"ignorequality\":false,\"reclaimhqon\":false,\"reclaimhqvalue\":85,\"reclaimqualityon\":false,\"reclaimqualityvalue\":4000}" + Environment.NewLine;
            allPreset += MiqoCraftCore.GetCacheSolverPresets() + Environment.NewLine;;

            //Header
            Service_Misc.LogText(iLogBox, "Creating scenario header...");
            fullScenario += "\"";
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "// " + scenarioName + Environment.NewLine;
            fullScenario += "// Script Generated by MiqoCrafter" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "// Copyright 2019 - Shishio Valentine" + Environment.NewLine;
            fullScenario += "// [email protected]" + Environment.NewLine;
            fullScenario += "// http://patreon.com/miqocrafter" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;

            //Prerequisite
            fullScenario += Environment.NewLine;
            fullScenario += Environment.NewLine;
            fullScenario += "// Prerequisite" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "//" + Environment.NewLine;
            if (iOptions.IgnoreCatalysts)
            {
                fullScenario += "// You will need to buy or obtain those items using external means, cause Miqocrafter can't automate it [Yet], or they are ignored catalysts" + Environment.NewLine;
            }
            else
            {
                fullScenario += "// You will need to buy or obtain those items using external means, cause Miqocrafter can't automate it [Yet]" + Environment.NewLine;
            }
            for (int i = 0; i < allItems.Count && i < allItemsQuantity.Count; i++)
            {
                FFXIVItem iItem = allItems[i];
                if (null == iItem)
                {
                    continue;
                }
                int quantity = allItemsQuantity[i];

                FFXIVCraftingOptions itemOptions = options.GetOption(iItem);

                if (iItem.Type == FFXIVItem.TypeItem.NPC || iItem.Type == FFXIVItem.TypeItem.Unkwown || null != catalysts.Find(x => x != null && x.ToLower() == iItem.Name.ToLower()) || (null != itemOptions && itemOptions.IgnoreItem))
                {
                    fullScenario += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                }
            }

            //Reduced
            fullScenario += Environment.NewLine;
            fullScenario += Environment.NewLine;
            fullScenario += "// Reduced Items" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "//" + Environment.NewLine;
            fullScenario += "// You will need to manually reduce those items, cause Miqocrafter can't automate it [Yet]" + Environment.NewLine;
            fullScenario += "// However Miqocrafter will try to gather/craft/retrieve the items that need to be reduced." + Environment.NewLine;
            for (int i = 0; i < allItems.Count && i < allItemsQuantity.Count; i++)
            {
                FFXIVItem iItem = allItems[i];
                if (null == iItem)
                {
                    continue;
                }
                int quantity = allItemsQuantity[i];
                FFXIVReducedItem reducedItem = null;
                if (iItem is FFXIVReducedItem)
                {
                    reducedItem = iItem as FFXIVReducedItem;
                }
                if (null != reducedItem)
                {
                    if (null != reducedItem.ReducedFrom)
                    {
                        fullScenario += "//    - " + iItem.Name + " (Reduced from " + reducedItem.ReducedFrom + " - " + iItem.UrlGarland + ")" + Environment.NewLine;
                    }
                    else
                    {
                        fullScenario += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                    }
                }
            }

            //Errors
            fullScenario += "ERRORS_ITEMS_DUMMY";

            fullScenario += "\",";

            //Getting miqo preset content
            string miqoPresetContent = "";

            if (null != iOptions.MiqoPresetPath && "" != iOptions.MiqoPresetPath)
            {
                FileInfo presetFile = new FileInfo(Path.Combine(iOptions.MiqoPresetPath, "presets.miqo"));
                if (presetFile.Exists)
                {
                    miqoPresetContent = File.ReadAllText(presetFile.FullName);
                }
            }
            if (miqoPresetContent == "" && null != options.MiqoPresetPath && "" != options.MiqoPresetPath)
            {
                FileInfo presetFile = new FileInfo(Path.Combine(options.MiqoPresetPath, "presets.miqo"));
                if (presetFile.Exists)
                {
                    miqoPresetContent = File.ReadAllText(presetFile.FullName);
                }
            }

            //Gathering stuff
            string lastTeleport = "";
            string errorContent = "";

            Service_Misc.LogText(iLogBox, "Creating gathering grids...");
            fullScenario += "\"";
            fullScenario += Environment.NewLine;
            fullScenario += Environment.NewLine;
            fullScenario += "// Gathered Items" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "//" + Environment.NewLine;
            fullScenario += "// Miqocrafter will use the gathering scenario from https://miqobot.com/forum/forums/topic/index-gathering-grids/ to retrieve those." + Environment.NewLine;
            for (int i = 0; i < allItems.Count && i < allItemsQuantity.Count; i++)
            {
                FFXIVItem iItem = allItems[i];
                if (null == iItem)
                {
                    continue;
                }
                int quantity = allItemsQuantity[i] / iOptions.NbPerNode + 1;

                if (!(iItem is FFXIVGatheredItem))
                {
                    continue;
                }
                FFXIVGatheredItem gatheredItem = iItem as FFXIVGatheredItem;

                if (null != catalysts.Find(x => x != null && x.ToLower() == iItem.Name.ToLower()))
                {
                    continue;
                }
                FFXIVCraftingOptions itemOptions = options.GetOption(iItem);
                if (null != itemOptions && itemOptions.IgnoreItem)
                {
                    continue;
                }

                if (null != gatheredItem)
                {
                    Service_Misc.LogText(iLogBox, "Searching for item grid : " + iItem + "");
                    if (gatheredItem.Slot.Count <= 0)
                    {
                        errorContent += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                        fullScenario += "// Failed to retrieve item gathering slot from FGarlandTool, can't gather this item " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                        continue;
                    }
                    if (null != logMiqobotCookies)
                    {
                        List <MiqoItemPage> listItemPage = Miqobot.GetURLItem(iItem.Name, logMiqobotCookies, null);
                        if (listItemPage.Count <= 0)
                        {
                            errorContent += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                            fullScenario += "// Failed to retrieve item gathering scenario from miqobot forums, can't gather this item " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                        }
                        else
                        {
                            string initName = "";
                            string grid     = null;
                            for (int j = 0; j < listItemPage.Count && null == grid; j++)
                            {
                                grid = Miqobot.GetLastGrid(iItem.Name, logMiqobotCookies, listItemPage[j], out initName);
                            }
                            if (null != grid)
                            {
                                //Finding right zone
                                string zone          = "";
                                string type          = "";
                                string slot          = "";
                                string time          = "";
                                string gatheringType = "";

                                if (gatheredItem.Slot.Count == 1)
                                {
                                    //No ambiguity
                                    zone          = gatheredItem.Zones[0];
                                    type          = gatheredItem.Types[0];
                                    slot          = gatheredItem.Slot[0];
                                    time          = gatheredItem.Times[0];
                                    gatheringType = gatheredItem.GatheringTypes[0];
                                }
                                else
                                {
                                    if (zone == "")
                                    {
                                        foreach (string zoneName in gatheredItem.Zones)
                                        {
                                            string initNameCorrected = initName.Replace(" ", "").ToLower();
                                            string gridDataCorrected = grid.Replace(" ", "").ToLower();
                                            string zoneNameCorrected = zoneName.ToLower().Replace("the ", "").Replace(" ", "").Trim();
                                            if (initNameCorrected.Contains(zoneNameCorrected))
                                            {
                                                int index = gatheredItem.Zones.IndexOf(zoneName);

                                                zone          = gatheredItem.Zones[index];
                                                type          = gatheredItem.Types[index];
                                                slot          = gatheredItem.Slot[index];
                                                time          = gatheredItem.Times[index];
                                                gatheringType = gatheredItem.GatheringTypes[index];
                                                break;
                                            }
                                            if (gridDataCorrected.Contains(zoneNameCorrected))
                                            {
                                                int index = gatheredItem.Zones.IndexOf(zoneName);

                                                zone          = gatheredItem.Zones[index];
                                                type          = gatheredItem.Types[index];
                                                slot          = gatheredItem.Slot[index];
                                                time          = gatheredItem.Times[index];
                                                gatheringType = gatheredItem.GatheringTypes[index];
                                                break;
                                            }
                                        }
                                    }
                                }
                                if (zone == "")
                                {
                                    errorContent += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                                    fullScenario += "// Failed to retrieve item gathering zone from miqobot grid, can't gather this item " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                                    continue;
                                }

                                //Find teleport item
                                string teleportTo = GarlandTool.GetTeleportName(zone, grid, gatheredItem);

                                //Compute grid name from miqo presets, to avoid duplicates
                                string gridName  = iItem.Name + " Grid";
                                int    indexGrid = 1;
                                while (miqoPresetContent.Contains("grid." + gridName + Environment.NewLine))
                                {
                                    string oldGridName = gridName;
                                    gridName = iItem.Name + " Grid" + indexGrid;
                                    grid     = grid.Replace("grid." + oldGridName + Environment.NewLine, "grid." + gridName + Environment.NewLine);
                                    indexGrid++;
                                }

                                //Embed grid
                                allGrids += grid + Environment.NewLine;

                                //Get preset
                                string preset = MiqoCraftCore.GetCraftingPreset(gatheringType, slot, gatheredItem, iOptions.GatheringRotation, gridName, time);

                                //Compute preset name from miqo presets, to avoid duplicates
                                string presetName  = iItem.Name + " preset";
                                int    indexpreset = 1;
                                while (miqoPresetContent.Contains("gatherpreset." + presetName + Environment.NewLine))
                                {
                                    string oldpresetName = presetName;
                                    presetName = iItem.Name + " preset" + indexpreset;
                                    preset     = preset.Replace("gatherpreset." + oldpresetName + Environment.NewLine, "gatherpreset." + presetName + Environment.NewLine);
                                    indexpreset++;
                                }

                                //Embed a new preset
                                allPreset += preset;

                                //Add gathering rotation to scenario
                                //Add gathering rotation to scenario
                                //teleportIf(Black Brush Station)\r\nunstealth()\r\nchangeJob(Miner)\r\nselectGrid(Min5-Copper Ore)\r\nselectGatherPreset(Metal Worm Jar- Copper Ore)\r\nstartGathering(4)
                                //teleportIfNotThere
                                fullScenario += "// Gathering " + iItem.Name + Environment.NewLine;
                                if (lastTeleport == "" || lastTeleport == teleportTo)
                                {
                                    fullScenario += "teleport(" + teleportTo + ")" + Environment.NewLine;
                                }
                                else
                                {
                                    fullScenario += "teleportIfNotThere(" + teleportTo + ")" + Environment.NewLine;
                                }
                                lastTeleport = teleportTo;

                                //Adding custom scenario after teleport
                                DirectoryInfo customDirectory = new DirectoryInfo(Path.Combine(Service_Misc.GetExecutionPath(), "CustomTeleport"));
                                if (!customDirectory.Exists)
                                {
                                    customDirectory.Create();
                                }
                                FileInfo customTeleportScenarioFile = new FileInfo(Path.Combine(customDirectory.FullName, teleportTo + " Scenario.txt"));
                                if (customTeleportScenarioFile.Exists)
                                {
                                    fullScenario += File.ReadAllText(customTeleportScenarioFile.FullName) + Environment.NewLine;
                                }

                                FileInfo customTeleportGridFile = new FileInfo(Path.Combine(customDirectory.FullName, teleportTo + " Grid.txt"));
                                if (customTeleportGridFile.Exists)
                                {
                                    allGrids += File.ReadAllText(customTeleportGridFile.FullName) + Environment.NewLine;
                                }


                                //fullScenario += "unstealth()" + Environment.NewLine;
                                fullScenario += "changeJob(" + GarlandTool.GetGatheringJobName(gatheringType, iItem) + ")" + Environment.NewLine;
                                fullScenario += "selectGrid(" + gridName + ")" + Environment.NewLine;
                                fullScenario += "selectGatherPreset(" + presetName + ")" + Environment.NewLine;
                                if (null != gatheredItem && gatheredItem.AsCollectable)
                                {
                                    fullScenario += "rotationIfGP(470 Collect 5% Gathering)" + Environment.NewLine;
                                    fullScenario += "rotationIfGP(470 Collect 15% Gathering)" + Environment.NewLine;
                                }
                                else
                                {
                                    fullScenario += "rotationIfGP(" + iOptions.GatheringRotation + ")" + Environment.NewLine;
                                }
                                fullScenario += "startGathering(" + quantity + ")" + Environment.NewLine;
                                fullScenario += Environment.NewLine;
                            }
                            else
                            {
                                errorContent += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                                fullScenario += "// Failed to retrieve the grid from miqobot forums, can't gather this item " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                            }
                        }
                    }
                    else
                    {
                        errorContent += "//    - " + quantity + "x " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                        fullScenario += "// Failed to log into miqobot forums, can't gather this item " + iItem.Name + " (see " + iItem.UrlGarland + ")" + Environment.NewLine;
                    }
                }
            }
            fullScenario += "\",";

            //Crafting stuff
            Service_Misc.LogText(iLogBox, "Generating craft scenario...");
            fullScenario += "\"";
            fullScenario += Environment.NewLine;
            fullScenario += Environment.NewLine;
            fullScenario += "// Crafted Items" + Environment.NewLine;
            fullScenario += "//--------------------------------------------------------------" + Environment.NewLine;
            fullScenario += "//" + Environment.NewLine;
            fullScenario += "solverPreset(" + iOptions.CraftPreset + ")" + Environment.NewLine;
            fullScenario += "nqhq(" + iOptions.NQHQPreset + ")" + Environment.NewLine;
            fullScenario += "reclaimOff()" + Environment.NewLine;

            string teleportCraft = iOptions.CustomTeleport;

            if (teleportCraft != "")
            {
                fullScenario += "teleport(" + teleportCraft + ")" + Environment.NewLine;
            }

            List <FFXIVCraftedItem> listAllCraftedItems = new List <FFXIVCraftedItem>();

            for (int i = 0; i < allItems.Count && i < allItemsQuantity.Count; i++)
            {
                FFXIVItem iItem = allItems[i];
                if (null == iItem)
                {
                    continue;
                }
                int quantity = allItemsQuantity[i];
                FFXIVCraftedItem craftedItem = null;
                if (iItem is FFXIVCraftedItem)
                {
                    craftedItem = iItem as FFXIVCraftedItem;
                }
                if (null != craftedItem)
                {
                    listAllCraftedItems.Add(craftedItem);
                }
            }
            for (int i = 0; i < allItems.Count && i < allItemsQuantity.Count; i++)
            {
                FFXIVItem iItem = allItems[i];
                if (null == iItem)
                {
                    continue;
                }
                int quantity = allItemsQuantity[i];
                FFXIVCraftedItem craftedItem = null;
                if (iItem is FFXIVCraftedItem)
                {
                    craftedItem = iItem as FFXIVCraftedItem;
                }
                FFXIVCraftingOptions itemOptions = options.GetOption(iItem);
                if (null != itemOptions && itemOptions.IgnoreItem)
                {
                    continue;
                }

                if (null != craftedItem)
                {
                    fullScenario += "// " + craftedItem + Environment.NewLine;

                    int indexCraftedItem = listAllCraftedItems.IndexOf(craftedItem);
                    if (listAllCraftedItems.IndexOf(craftedItem) >= listAllCraftedItems.Count - 1 && iOptions.Collectable)
                    {
                        fullScenario += "setCraftCollect(on)" + Environment.NewLine;
                    }
                    else
                    {
                        fullScenario += "setCraftCollect(off)" + Environment.NewLine;
                    }

                    fullScenario += "job(" + craftedItem.Class + ")" + Environment.NewLine;
                    fullScenario += "recipe(" + craftedItem.Name + ")" + Environment.NewLine;

                    if (null != itemOptions && itemOptions.CustomCraftingMacro != "")
                    {
                        fullScenario += "selectCraftMacro(" + itemOptions.CustomCraftingMacro + ")" + Environment.NewLine;
                    }

                    fullScenario += "craft(" + quantity + ")" + Environment.NewLine;

                    if (listAllCraftedItems.IndexOf(craftedItem) >= listAllCraftedItems.Count - 1 && iOptions.Collectable)
                    {
                        fullScenario += "setCraftCollect(off)" + Environment.NewLine;
                    }

                    if (null != itemOptions && itemOptions.CustomCraftingMacro != "")
                    {
                        fullScenario += "solverPreset(" + iOptions.CraftPreset + ")" + Environment.NewLine;
                    }
                    fullScenario += Environment.NewLine;
                }
            }
            fullScenario += "\"";

            if (errorContent == "")
            {
                fullScenario = fullScenario.Replace("ERRORS_ITEMS_DUMMY", "");
            }
            else
            {
                string scenarioError = "";
                scenarioError += Environment.NewLine;
                scenarioError += Environment.NewLine;
                scenarioError += "// Items without grid / Miqocrafter couldn't automate" + Environment.NewLine;
                scenarioError += "//--------------------------------------------------------------" + Environment.NewLine;
                scenarioError += "//" + Environment.NewLine;
                scenarioError += "// You will need to buy or obtain those items using external means, cause Miqocrafter can't automate it [Yet]" + Environment.NewLine;
                scenarioError += errorContent;
                scenarioError += Environment.NewLine;
                fullScenario   = fullScenario.Replace("ERRORS_ITEMS_DUMMY", scenarioError);
            }

            string textFileContent = "scenario.Craft " + scenarioName + Environment.NewLine;

            textFileContent += "{ \"chapters\":[";
            textFileContent += fullScenario.Replace(Environment.NewLine, "\\r\\n").Replace("/", "\\/");
            textFileContent += "]}" + Environment.NewLine;

            textFileContent += allRotations + Environment.NewLine;
            textFileContent += allGrids + Environment.NewLine;
            textFileContent += allPreset + Environment.NewLine;

            while (textFileContent.Contains(Environment.NewLine + Environment.NewLine))
            {
                textFileContent = textFileContent.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
            }

            return(textFileContent);
        }
Exemple #4
0
        public static string GetTeleportName(string iZone, string iGrid, FFXIVGatheredItem iItem)
        {
            string toSearchInGrid = iZone + " @";

            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            toSearchInGrid = iZone + "@";
            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            toSearchInGrid = iZone + Environment.NewLine + " @";
            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            toSearchInGrid = iZone + Environment.NewLine + "@";
            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            toSearchInGrid = iZone + @"\r\n" + "@";
            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            toSearchInGrid = iZone + @"\r\n" + " @";
            if (iGrid.Contains(toSearchInGrid))
            {
                return(iGrid.Split(new string[] { toSearchInGrid }, StringSplitOptions.None)[1].Split(']')[0]);
            }
            if (iZone == "Kholusia")
            {
                return("Stilltide");
            }
            if (iZone == "Central Thanalan")
            {
                return("Black Brush Station");
            }
            if (iZone == "Southern Thanalan")
            {
                return("Forgotten Springs");
            }
            if (iZone == "The Sea of Clouds")
            {
                return("Camp Cloudtop");
            }
            if (iZone == "The Azim Steppe")
            {
                return("Reunion");
            }
            if (iZone == "The Peaks")
            {
                return("Ala Ghiri");
            }
            if (iZone == "Lakeland")
            {
                return("Fort Jobb");
            }
            if (iZone == "Amh Araeng")
            {
                return("Twine");
            }
            if (iZone == "North Shroud")
            {
                return("Fallgourd Float");
            }
            if (iZone == "Lower La Noscea")
            {
                return("Moraby Drydocks");
            }
            if (iZone == "The Churning Mists")
            {
                return("Zenith");
            }
            if (iZone == "Eastern Thanalan")
            {
                return("Camp Drybone");
            }
            if (iZone == "Central Shroud")
            {
                return("Bentbranch Meadows");
            }
            if (iZone == "East Shroud")
            {
                return("The Hawthorne Hut");
            }
            if (iZone == "The Dravanian Hinterlands")
            {
                return("Idyllshire");
            }
            if (iZone == "The Fringes")
            {
                return("The Peering Stones");
            }
            if (iZone == "Yanxia")
            {
                return("Namai");
            }
            if (iZone == "The Rak'tika Greatwood")
            {
                return("Fanow");
            }

            if (iZone == "New Gridania")
            {
                return("New Gridania");
            }
            if (iZone == "Central Shroud")
            {
                return("Bentbranch Meadows");
            }
            if (iZone == "East Shroud")
            {
                return("The Hawthorne Hut");
            }
            if (iZone == "South Shroud")
            {
                return("Quarrymill");
            }
            if (iZone == "South Shroud")
            {
                return("Camp Tranquil");
            }
            if (iZone == "North Shroud")
            {
                return("Fallgourd Float");
            }
            if (iZone == "Ul'dah - Steps of Nald")
            {
                return("Ul'dah - Steps of Nald");
            }
            if (iZone == "Western Thanalan")
            {
                return("Horizon");
            }
            if (iZone == "Central Thanalan")
            {
                return("Black Brush Station");
            }
            if (iZone == "Eastern Thanalan")
            {
                return("Camp Drybone");
            }
            if (iZone == "Southern Thanalan")
            {
                return("Little Ala Mhigo");
            }
            if (iZone == "Southern Thanalan")
            {
                return("Forgotten Springs");
            }
            if (iZone == "Northern Thanalan")
            {
                return("Camp Bluefog");
            }
            if (iZone == "Northern Thanalan")
            {
                return("Ceruleum Processing Plant");
            }
            if (iZone == "The Gold Saucer")
            {
                return("The Gold Saucer");
            }
            if (iZone == "Foundation")
            {
                return("Foundation");
            }
            if (iZone == "Coerthas Central Highlands")
            {
                return("Camp Dragonhead");
            }
            if (iZone == "Coerthas Western")
            {
                return("Highlands  Falcon's Nest");
            }
            if (iZone == "The Sea of Clouds")
            {
                return("Camp Cloudtop");
            }
            if (iZone == "The Sea of Clouds")
            {
                return("Ok' Zundu");
            }
            if (iZone == "Azys Lla")
            {
                return("Helix");
            }
            if (iZone == "Idyllshire")
            {
                return("Idyllshire");
            }
            if (iZone == "The Dravanian Forelands")
            {
                return("Tailfeather");
            }
            if (iZone == "The Dravanian Forelands")
            {
                return("Anyx Trine");
            }
            if (iZone == "The Churning Mists")
            {
                return("Moghome");
            }
            if (iZone == "The Churning Mists")
            {
                return("Zenith");
            }
            if (iZone == "Rhalgr's Reach")
            {
                return("Rhalgr's Reach");
            }
            if (iZone == "The Fringes")
            {
                return("Castrum Oriens");
            }
            if (iZone == "The Fringes")
            {
                return("The Peering Stones");
            }
            if (iZone == "The Peaks")
            {
                return("Ala Gannha");
            }
            if (iZone == "The Peaks")
            {
                return("Ala Ghiri");
            }
            if (iZone == "The Lochs")
            {
                return("Porta Praetoria");
            }
            if (iZone == "The Lochs")
            {
                return("The Ala Mhigan Quarter");
            }
            if (iZone == "The Ruby Sea")
            {
                return("Tamamizu");
            }
            if (iZone == "The Ruby Sea")
            {
                return("Onokoro");
            }
            if (iZone == "Yanxia")
            {
                return("Namai");
            }
            if (iZone == "Yanxia")
            {
                return("The House of the Fierce");
            }
            if (iZone == "The Azim Steppe")
            {
                return("Reunion");
            }
            if (iZone == "The Azim Steppe")
            {
                return("The Dawn Throne");
            }
            if (iZone == "The Doman Enclave")
            {
                return("The Doman Enclave");
            }
            if (iZone == "The Crystarium")
            {
                return("The Crystarium");
            }
            if (iZone == "Lakeland")
            {
                return("Fort Jobb");
            }
            if (iZone == "Lakeland")
            {
                return("The Ostall Imperative");
            }
            if (iZone == "Kholusia")
            {
                return("Stilltide");
            }
            if (iZone == "Kholusia")
            {
                return("Wright");
            }
            if (iZone == "Amh Araeng")
            {
                return("Mord Souq");
            }
            if (iZone == "Amh Araeng")
            {
                return("The Inn at Journey's Head");
            }
            if (iZone == "Amh Araeng")
            {
                return("Twine");
            }
            if (iZone == "Il Mheg")
            {
                return("Lydha Lran");
            }
            if (iZone == "Il Mheg")
            {
                return("Pla Enni");
            }
            if (iZone == "Il Mheg")
            {
                return("Wolekdorf");
            }
            if (iZone == "The Rak'tika Greatwood")
            {
                return("Slitherbough");
            }
            if (iZone == "The Rak'tika Greatwood")
            {
                return("Fanow");
            }
            if (iZone == "Mor Dhona")
            {
                return("Revenant's Toll");
            }
            if (iZone == "Upper La Noscea")
            {
                return("Camp Bronze Lake");
            }
            if (iZone == "Middle La Noscea")
            {
                return("Summerford Farms");
            }
            if (iZone == "Coerthas Western Highlands")
            {
                return("Falcon's Nest");
            }


            return(iZone);
        }
Exemple #5
0
        private static FFXIVItem CreateItemFromNode(System.Windows.Forms.TextBox iLogBox, CookieCollection iCookies, ref CookieCollection oCookies, ref HttpStatusCode oCode, JToken iItemNode, JToken iDataNode, List <JToken> iIngredientsToken, List <string> iIngredienstIDs)
        {
            FFXIVItem item = null;

            if (null == iItemNode)
            {
                return(null);
            }

            JToken itemToken = iItemNode;

            if (null == itemToken)
            {
                return(item);
            }

            JToken craftToken   = itemToken["craft"];
            JToken nodeToken    = itemToken["nodes"];
            JToken reducedToken = itemToken["reducedFrom"];
            JToken tradeShop    = itemToken["tradeShops"];
            JToken vendor       = itemToken["vendors"];

            if (null != craftToken)
            {
                FFXIVCraftedItem craftedItem = new FFXIVCraftedItem();
                craftedItem.Type = FFXIVItem.TypeItem.Crafted;

                string jobID = craftToken[0]["job"].Value <string>();
                craftedItem.Class    = GetJobName(jobID);
                craftedItem.UrlClass = "http://garlandtools.org/files/icons/job/" + craftedItem.Class + ".png";
                craftedItem.Level    = craftToken[0]["lvl"].Value <string>();

                int    yieldQuantity = 1;
                JToken yieldToken    = craftToken[0]["yield"];
                if (null != yieldToken)
                {
                    yieldQuantity = yieldToken.Value <int>();
                }
                craftedItem.RecipeQuantity = yieldQuantity;

                //Building craft requirement list
                foreach (JToken ingredientToken in craftToken[0]["ingredients"].Children())
                {
                    if (null == ingredientToken)
                    {
                        continue;
                    }

                    string ingredientID = ingredientToken["id"].Value <string>();

                    //Finding right ingredient token from input list, with all informations
                    JToken    fullIngredientNode = ingredientToken;
                    int       indexInList        = iIngredienstIDs.IndexOf(ingredientID);
                    FFXIVItem ingredient         = null;
                    if (indexInList >= 0 && indexInList < iIngredientsToken.Count)
                    {
                        fullIngredientNode = iIngredientsToken[indexInList];
                        ingredient         = CreateItemFromNode(iLogBox, iCookies, ref oCookies, ref oCode, fullIngredientNode, iDataNode, iIngredientsToken, iIngredienstIDs);
                    }
                    else
                    {
                        ingredient = RecBuildCraftingTree(iLogBox, ingredientID, 1);
                    }

                    //Adding Item
                    if (null != ingredient)
                    {
                        ingredient.Quantity = ingredientToken["amount"].Value <int>();
                        craftedItem.ListNeededItems.Add(ingredient);
                    }
                    else
                    {
                        Service_Misc.LogText(iLogBox, "Oups... failed to retrieve one ingredient : ID=" + ingredientToken["id"].Value <string>());
                    }
                }

                item = craftedItem;
            }
            else if (null != nodeToken)
            {
                FFXIVGatheredItem gatheredItem = ReadGatheredItem(iCookies, ref oCookies, ref oCode, iDataNode, itemToken, nodeToken);
                item      = gatheredItem;
                item.Type = FFXIVItem.TypeItem.Gathered;
            }
            else if (null != reducedToken)
            {
                item = ReadReducedItem(iLogBox, reducedToken);
            }
            else if (null != tradeShop || null != vendor)
            {
                item      = new FFXIVItem();
                item.Type = FFXIVItem.TypeItem.NPC;
            }
            else
            {
                item      = new FFXIVItem();
                item.Type = FFXIVItem.TypeItem.Unkwown;
                Service_Misc.LogText(iLogBox, "Oups... one ingredient is unknown, don't know how to get this one.");
            }

            if (null != item)
            {
                try
                {
                    item.Name       = itemToken["name"].Value <string>();
                    item.UrlImage   = "http://garlandtools.org/files/icons/item/" + itemToken["icon"].Value <string>() + ".png";
                    item.UrlGarland = "http://garlandtools.org/db/#item/" + itemToken["id"].Value <string>();
                    item.ID         = itemToken["id"].Value <string>();
                }
                catch (Exception)
                {
                    Service_Misc.LogText(iLogBox, "Oups... failed to retrieve one item : Token=" + Environment.NewLine + iItemNode.ToString());
                }
            }

            return(item);
        }
Exemple #6
0
        private static FFXIVGatheredItem ReadGatheredItem(CookieCollection iCookies, ref CookieCollection oCookies, ref HttpStatusCode oCode, JToken dataToken, JToken itemToken, JToken nodeToken)
        {
            FFXIVGatheredItem gatheredItem = new FFXIVGatheredItem();

            //Adding nodes info
            foreach (JToken gatherNodeToken in nodeToken.Children())
            {
                try
                {
                    string nodeSearchContent = Service_Misc.GetContentFromRequest("GET http://garlandtools.org/db/doc/node/en/2/" + gatherNodeToken.Value <string>() + ".json HTTP/1.1|Host: garlandtools.org|Connection: keep-alive|Accept: application/json, text/javascript, */*; q=0.01|X-Requested-With: XMLHttpRequest|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Referer: http://garlandtools.org/db/|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|",
                                                                                  iCookies, ref oCookies, ref oCode);

                    try
                    {
                        string logName2 = Path.Combine(Service_Misc.GetExecutionPath(), "Node.log");
                        File.WriteAllText(logName2, nodeSearchContent);
                    }
                    catch
                    {
                    }

                    JToken gatherResultToken = JObject.Parse(nodeSearchContent);
                    if (null == gatherResultToken)
                    {
                        continue;
                    }

                    JToken gatherResultNodeToken = gatherResultToken.Children().ToList()[0].Children().ToList()[0];
                    if (null == gatherResultNodeToken)
                    {
                        continue;
                    }

                    string zoneID = gatherResultNodeToken["zoneid"].Value <string>();

                    JToken locationToken = dataToken["locationIndex"];
                    if (null == locationToken)
                    {
                        continue;
                    }

                    JToken zoneIDToken = locationToken[zoneID];
                    if (null == zoneIDToken)
                    {
                        continue;
                    }

                    JToken zoneNameToken = zoneIDToken["name"];
                    if (null == zoneNameToken)
                    {
                        continue;
                    }

                    string zone          = zoneNameToken.Value <string>();
                    string gatheringType = gatherResultNodeToken["type"].Value <string>();
                    string type          = "";
                    if (null != gatherResultNodeToken["limitType"])
                    {
                        type = gatherResultNodeToken["limitType"].Value <string>();
                    }
                    string slot = "";
                    foreach (JToken slotToken in gatherResultNodeToken["items"])
                    {
                        if (null == slotToken)
                        {
                            continue;
                        }
                        if (null == slotToken["slot"])
                        {
                            continue;
                        }
                        if (null == slotToken["id"])
                        {
                            continue;
                        }
                        string id            = slotToken["id"].Value <string>();
                        string slotCandidate = slotToken["slot"].Value <string>();
                        if (id == itemToken["id"].Value <string>())
                        {
                            slot = slotCandidate;
                            break;
                        }
                    }
                    string time = "";
                    if (null != gatherResultNodeToken["time"])
                    {
                        foreach (JToken timeToken in gatherResultNodeToken["time"])
                        {
                            if (null == timeToken)
                            {
                                continue;
                            }
                            if (time != "")
                            {
                                time += ",";
                            }
                            time += timeToken.Value <string>();
                        }
                    }

                    gatheredItem.Zones.Add(zone);
                    gatheredItem.NodeType.Add("");
                    gatheredItem.Slot.Add(slot);
                    gatheredItem.Times.Add(time);
                    gatheredItem.Types.Add(type);
                    gatheredItem.GatheringTypes.Add(gatheringType);
                }
                catch (Exception exc)
                {
                    string msg = exc.Message;
                }
            }

            return(gatheredItem);
        }