Esempio n. 1
0
 /// <summary>
 /// Validates that the image exists given the name
 /// </summary>
 private void ValidateImage(string fileName)
 {
     if (!BundleImageNames.Contains(fileName))
     {
         Globals.ConsoleWarn($"Could not validate bundle image: {ImageDirectory}/{fileName}.png");
     }
 }
        /// <summary>
        /// Gets a random file name that matches the weapon type at the given position
        /// Will remove the name found from the list
        /// </summary>
        /// <param name="position">The position</param>
        /// <returns>The selected file name</returns>
        protected override string GetRandomFileName(Point position)
        {
            string fileName = "";

            switch (GetWeaponTypeFromPosition(position))
            {
            case WeaponType.SlashingSword:
            case WeaponType.StabbingSword:
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(SwordImages);
                break;

            case WeaponType.Dagger:
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(DaggerImages);
                break;

            case WeaponType.ClubOrHammer:
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(HammerAndClubImages);
                break;

            case WeaponType.Slingshot:
                // TODO:Use slingshot images when we actually randomize them
                break;

            default:
                Globals.ConsoleError($"No weapon type defined at image position: {position.X}, {position.Y}");
                break;
            }

            if (string.IsNullOrEmpty(fileName))
            {
                Globals.ConsoleWarn($"Using default image for weapon at image position - you may not have enough weapon images: {position.X}, {position.Y}");
                return(null);
            }
            return(fileName);
        }
Esempio n. 3
0
        /// <summary>
        /// This is the method to repalce the existing Crop.getRandomWildCropForSeason
        /// This will make the seed grow a crop of an actual appropriate type
        /// </summary>
        /// <param name="season">The season string: "spring", "summer", "fall", or "winter"</param>
        /// <returns>The ID of the random wild crop</returns>
        public int GetRandomWildCropForSeason(string season)
        {
            List <int> wildCropIDs;

            switch (season)
            {
            case "spring":
                wildCropIDs = ItemList.GetForagables(Seasons.Spring)
                              .Where(x => x.ShouldBeForagable).Select(x => x.Id).ToList();
                break;

            case "summer":
                wildCropIDs = ItemList.GetForagables(Seasons.Summer)
                              .Where(x => x.ShouldBeForagable).Select(x => x.Id).ToList();
                break;

            case "fall":
                wildCropIDs = ItemList.GetForagables(Seasons.Fall)
                              .Where(x => x.ShouldBeForagable).Select(x => x.Id).ToList();
                break;

            case "winter":
                wildCropIDs = ItemList.GetForagables(Seasons.Winter)
                              .Where(x => x.ShouldBeForagable).Select(x => x.Id).ToList();
                break;

            default:
                Globals.ConsoleWarn($"GetRandomWildCropForSeason was passed an unexpected season value: {season}. Returning the ID for horseradish.");
                return((int)ObjectIndexes.WildHorseradish);
            }

            return(Globals.RNGGetRandomValueFromList(wildCropIDs, true));
        }
        /// <summary>
        /// Gets a random file name that matches the crop growth image at the given position
        /// Will remove the name found from the list
        /// </summary>
        /// <param name="position">The position</param>
        /// <returns>The selected file name</returns>
        protected override string GetRandomFileName(Point position)
        {
            string fileName = "";

            int  cropId = CropGrowthImagePointsToIds[position];
            Item item   = ItemList.Items[cropId];

            SeedItem seedItem = item.Id == (int)ObjectIndexes.CoffeeBean ?
                                (SeedItem)item : ((CropItem)item).MatchingSeedItem;
            CropGrowthInformation growthInfo = seedItem.CropGrowthInfo;

            FixWidthValue(seedItem.CropGrowthInfo.GraphicId);

            if (item.IsFlower)
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(FlowerImages);

                if (!seedItem.CropGrowthInfo.TintColorInfo.HasTint)
                {
                    fileName = $"{fileName.Substring(0, fileName.Length - 4)}-NoHue.png";
                }
            }

            else if (growthInfo.IsTrellisCrop)
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(TrellisImages);
            }

            else if (growthInfo.RegrowsAfterHarvest)
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(RegrowingImages);
            }

            else
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(NormalImages);

                if (growthInfo.GrowthStages.Count <= 4)
                {
                    fileName += "-4.png";
                }

                else
                {
                    fileName += "-5.png";
                }
            }

            if (string.IsNullOrEmpty(fileName) || fileName == "-4.png" || fileName == "-5.png")
            {
                Globals.ConsoleWarn($"Using default image for crop growth - you may not have enough crop growth images: {position.X}, {position.Y}");
                return(null);
            }


            CropIdsToImageNames[cropId] = Path.GetFileName(fileName).Replace("-4.png", ".png").Replace("-5.png", ".png").Replace("-NoHue.png", ".png");
            return(fileName);
        }
 /// <summary>
 /// Validates that all the items in the ObjectIndexes exist in the main item list
 /// </summary>
 private void ValidateItemList()
 {
     foreach (ObjectIndexes index in Enum.GetValues(typeof(ObjectIndexes)).Cast <ObjectIndexes>())
     {
         if (!ItemList.Items.ContainsKey((int)index))
         {
             Globals.ConsoleWarn($"Missing item: {(int)index}: {index.ToString()}");
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Gets a random file name from the files to pull from and removes the found entry from the list
        /// </summary>
        /// <param name="position">The position of the instrument - unused in this version of the function</param>
        /// <returns></returns>
        protected virtual string GetRandomFileName(Point position)
        {
            string fileName = Globals.RNGGetAndRemoveRandomValueFromList(FilesToPullFrom);

            if (string.IsNullOrEmpty(fileName))
            {
                Globals.ConsoleWarn($"Not enough images at directory (need more images, using default image): {ImageDirectory}");
                return(null);
            }

            return(fileName);
        }
Esempio n. 7
0
        /// <summary>
        /// Whether the settings premit random weapon images
        /// </summary>
        /// <returns>True if so, false otherwise</returns>
        protected override bool ShouldSaveImage(Point position)
        {
            if (!Globals.Config.Bundles.Randomize)
            {
                return(false);
            }

            Bundle bundle = PointsToBundlesMap[position];

            if (BundleImageNames.Contains(bundle.ImageName))
            {
                return(true);
            }

            Globals.ConsoleWarn($"Could not find bundle image: {ImageDirectory}/{bundle.ImageName}.png");
            return(false);
        }
Esempio n. 8
0
        /// <summary>
        /// Adds a random new item to a list
        /// </summary>
        /// <param name="listToPopulate">The list to populate</param>
        private static void AddUniqueNewForagable(List <Item> listToPopulate)
        {
            if (listToPopulate.Count >= _allForagables.Count)
            {
                Globals.ConsoleWarn("Tried to add a unique foragable when the given list was full!");
                return;
            }

            int itemIndex;

            do
            {
                itemIndex = Globals.RNG.Next(0, _allForagables.Count);
            } while (listToPopulate.Contains(_allForagables[itemIndex]));

            listToPopulate.Add(_allForagables[itemIndex]);
        }
        /// <summary>
        /// Gets a random file name that matches the crop growth image at the given position (fish excluded)
        /// Will remove the name found from the list
        /// </summary>
        /// <param name="position">The position</param>
        /// <returns>The selected file name</returns>
        protected override string GetRandomFileName(Point position)
        {
            ImageWidthInPx = 16;

            int    itemId       = PointsToItemIds[position];
            string fileName     = "";
            string subDirectory = "";

            if (BootData.AllBoots.Any(x => x.Id == itemId))
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(BootImages);

                if (string.IsNullOrEmpty(fileName))
                {
                    Globals.ConsoleWarn($"Could not find the boot image for id {itemId}; using default image instead.");
                    return(null);
                }

                return(fileName);
            }

            Item item = ItemList.Items[itemId];

            if (item.Id == (int)ObjectIndexes.CherrySapling)
            {
                ImageWidthInPx = 96;
                return($"{ImageDirectory}/fruitTreeSprites.png");
            }

            if (item.IsFish)
            {
                fileName = Globals.RNGGetAndRemoveRandomValueFromList(FishImages);

                if (string.IsNullOrEmpty(fileName))
                {
                    Globals.ConsoleWarn($"Could not find the fish image for {item.Name}; using default image instead.");
                    return(null);
                }

                return(fileName);
            }

            int cropId = item.Id;

            if (item.IsCrop || item.Id == (int)ObjectIndexes.CoffeeBean)
            {
                subDirectory = "/Crops";
            }

            else if (item.IsSeed)
            {
                SeedItem seedItem = (SeedItem)item;
                cropId       = seedItem.CropGrowthInfo.CropId;
                subDirectory = "/Seeds";
            }

            if (item.IsFlower)
            {
                subDirectory = "/Flowers";

                CropItem cropItem = (CropItem)item;
                if (cropItem.MatchingSeedItem.CropGrowthInfo.TintColorInfo.HasTint)
                {
                    ImageWidthInPx = 32;                     // Flower images include the stem and the top if they have tint
                }
            }

            if (!CropIdsToImageNames.TryGetValue(cropId, out fileName))
            {
                Globals.ConsoleWarn($"Could not find the matching image for {item.Name}; using default image instead.");
                return(null);
            }

            return($"{ImageDirectory}{subDirectory}/{fileName}");
        }
 /// <summary>
 /// Force generate a random bundle
 /// Failsafe in case we run out of bundles
 /// </summary>
 protected void GenerateRandomBundleFailsafe()
 {
     Globals.ConsoleWarn($"Had to generate random bundle for {Room} as a fallback for this bundle: {BundleType.ToString()}");
     PopulateRandomBundle();
     GenerateRandomReward();
 }
        /// <summary>
        /// Validates that the crop growth images map to the appropriate directories
        /// </summary>
        private void ValidateCropImages()
        {
            // Gather data for normal images
            string        normalCropGrowthDirectory = $"{ImageDirectory}/{NormalDirectory}";
            List <string> normalImageNames          = Directory.GetFiles(normalCropGrowthDirectory).ToList();

            List <string> normal4StageImages = normalImageNames
                                               .Where(x => x.EndsWith("-4.png"))
                                               .Select(x => Path.GetFileName(x.Replace("-4.png", "")))
                                               .ToList();

            List <string> normal5StageImages = normalImageNames
                                               .Where(x => x.EndsWith("-5.png"))
                                               .Select(x => Path.GetFileName(x.Replace("-5.png", "")))
                                               .ToList();

            // Validate that the stage 4 and 5 match
            if (normal4StageImages.Count != normal5StageImages.Count)
            {
                string missingNumber = normal5StageImages.Count > normal4StageImages.Count ? "5" : "4";
                Globals.ConsoleWarn($"Missing a stage {missingNumber} image at: {normalCropGrowthDirectory}");
            }

            // Gather the all of the crop growth images and validate whether their names are all unique
            List <string> normalCropGrowthImages    = NormalImages.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
            List <string> regrowingCropGrowthImages = RegrowingImages.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
            List <string> trellisCropGrowthImages   = TrellisImages.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
            List <string> flowerCropGrowthImages    = FlowerImages.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();

            List <string> allCropGrowthImages = normalCropGrowthImages
                                                .Concat(regrowingCropGrowthImages)
                                                .Concat(trellisCropGrowthImages)
                                                .Concat(flowerCropGrowthImages)
                                                .Distinct()
                                                .ToList();

            int countOfEachPath = normalCropGrowthImages.Count + regrowingCropGrowthImages.Count + trellisCropGrowthImages.Count + flowerCropGrowthImages.Count;

            if (allCropGrowthImages.Count != countOfEachPath)
            {
                Globals.ConsoleWarn($"Duplicate image name detected in one of the folders at: {ImageDirectory}");
            }

            // Check that every crop growth image has a matching seed packet
            string        seedImageDirectory = $"{CustomImagesPath}/SpringObjects/Seeds";
            List <string> seedImageNames     = Directory.GetFiles(seedImageDirectory)
                                               .Where(x => x.EndsWith(".png"))
                                               .Select(x => Path.GetFileNameWithoutExtension(x))
                                               .ToList();

            foreach (string growthImageName in allCropGrowthImages)
            {
                if (!seedImageNames.Contains(growthImageName))
                {
                    Globals.ConsoleWarn($"{growthImageName}.png not found at: {seedImageDirectory}");
                }
            }

            // Check that all crop growth images exist as a crop or flower
            string        cropImageDirectory = $"{CustomImagesPath}/SpringObjects/Crops";
            List <string> cropImageNames     = Directory.GetFiles(cropImageDirectory)
                                               .Where(x => x.EndsWith(".png"))
                                               .Select(x => Path.GetFileNameWithoutExtension(x))
                                               .ToList();

            foreach (string cropImageName in normalCropGrowthImages.Concat(regrowingCropGrowthImages).Concat(trellisCropGrowthImages))
            {
                if (!cropImageNames.Contains(cropImageName))
                {
                    Globals.ConsoleWarn($"{cropImageName}.png not found at: {cropImageDirectory}");
                }
            }

            string        flowerImageDirectory = $"{CustomImagesPath}/SpringObjects/Flowers";
            List <string> flowerImageNames     = Directory.GetFiles(flowerImageDirectory)
                                                 .Where(x => x.EndsWith(".png"))
                                                 .Select(x => Path.GetFileNameWithoutExtension(x))
                                                 .ToList();

            foreach (string flowerImageName in flowerCropGrowthImages)
            {
                if (!flowerImageNames.Contains(flowerImageName))
                {
                    Globals.ConsoleWarn($"{flowerImageName}.png not found at: {flowerImageDirectory}");
                }
            }

            // Check that each flower image contains the no-hue version
            List <string> noHueFlowerImages = Directory.GetFiles($"{ImageDirectory}/{FlowersDirectory}")
                                              .Where(x => x.EndsWith("-NoHue.png"))
                                              .Select(x => Path.GetFileNameWithoutExtension(x))
                                              .OrderBy(x => x)
                                              .ToList();

            foreach (string flowerImageName in flowerCropGrowthImages)
            {
                if (!noHueFlowerImages.Contains($"{flowerImageName}-NoHue"))
                {
                    Globals.ConsoleWarn($"{flowerImageName}-NoHue.png not found at: {ImageDirectory}/{FlowersDirectory}");
                }
            }
        }