Esempio n. 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);
        }
Esempio n. 2
0
        public static bool WriteSeedFile(Randomiser randomiser)
        {
            List <Tuple <LocationID, ItemID> > temp = new List <Tuple <LocationID, ItemID> >();

            foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
            {
                foreach (Location location in randomiser.GetPlacedLocations())
                {
                    if (id != LocationID.None && id == location.Id)
                    {
                        temp.Add(new Tuple <LocationID, ItemID>(location.Id, location.Item.Id));
                    }
                }
            }

            try
            { using (BinaryWriter br = new BinaryWriter(File.Open("Seed\\seed.lm2r", FileMode.Create)))
              {
                  br.Write(randomiser.Settings.AutScanTablets);
                  br.Write(temp.Count);
                  foreach (var p in temp)
                  {
                      br.Write((int)p.Item1);
                      br.Write((int)p.Item2);
                  }
                  foreach (Location location in randomiser.CursedLocations)
                  {
                      br.Write((int)location.Id);
                  }
              }
              Logger.Log($"Total items randomised {temp.Count}"); }
            catch (Exception ex)
            {
                Logger.Log($"Failed to write seed file.\n {ex.Message}");
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        public static bool WriteSeedFile(Randomiser randomiser)
        {
            string          currentDir      = Directory.GetCurrentDirectory();
            List <Location> placedLocations = randomiser.GetPlacedLocations();

            Dictionary <int, int> itemLocation = new Dictionary <int, int>();

            foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
            {
                foreach (var location in placedLocations)
                {
                    if (id == location.id && id != LocationID.None)
                    {
                        itemLocation.Add((int)location.id, (int)location.item.id);
                    }
                }
            }

            FileStream      fs        = new FileStream(Path.Combine(currentDir, "Seed\\seed.lm2"), FileMode.Create);
            BinaryFormatter formatter = new BinaryFormatter();

            try
            {
                formatter.Serialize(fs, itemLocation);
            }
            catch (Exception ex)
            {
                Logger.GetLogger.Log("Error: {0}", ex.Message);
                return(false);
            }
            finally
            {
                fs.Close();
            }
            return(true);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        public static bool WriteSeedFile(Randomiser randomiser)
        {
            List <(LocationID, ItemID)>      items     = new List <(LocationID, ItemID)>();
            List <(LocationID, ItemID, int)> shopItems = new List <(LocationID, ItemID, int)>();

            foreach (LocationID id in Enum.GetValues(typeof(LocationID)))
            {
                foreach (Location location in randomiser.GetPlacedLocations())
                {
                    if (id != LocationID.None && id == location.ID)
                    {
                        if (location.LocationType == LocationType.Shop)
                        {
                            shopItems.Add((location.ID, location.Item.ID, location.Item.PriceMultiplier));
                        }
                        else
                        {
                            items.Add((location.ID, location.Item.ID));
                        }
                    }
                }
            }

            try
            {
                using (BinaryWriter br = new BinaryWriter(File.Open("Seed\\seed.lm2r", FileMode.Create)))
                {
                    br.Write((int)randomiser.StartingWeaponID);
                    br.Write(randomiser.Settings.RequiredSkulls);
                    br.Write(randomiser.Settings.RemoveITStatue);
                    br.Write(randomiser.Settings.EasyEchidna);
                    br.Write(randomiser.Settings.AutoScanTablets);
                    br.Write(randomiser.Settings.AutoPlaceSkulls);
                    br.Write(randomiser.Settings.FastCorridor);
                    br.Write(randomiser.Settings.StartingMoney);
                    br.Write(randomiser.Settings.StartingWeights);
                    br.Write(randomiser.Settings.AlwaysShellHorn);
                    br.Write(items.Count);
                    foreach (var p in items)
                    {
                        br.Write((int)p.Item1);
                        br.Write((int)p.Item2);
                    }

                    br.Write(shopItems.Count);
                    foreach (var p in shopItems)
                    {
                        br.Write((int)p.Item1);
                        br.Write((int)p.Item2);
                        br.Write(p.Item3);
                    }

                    foreach (Location location in randomiser.CursedLocations)
                    {
                        br.Write((int)location.ID);
                    }

                    br.Write(randomiser.ExitPairs.Count);
                    foreach (var d in randomiser.ExitPairs)
                    {
                        br.Write((int)d.Item1);
                        br.Write((int)d.Item2);
                    }

                    br.Write(randomiser.SoulGatePairs.Count);
                    foreach (var s in randomiser.SoulGatePairs)
                    {
                        br.Write((int)s.Item1.ID);
                        br.Write((int)s.Item2.ID);
                        br.Write(s.Item3);
                    }
                }
                Logger.Log($"Total items randomised {items.Count + shopItems.Count}");
            }
            catch (Exception ex)
            {
                Logger.Log($"Failed to write seed file.\n {ex.Message}");
                return(false);
            }
            return(true);
        }