Example #1
0
        public static void CreateSpoilerLog(RandomizedResult randomized, GameplaySettings settings, OutputSettings outputSettings)
        {
            var itemList = randomized.ItemList
                           .Where(io => !io.Item.IsFake())
                           .Select(u => new SpoilerItem(u, ItemUtils.IsRequired(u.Item, randomized), ItemUtils.IsImportant(u.Item, randomized)));
            var settingsString = settings.ToString();

            var directory = Path.GetDirectoryName(outputSettings.OutputROMFilename);
            var filename  = $"{Path.GetFileNameWithoutExtension(outputSettings.OutputROMFilename)}";

            var     plainTextRegex = new Regex("[^a-zA-Z0-9' .\\-]+");
            Spoiler spoiler        = new Spoiler()
            {
                Version                      = Randomizer.AssemblyVersion,
                SettingsString               = settingsString,
                Seed                         = randomized.Seed,
                RandomizeDungeonEntrances    = settings.RandomizeDungeonEntrances,
                ItemList                     = itemList.Where(u => !u.Item.IsFake()).ToList(),
                NewDestinationIndices        = randomized.NewDestinationIndices,
                Logic                        = randomized.Logic,
                CustomItemListString         = settings.UseCustomItemList ? settings.CustomItemListString : null,
                CustomStartingItemListString = settings.CustomStartingItemList.Any() ? settings.CustomStartingItemListString : null,
                CustomJunkLocationsString    = settings.CustomJunkLocationsString,
                GossipHints                  = randomized.GossipQuotes?.ToDictionary(me => (GossipQuote)me.Id, (me) =>
                {
                    var message     = me.Message.Substring(1);
                    var soundEffect = message.Substring(0, 2);
                    message         = message.Substring(2);
                    if (soundEffect == "\x69\x0C")
                    {
                        // real
                    }
                    else if (soundEffect == "\x69\x0A")
                    {
                        // fake
                        message = "FAKE - " + message;
                    }
                    else
                    {
                        // junk
                        message = "JUNK - " + message;
                    }
                    return(plainTextRegex.Replace(message.Replace("\x11", " "), ""));
                }),
            };

            if (outputSettings.GenerateHTMLLog)
            {
                using (StreamWriter newlog = new StreamWriter(Path.Combine(directory, filename + "_Tracker.html")))
                {
                    Templates.HtmlSpoiler htmlspoiler = new Templates.HtmlSpoiler(spoiler);
                    newlog.Write(htmlspoiler.TransformText());
                }
            }

            if (outputSettings.GenerateSpoilerLog)
            {
                CreateTextSpoilerLog(spoiler, Path.Combine(directory, filename + "_SpoilerLog.txt"));
            }
        }
Example #2
0
        public static void CreateSpoilerLog(RandomizedResult randomized, Settings settings)
        {
            var itemList = randomized.ItemList
                           .Where(u => u.ReplacesAnotherItem)
                           .Select(u => new SpoilerItem(u)
            {
                ReplacedById = randomized.ItemList.Single(i => i.ReplacesItemId == u.ID).ID
            })
                           .ToList();
            var settingsString = settings.ToString();

            var directory = Path.GetDirectoryName(settings.OutputROMFilename);
            var filename  = $"{Path.GetFileNameWithoutExtension(settings.OutputROMFilename)}";

            Spoiler spoiler = new Spoiler()
            {
                Version                   = MainForm.AssemblyVersion.Substring(26),
                SettingsString            = settingsString,
                Seed                      = settings.Seed,
                RandomizeDungeonEntrances = settings.RandomizeDungeonEntrances,
                ItemList                  = itemList,
                NewDestinationIndices     = randomized.NewDestinationIndices,
                Logic                     = randomized.Logic
            };

            if (settings.GenerateHTMLLog)
            {
                filename += "_SpoilerLog.html";
                using (StreamWriter newlog = new StreamWriter(Path.Combine(directory, filename)))
                {
                    Templates.HtmlSpoiler htmlspoiler = new Templates.HtmlSpoiler(spoiler);
                    newlog.Write(htmlspoiler.TransformText());
                }
            }
            else
            {
                filename += "_SpoilerLog.txt";
                CreateTextSpoilerLog(spoiler, Path.Combine(directory, filename));
            }
        }
Example #3
0
        public static void CreateSpoilerLog(RandomizedResult randomized, GameplaySettings settings, OutputSettings outputSettings)
        {
            var itemList = randomized.ItemList
                           .Where(io => (io.IsRandomized && io.NewLocation.Value.Region().HasValue) || (io.Item.MainLocation().HasValue&& randomized.ItemList[io.Item.MainLocation().Value].IsRandomized))
                           .Select(io => new {
                ItemObject            = io.Item.MainLocation().HasValue ? randomized.ItemList.Find(x => x.NewLocation == io.Item.MainLocation().Value) : io,
                LocationForImportance = io.NewLocation ?? io.Item,
                Region = io.IsRandomized ? io.NewLocation.Value.Region().Value : io.Item.Region().Value,
            })
                           .Select(u => new SpoilerItem(
                                       u.ItemObject,
                                       u.Region,
                                       ItemUtils.IsRequired(u.ItemObject.Item, u.LocationForImportance, randomized),
                                       ItemUtils.IsImportant(u.ItemObject.Item, u.LocationForImportance, randomized),
                                       randomized.ImportantSongLocations.Contains(u.LocationForImportance),
                                       settings.ProgressiveUpgrades
                                       ));

            randomized.Logic.ForEach((il) =>
            {
                if (il.ItemId >= 0)
                {
                    var io        = randomized.ItemList[il.ItemId];
                    il.IsFakeItem = (io.Item.IsFake() && io.Item.Entrance() == null) || !io.IsRandomized;
                }
            });

            Dictionary <Item, Item> dungeonEntrances = new Dictionary <Item, Item>();

            if (settings.RandomizeDungeonEntrances)
            {
                var entrances = new List <Item>
                {
                    Item.AreaWoodFallTempleAccess,
                    Item.AreaSnowheadTempleAccess,
                    Item.AreaGreatBayTempleAccess,
                    Item.AreaInvertedStoneTowerTempleAccess,
                };
                foreach (var entrance in entrances.OrderBy(e => entrances.IndexOf(randomized.ItemList[e].NewLocation.Value)))
                {
                    dungeonEntrances.Add(randomized.ItemList[entrance].NewLocation.Value, entrance);
                }
            }
            var settingsString = settings.ToString();

            var directory = Path.GetDirectoryName(outputSettings.OutputROMFilename);
            var filename  = $"{Path.GetFileNameWithoutExtension(outputSettings.OutputROMFilename)}";

            var     plainTextRegex = new Regex("[^a-zA-Z0-9' .\\-]+");
            Spoiler spoiler        = new Spoiler()
            {
                Version          = Randomizer.AssemblyVersion,
                SettingsString   = settingsString,
                Seed             = randomized.Seed,
                DungeonEntrances = dungeonEntrances,
                ItemList         = itemList.ToList(),
                Logic            = randomized.Logic,
                GossipHints      = randomized.GossipQuotes?.ToDictionary(me => (GossipQuote)me.Id, (me) =>
                {
                    var message     = me.Message.Substring(1);
                    var soundEffect = message.Substring(0, 2);
                    message         = message.Substring(2);
                    if (soundEffect == "\x69\x0C")
                    {
                        // real
                    }
                    else if (soundEffect == "\x69\x0A")
                    {
                        // fake
                        message = "FAKE - " + message;
                    }
                    else
                    {
                        // junk
                        message = "JUNK - " + message;
                    }
                    return(plainTextRegex.Replace(message.Replace("\x11", " "), ""));
                }),
                MessageCosts = randomized.MessageCosts.Select((mc, i) =>
                {
                    if (!mc.HasValue)
                    {
                        return(((string, ushort)?)null);
                    }
                    var messageCost = MessageCost.MessageCosts[i];

                    var name = messageCost.Name;
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        if (messageCost.LocationsAffected.Count > 0)
                        {
                            var location     = messageCost.LocationsAffected[0];
                            var mainLocation = location.MainLocation();
                            if (mainLocation.HasValue)
                            {
                                name = $"{mainLocation.Value.Location()} ({location.ToString().Replace(mainLocation.Value.ToString(), "")})";
                            }
                            else
                            {
                                name = location.Location();
                            }
                        }
                        else
                        {
                            name = $"Message Cost [{i}]";
                        }
                    }
                    return(name, mc.Value);
                }).Where(mc => mc != null).Select(mc => mc.Value).ToList(),
            };

            if (outputSettings.GenerateHTMLLog)
            {
                using (StreamWriter newlog = new StreamWriter(Path.Combine(directory, filename + "_Tracker.html")))
                {
                    Templates.HtmlSpoiler htmlspoiler = new Templates.HtmlSpoiler(spoiler);
                    newlog.Write(htmlspoiler.TransformText());
                }
            }

            if (outputSettings.GenerateSpoilerLog)
            {
                CreateTextSpoilerLog(spoiler, Path.Combine(directory, filename + "_SpoilerLog.txt"));
            }
        }
Example #4
0
        public static void CreateSpoilerLog(RandomizedResult randomized, GameplaySettings settings, OutputSettings outputSettings)
        {
            var itemList = randomized.ItemList
                           .Where(io => !io.Item.IsFake() && io.NewLocation.HasValue)
                           .Select(u => new SpoilerItem(u, ItemUtils.IsRequired(u.Item, randomized), ItemUtils.IsImportant(u.Item, randomized), settings.ProgressiveUpgrades));

            Dictionary <Item, Item> dungeonEntrances = new Dictionary <Item, Item>();

            if (settings.RandomizeDungeonEntrances)
            {
                var entrances = new List <Item>
                {
                    Item.AreaWoodFallTempleAccess,
                    Item.AreaSnowheadTempleAccess,
                    Item.AreaGreatBayTempleAccess,
                    Item.AreaInvertedStoneTowerTempleAccess,
                };
                foreach (var entrance in entrances.OrderBy(e => entrances.IndexOf(randomized.ItemList[e].NewLocation.Value)))
                {
                    dungeonEntrances.Add(randomized.ItemList[entrance].NewLocation.Value, entrance);
                }
            }
            var settingsString = settings.ToString();

            var directory = Path.GetDirectoryName(outputSettings.OutputROMFilename);
            var filename  = $"{Path.GetFileNameWithoutExtension(outputSettings.OutputROMFilename)}";

            var     plainTextRegex = new Regex("[^a-zA-Z0-9' .\\-]+");
            Spoiler spoiler        = new Spoiler()
            {
                Version          = Randomizer.AssemblyVersion,
                SettingsString   = settingsString,
                Seed             = randomized.Seed,
                DungeonEntrances = dungeonEntrances,
                ItemList         = itemList.ToList(),
                Logic            = randomized.Logic,
                GossipHints      = randomized.GossipQuotes?.ToDictionary(me => (GossipQuote)me.Id, (me) =>
                {
                    var message     = me.Message.Substring(1);
                    var soundEffect = message.Substring(0, 2);
                    message         = message.Substring(2);
                    if (soundEffect == "\x69\x0C")
                    {
                        // real
                    }
                    else if (soundEffect == "\x69\x0A")
                    {
                        // fake
                        message = "FAKE - " + message;
                    }
                    else
                    {
                        // junk
                        message = "JUNK - " + message;
                    }
                    return(plainTextRegex.Replace(message.Replace("\x11", " "), ""));
                }),
            };

            if (outputSettings.GenerateHTMLLog)
            {
                using (StreamWriter newlog = new StreamWriter(Path.Combine(directory, filename + "_Tracker.html")))
                {
                    Templates.HtmlSpoiler htmlspoiler = new Templates.HtmlSpoiler(spoiler);
                    newlog.Write(htmlspoiler.TransformText());
                }
            }

            if (outputSettings.GenerateSpoilerLog)
            {
                CreateTextSpoilerLog(spoiler, Path.Combine(directory, filename + "_SpoilerLog.txt"));
            }
        }