Esempio n. 1
0
        /// <summary>Convert the given <see cref="BfavContent"/> to <see cref="FavrContent"/>.</summary>
        /// <param name="bfavContent">The <see cref="BfavContent"/> to convert.</param>
        /// <returns>The converted passed <see cref="BfavContent"/>.</returns>
        private static List <FavrCustomAnimal> ConvertBfavContent(BfavContent bfavContent)
        {
            var favrAnimals = new List <FavrCustomAnimal>();

            foreach (var category in bfavContent.Categories)
            {
                Logger.WriteLine($"Converting animal: {category.AnimalShop?.Name ?? category.Category}", ConsoleColor.Gray);

                // create the animal subtypes
                var subtypes = new List <FavrCustomAnimalType>();
                foreach (var type in category.Types)
                {
                    var splitDataString = type.Data.Split('/');

                    var productId       = splitDataString[2];
                    var deluxeProductId = splitDataString[3];
                    var meatId          = splitDataString[23];

                    // check if the (deluxe|meat)product ids are valid ids, or it they should have api tokens added to them
                    if (!int.TryParse(productId, out _))
                    {
                        productId = $"spacechase0.JsonAssets:GetObjectId:{productId}";
                    }
                    if (!int.TryParse(deluxeProductId, out _))
                    {
                        deluxeProductId = $"spacechase0.JsonAssets:GetObjectId:{deluxeProductId}";
                    }
                    if (!int.TryParse(meatId, out _))
                    {
                        meatId = $"spacechase0.JsonAssets:GetObjectId:{meatId}";
                    }

                    // convert produce
                    var toolName = splitDataString[22];

                    // determine tool harvest sound as FAVR requires packs to be explicit
                    string toolHarvestSound = null;
                    if (toolName.ToLower() == "shears")
                    {
                        toolHarvestSound = "scissors";
                    }
                    else if (toolName.ToLower() == "milk pail")
                    {
                        toolHarvestSound = "Milking";
                    }

                    var produce = new FavrAnimalProduce(defaultProductId: productId, upgradedProductId: deluxeProductId, harvestType: (HarvestType)Convert.ToInt32(splitDataString[13]), toolHarvestSound: toolHarvestSound, daysToProduce: Convert.ToInt32(splitDataString[0]), toolName: toolName);

                    subtypes.Add(new FavrCustomAnimalType(
                                     action: Action.Add,
                                     name: type.Type,
                                     isBuyable: true,
                                     isIncubatable: true,
                                     produce: new List <FavrAnimalProduce> {
                        produce
                    },
                                     daysTillMature: Convert.ToByte(splitDataString[1]),
                                     soundId: splitDataString[4],
                                     frontAndBackSpriteWidth: Convert.ToInt32(splitDataString[16]),
                                     frontAndBackSpriteHeight: Convert.ToInt32(splitDataString[17]),
                                     sideSpriteWidth: Convert.ToInt32(splitDataString[18]),
                                     sideSpriteHeight: Convert.ToInt32(splitDataString[19]),
                                     meatId: meatId,
                                     happinessDrain: Convert.ToByte(splitDataString[21])
                                     ));
                }

                var  action  = Action.Add;
                bool?buyable = category.AnimalShop != null;
                if (category.Action.ToLower() == "update")
                {
                    Logger.WriteLine("Manual audit required, when an animal has an action of 'Update' the internal name needs to be specified in the FAVR pack", ConsoleColor.Red);
                    action  = Action.Edit;
                    buyable = null; // inherit buyablility from the pack who added the animal
                }

                favrAnimals.Add(new FavrCustomAnimal(
                                    action: action,
                                    internalName: action == Action.Add ? null : "input animal internal name here",
                                    name: category.AnimalShop?.Name ?? category.Category,
                                    buyable: (buyable.HasValue && !buyable.Value) ? false : null, // turn 'true' into null (so it gets ommited from the final favr file as that's the default value)
                                    canSwim: false,
                                    animalShopInfo: new FavrAnimalShopInfo(
                                        description: category.AnimalShop?.Description,
                                        buyPrice: category.AnimalShop?.Price ?? 0),
                                    types: subtypes,
                                    buildings: category.Buildings
                                    ));
            }

            return(favrAnimals);
        }
Esempio n. 2
0
 /*********
 ** Public Methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="name">The name of the subtype.</param>
 /// <param name="produce">The produce for the sub type.</param>
 public FavrAnimalSubType(string name, FavrAnimalProduce produce)
 {
     Name    = name;
     Produce = produce;
 }