Esempio n. 1
0
        /// <summary>
        /// Randomizes boots - currently only changes defense and immunity
        /// </summary>
        /// <returns />
        public static Dictionary <int, string> Randomize()
        {
            Boots.Clear();
            WeaponAndArmorNameRandomizer nameRandomizer = new WeaponAndArmorNameRandomizer();
            List <string> descriptions = NameAndDescriptionRandomizer.GenerateBootDescriptions(BootData.AllBoots.Count);

            Dictionary <int, string> bootReplacements = new Dictionary <int, string>();
            List <BootItem>          bootsToUse       = new List <BootItem>();

            for (int i = 0; i < BootData.AllBoots.Count; i++)
            {
                BootItem originalBoot = BootData.AllBoots[i];
                int      statPool     = Globals.RNGGetIntWithinPercentage(originalBoot.Defense + originalBoot.Immunity, 30);
                int      defense      = Range.GetRandomValue(0, statPool);
                int      immunity     = statPool - defense;

                if ((defense + immunity) == 0)
                {
                    if (Globals.RNGGetNextBoolean())
                    {
                        defense = 1;
                    }

                    else
                    {
                        immunity = 1;
                    }
                }

                BootItem newBootItem = new BootItem(
                    originalBoot.Id,
                    nameRandomizer.GenerateRandomBootName(),
                    descriptions[i],
                    originalBoot.NotActuallyPrice,
                    defense,
                    immunity,
                    originalBoot.ColorSheetIndex
                    );

                bootsToUse.Add(newBootItem);
                Boots.Add(newBootItem.Id, newBootItem);
            }

            foreach (BootItem bootToAdd in bootsToUse)
            {
                bootReplacements.Add(bootToAdd.Id, bootToAdd.ToString());
            }

            WriteToSpoilerLog(bootsToUse);
            return(bootReplacements);
        }
Esempio n. 2
0
        public static void Randomize(EditedObjectInformation editedObjectInfo)
        {
            List <FishItem> legendaryFish  = FishItem.GetLegendaries().Cast <FishItem>().ToList();
            List <FishItem> normalFish     = FishItem.Get().Cast <FishItem>().ToList();
            List <FishItem> normalFishCopy = new List <FishItem>();

            foreach (FishItem fish in normalFish)
            {
                FishItem fishInfo = new FishItem(fish.Id, true);
                CopyFishInfo(fish, fishInfo);
                normalFishCopy.Add(fishInfo);
            }

            List <string> fishNames = NameAndDescriptionRandomizer.GenerateFishNames(normalFish.Count + legendaryFish.Count);

            foreach (FishItem fish in normalFish)
            {
                FishItem         fishToReplace   = Globals.RNGGetAndRemoveRandomValueFromList(normalFishCopy);
                int              newDartChance   = GenerateRandomFishDifficulty();
                FishBehaviorType newBehaviorType = Globals.RNGGetRandomValueFromList(
                    Enum.GetValues(typeof(FishBehaviorType)).Cast <FishBehaviorType>().ToList());
                string newName = Globals.RNGGetAndRemoveRandomValueFromList(fishNames);

                if (!Globals.Config.Fish.Randomize)
                {
                    continue;
                }

                CopyFishInfo(fishToReplace, fish);
                fish.DartChance   = newDartChance;
                fish.BehaviorType = newBehaviorType;
                fish.OverrideName = newName;

                if (fish.IsMinesFish)
                {
                    if (!fish.AvailableLocations.Contains(Locations.UndergroundMine))
                    {
                        fish.AvailableLocations.Add(Locations.UndergroundMine);
                    }
                }

                if (Globals.Config.Fish.Randomize)
                {
                    if (fish.IsSubmarineOnlyFish)
                    {
                        fish.DifficultyToObtain = ObtainingDifficulties.RareItem;
                    }
                    else
                    {
                        fish.DifficultyToObtain = ObtainingDifficulties.LargeTimeRequirements;
                    }
                }

                editedObjectInfo.FishReplacements.Add(fish.Id, fish.ToString());
                editedObjectInfo.ObjectInformationReplacements.Add(fish.Id, GetFishObjectInformation(fish));
            }

            foreach (FishItem fish in legendaryFish)
            {
                FishBehaviorType newBehaviorType = Globals.RNGGetRandomValueFromList(
                    Enum.GetValues(typeof(FishBehaviorType)).Cast <FishBehaviorType>().ToList());

                string newName = Globals.RNGGetAndRemoveRandomValueFromList(fishNames);

                if (!Globals.Config.Fish.Randomize)
                {
                    continue;
                }

                fish.BehaviorType = newBehaviorType;
                fish.OverrideName = newName;

                editedObjectInfo.FishReplacements.Add(fish.Id, fish.ToString());
                editedObjectInfo.ObjectInformationReplacements.Add(fish.Id, GetFishObjectInformation(fish));
            }

            WriteToSpoilerLog();
        }
        /// <summary>
        /// Randomizes the crops - currently only does prices, and only for seasonal crops
        /// </summary>
        /// <param name="editedObjectInfo">The edited object information</param>
        /// crop format: name/price/-300/Seeds -74/name/tooltip
        private static void RandomizeCrops(EditedObjectInformation editedObjectInfo)
        {
            List <int> regrowableSeedIdsToRandomize = ItemList.GetSeeds().Cast <SeedItem>()
                                                      .Where(x => x.Randomize && x.CropGrowthInfo.RegrowsAfterHarvest)
                                                      .Select(x => x.Id)
                                                      .ToList();
            List <int> regrowableSeedIdsToRandomizeCopy = new List <int>(regrowableSeedIdsToRandomize);

            List <int> nonRegrowableSeedIdsToRandomize = ItemList.GetSeeds().Cast <SeedItem>()
                                                         .Where(x => x.Randomize && !x.CropGrowthInfo.RegrowsAfterHarvest)
                                                         .Select(x => x.Id)
                                                         .ToList();
            List <int> nonRegrowableSeedIdsToRandomizeCopy = new List <int>(nonRegrowableSeedIdsToRandomize);

            // Fill up a dictionary to remap the seed values
            Dictionary <int, int> seedMappings = new Dictionary <int, int>();           // Original value, new value

            foreach (int originalRegrowableSeedId in regrowableSeedIdsToRandomize)
            {
                seedMappings.Add(originalRegrowableSeedId, Globals.RNGGetAndRemoveRandomValueFromList(regrowableSeedIdsToRandomizeCopy));
            }

            foreach (int originalNonRegrowableSeedId in nonRegrowableSeedIdsToRandomize)
            {
                seedMappings.Add(originalNonRegrowableSeedId, Globals.RNGGetAndRemoveRandomValueFromList(nonRegrowableSeedIdsToRandomizeCopy));
            }

            // Loop through the dictionary and reassign the values, keeping the seasons the same as before
            foreach (KeyValuePair <int, int> seedMapping in seedMappings)
            {
                int originalValue = seedMapping.Key;
                int newValue      = seedMapping.Value;

                CropGrowthInformation cropInfoToAdd = CropGrowthInformation.ParseString(CropGrowthInformation.DefaultStringData[newValue]);
                cropInfoToAdd.GrowingSeasons = CropGrowthInformation.ParseString(CropGrowthInformation.DefaultStringData[originalValue]).GrowingSeasons;
                cropInfoToAdd.GrowthStages   = GetRandomGrowthStages(cropInfoToAdd.GrowthStages.Count);
                cropInfoToAdd.CanScythe      = Globals.RNGGetNextBoolean(10);
                cropInfoToAdd.DaysToRegrow   = cropInfoToAdd.RegrowsAfterHarvest ? Range.GetRandomValue(1, 7) : -1;

                if (!Globals.Config.RandomizeCrops)
                {
                    continue;
                }                                                                 // Preserve the original seasons/etc
                CropGrowthInformation.CropIdsToInfo[originalValue] = cropInfoToAdd;
            }

            // Set the object info
            List <CropItem> randomizedCrops = ItemList.GetCrops(true).Cast <CropItem>()
                                              .Where(x => nonRegrowableSeedIdsToRandomize.Union(regrowableSeedIdsToRandomize).Contains(x.MatchingSeedItem.Id))
                                              .ToList();
            List <CropItem> vegetables = randomizedCrops.Where(x => !x.IsFlower).ToList();
            List <CropItem> flowers    = randomizedCrops.Where(x => x.IsFlower).ToList();

            List <string> vegetableNames   = NameAndDescriptionRandomizer.GenerateVegetableNames(vegetables.Count + 1);
            List <string> cropDescriptions = NameAndDescriptionRandomizer.GenerateCropDescriptions(randomizedCrops.Count);

            SetCropAndSeedInformation(
                editedObjectInfo,
                vegetables,
                vegetableNames,
                cropDescriptions);                 // Note: It removes the descriptions it uses from the list after assigning them- may want to edit later

            SetUpCoffee(editedObjectInfo, vegetableNames[vegetableNames.Count - 1]);
            SetUpRice(editedObjectInfo);

            SetCropAndSeedInformation(
                editedObjectInfo,
                flowers,
                NameAndDescriptionRandomizer.GenerateFlowerNames(flowers.Count),
                cropDescriptions);                 // Note: It removes the descriptions it uses from the list after assigning them- may want to edit later

            SetUpCookedFood(editedObjectInfo);
        }