예제 #1
0
        public static bool WriteSpoilers(Randomiser randomiser)
        {
            string          currentDir      = Directory.GetCurrentDirectory();
            List <Location> placedLocations = randomiser.GetPlacedLocations();

            try
            {
                using (StreamWriter sr = File.CreateText(Path.Combine(currentDir, "Seed\\spoilers.txt")))
                {
                    sr.WriteLine("Seed: {0}", randomiser.Seed);
                    sr.WriteLine();

                    foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
                    {
                        foreach (var location in placedLocations)
                        {
                            if (id == location.id && id != LocationID.None)
                            {
                                sr.WriteLine("{0} -> {1}", location.name, location.item.name);
                            }
                        }
                    }

                    sr.WriteLine();
                    sr.WriteLine("Expected Playthrough");

                    PlayerState     playthrough = new PlayerState(randomiser);
                    List <Location> reachableLocations;

                    do
                    {
                        reachableLocations = playthrough.GetReachableLocations(randomiser.GetPlacedRequiredItemLocations());
                        sr.WriteLine("{");
                        foreach (var location in reachableLocations)
                        {
                            playthrough.CollectItem(location.item);
                            playthrough.collectedLocations.Add(location.name, true);
                            if ((int)location.item.id < 155)
                            {
                                sr.WriteLine("  {0} -> {1}", location.name, location.item.name);
                            }
                        }
                        sr.WriteLine("}");
                        playthrough.ResetCheckedAreasAndEntrances();
                    } while (reachableLocations.Count > 0);
                }
            }
            catch (Exception ex)
            {
                Logger.GetLogger.Log("Error: {0}", ex.Message);
                return(false);
            }

            return(true);
        }
예제 #2
0
        public static bool WriteSpoilers(Randomiser randomiser)
        {
            try
            {
                using (StreamWriter sr = File.CreateText("Seed\\spoilers.txt"))
                {
                    sr.WriteLine($"Seed: {randomiser.Settings.Seed}");
                    sr.WriteLine();

                    sr.WriteLine($"Starting Weapon: {randomiser.StartingWeapon.name}");
                    sr.WriteLine();

                    if (randomiser.Settings.RandomCurses)
                    {
                        sr.WriteLine("Curse Locations:");
                        foreach (Location location in randomiser.CursedLocations)
                        {
                            sr.WriteLine($"  {location.Name}");
                        }
                        sr.WriteLine();
                    }

                    foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
                    {
                        foreach (Location location in randomiser.GetPlacedLocations())
                        {
                            if (id != LocationID.None && id == location.Id)
                            {
                                sr.WriteLine($"{location.Name} -> {location.Item.name}");
                            }
                        }
                    }
                    sr.WriteLine();
                    sr.WriteLine("Expected Playthrough");

                    PlayerState     playthrough = new PlayerState(randomiser);
                    List <Location> reachableLocations;

                    do
                    {
                        reachableLocations = playthrough.GetReachableLocations(randomiser.GetPlacedRequiredItemLocations());
                        sr.WriteLine("{");
                        foreach (Location location in reachableLocations)
                        {
                            playthrough.CollectItem(location.Item);
                            playthrough.collectedLocations.Add(location.Name, true);
                            sr.WriteLine($"  {location.Name} -> {location.Item.name}");
                        }
                        sr.WriteLine("}");

                        if (playthrough.CanBeatGame(reachableLocations))
                        {
                            break;
                        }

                        playthrough.ResetCheckedAreasAndEntrances();
                    } while (reachableLocations.Count > 0);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log($"Failed to write spoiler log.\n {ex.Message}");
                return(false);
            }
        }
예제 #3
0
        public static bool WriteSpoilerLog(Randomiser randomiser)
        {
            try
            {
                using (StreamWriter sw = File.CreateText("Seed\\spoilers.txt"))
                {
                    sw.WriteLine($"Seed: {randomiser.Settings.Seed}\n");

                    sw.WriteLine($"Starting Weapon: {randomiser.StartingWeapon?.Name}\n");

                    sw.WriteLine("Curse Locations: {");
                    foreach (Location location in randomiser.CursedLocations)
                    {
                        sw.WriteLine($"  {location.Name}");
                    }

                    sw.WriteLine("}\n");

                    sw.WriteLine("Entrance Placement: {");
                    if (!randomiser.Settings.FullRandomEntrances)
                    {
                        if (randomiser.Settings.RandomHorizontalEntraces)
                        {
                            sw.WriteLine("  Horizontal Entrances: {");
                            foreach (string pair in randomiser.HorizontalPairs)
                            {
                                sw.WriteLine(pair);
                            }

                            sw.WriteLine("  }");
                        }

                        if (randomiser.Settings.RandomLadderEntraces)
                        {
                            sw.WriteLine("  Ladders Entrances: {");
                            foreach (string pair in randomiser.LadderPairs)
                            {
                                sw.WriteLine(pair);
                            }

                            sw.WriteLine("  }");
                        }

                        if (randomiser.Settings.RandomGateEntraces)
                        {
                            sw.WriteLine("  Gate Entrances: {");
                            foreach (string pair in randomiser.GatePairs)
                            {
                                sw.WriteLine(pair);
                            }

                            sw.WriteLine("  }");
                        }
                    }
                    else
                    {
                        sw.WriteLine("  Entrances: {");
                        foreach (string pair in randomiser.EntrancePairs)
                        {
                            sw.WriteLine(pair);
                        }

                        sw.WriteLine("  }");
                    }

                    if (randomiser.Settings.RandomSoulGateEntraces)
                    {
                        sw.WriteLine("  Soul Gate Entrances: {");
                        foreach (var pair in randomiser.SoulGatePairs)
                        {
                            sw.WriteLine($"    {pair.Item1.Name} - {pair.Item2.Name}: Soul Amount {pair.Item3}");
                        }

                        sw.WriteLine("  }");
                    }
                    sw.WriteLine("}\n");

                    sw.WriteLine("Item Placement {");
                    foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
                    {
                        foreach (Location location in randomiser.GetPlacedLocations())
                        {
                            if (id != LocationID.None && id == location.ID)
                            {
                                sw.WriteLine($"  {location.Name} -> {location.Item.Name}");
                            }
                        }
                    }
                    sw.WriteLine("}\n");
                    sw.WriteLine("Expected Playthrough {");

                    PlayerState playthrough = new PlayerState(randomiser)
                    {
                        IgnoreFalseChecks = true
                    };
                    playthrough.CollectItem(randomiser.StartingWeapon);

                    List <Location> reachableLocations;

                    int sphere = 0;
                    do
                    {
                        reachableLocations = playthrough.GetReachableLocations(randomiser.GetPlacedRequiredItemLocations());
                        sw.WriteLine($"  Sphere {sphere} {{");
                        foreach (Location location in reachableLocations)
                        {
                            playthrough.CollectItem(location.Item);
                            playthrough.CollectLocation(location);
                            sw.WriteLine($"    {location.Name} -> {location.Item.Name}");
                        }
                        sw.WriteLine("  }");

                        if (playthrough.CanBeatGame())
                        {
                            break;
                        }

                        playthrough.RemoveFalseCheckedAreasAndEntrances();
                        sphere++;
                    } while (reachableLocations.Count > 0);
                    sw.WriteLine("}");
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log($"Failed to write spoiler log.\n {ex.Message}");
                return(false);
            }
        }