public static void Show(IModEvents events)
        {
            Random random = ModEntry.Random;

            int catLimit = ModEntry.Indexes[AnimalType.Cat].Length;
            int dogLimit = ModEntry.Indexes[AnimalType.Dog].Length;

            bool          cat = catLimit != 0 && (dogLimit == 0 || random.NextDouble() < 0.5);
            AdoptQuestion q   = new AdoptQuestion(cat, random.Next(1, cat ? catLimit : dogLimit), events);

            events.Display.RenderedHud           += q.Display;
            Game1.currentLocation.lastQuestionKey = "AdoptPetQuestion";
            Game1.currentLocation.createQuestionDialogue(
                $"Oh dear, it looks like someone has abandoned a poor {(cat ? "Cat" : "Dog")} here! Perhaps you should pay Marnie {ModEntry.Config.AdoptionPrice} gold to give it a checkup so you can adopt it?",
                Game1.player.money < ModEntry.Config.AdoptionPrice
                    ? new[]
            {
                new Response("n", $"Unfortunately I do not have the required {ModEntry.Config.AdoptionPrice} gold in order to do this.")
            }
                    : new[]
            {
                new Response("y", "Yes, I really should adopt the poor animal!"),
                new Response("n", "No, I do not have the space to house it.")
            },
                q.Resolver);
        }
Exemple #2
0
        private void DoAction()
        {
            int seed = Game1.year * 1000 + seasons.IndexOf(Game1.currentSeason) * 100 + Game1.dayOfMonth;

            random = new Random(seed);
            List <Pet> list = GetAllPets();

            if ((Config.UseMaxAdoptionLimit && list.Count >= Config.MaxAdoptionLimit) || random.NextDouble() < Math.Max(0.1, Math.Min(0.9, list.Count * Config.RepeatedAdoptionPenality)) || list.FindIndex(a => a.age == seed) != -1)
            {
                Game1.drawObjectDialogue("Just an empty box.");
            }
            else
            {
                AdoptQuestion.Show();
            }
        }
Exemple #3
0
        private void DoAction()
        {
            int seed = Game1.year * 1000 + Array.IndexOf(ModEntry.Seasons, Game1.currentSeason) * 100 + Game1.dayOfMonth;

            if (Config.DisableDailyLimit)
            {
                ModEntry.Random = new Random();
            }
            else
            {
                ModEntry.Random = new Random(seed);
            }
            List <Pet> list = GetAllPets().ToList();

            if (ModEntry.Config.UseMaxAdoptionLimit && list.Count >= ModEntry.Config.MaxAdoptionLimit || ModEntry.Random.NextDouble() < Math.Max(0.1, Math.Min(0.9, list.Count * ModEntry.Config.RepeatedAdoptionPenality)) || (!Config.DisableDailyLimit && list.FindIndex(a => a.Age == seed) != -1))
            {
                Game1.drawObjectDialogue(this.Helper.Translation.Get("EmptyBox"));
            }
            else
            {
                AdoptQuestion.Show();
            }
        }
Exemple #4
0
        internal static void Show()
        {
            Random rnd = MoreAnimalsMod.random;

            int catLimit = MoreAnimalsMod.Indexes["cat"].Count;
            int dogLimit = MoreAnimalsMod.Indexes["dog"].Count;

            bool          cat = catLimit != 0 && (dogLimit == 0 || rnd.NextDouble() < 0.5);
            AdoptQuestion q   = new AdoptQuestion(cat, rnd.Next(1, cat ? catLimit : dogLimit));

            GraphicsEvents.OnPostRenderHudEvent  += q.Display;
            Game1.currentLocation.lastQuestionKey = "AdoptPetQuestion";
            Game1.currentLocation.createQuestionDialogue(
                "Oh dear, it looks like someone has abandoned a poor " + (cat ? "Cat" : "Dog") + " here! Perhaps you should pay Marnie " + MoreAnimalsMod.Config.AdoptionPrice + " gold to give it a checkup so you can adopt it?",
                Game1.player.money < MoreAnimalsMod.Config.AdoptionPrice ?
                new Response[] {
                new Response("n", "Unfortunately I do not have the required " + MoreAnimalsMod.Config.AdoptionPrice + " gold in order to do this.")
            } :
                new Response[] {
                new Response("y", "Yes, I really should adopt the poor animal!"),
                new Response("n", "No, I do not have the space to house it.")
            },
                q.Resolver, null);
        }
Exemple #5
0
        public static void Show()
        {
            Random     random = ModEntry.Random;
            string     type   = null;
            AnimalSkin skin   = null;

            if (ModEntry.Config.BalancedPetTypes)
            {
                double totalType = ModEntry.Pets.Count;
                Dictionary <string, double> types = ModEntry.Pets.Where(a => a.Value.Count > 0).ToDictionary(k => k.Key, v => totalType);
                foreach (Pet pet in ModEntry.GetAllPets().Where(p => ModEntry.PetTypesRev.ContainsKey(p.GetType()) && ModEntry.Pets[ModEntry.PetTypesRev[p.GetType()]].Count > 0))
                {
                    types[ModEntry.PetTypesRev[pet.GetType()]] *= 0.5;
                }
                types = types.ToDictionary(k => k.Key, v => v.Value / totalType);
                double   typeMax    = types.Values.OrderByDescending(a => a).First();
                double   typeChance = random.NextDouble() * typeMax;
                string[] validTypes = types.Where(a => a.Value >= typeChance).Select(a => a.Key).ToArray();
                if (validTypes.Length > 0)
                {
                    type = validTypes[random.Next(validTypes.Length)];
                }
            }
            if (string.IsNullOrEmpty(type))
            {
                string[] arr = ModEntry.Pets.Where(a => a.Value.Count > 0).Select(a => a.Key).ToArray();
                type = arr[random.Next(arr.Length)];
            }
            if (ModEntry.Config.BalancedPetSkins)
            {
                double totalSkin = ModEntry.Pets[type].Count;
                Dictionary <int, double> skins = ModEntry.Pets[type].ToDictionary(k => k.ID, v => totalSkin);
                foreach (Pet pet in ModEntry.GetAllPets().Where(pet => ModEntry.PetTypesRev.ContainsKey(pet.GetType()) && ModEntry.PetTypesRev[pet.GetType()].Equals(type) && skins.ContainsKey(pet.Manners)))
                {
                    skins[pet.Manners] *= 0.5;
                }
                skins = skins.ToDictionary(k => k.Key, v => v.Value / totalSkin);
                double skinMax = skins.Values.OrderByDescending(a => a).First();
                int[]  validSkins;
                if (ModEntry.Config.ForceUniqueSkins)
                {
                    validSkins = skins.Where(a => a.Value == skinMax).Select(a => a.Key).ToArray();
                }
                else
                {
                    double skinChance = Math.Min(random.NextDouble(), skinMax);
                    validSkins = skins.Where(a => a.Value >= skinChance).Select(a => a.Key).ToArray();
                }
                int id = 0;
                if (validSkins.Length > 0)
                {
                    id = validSkins[random.Next(validSkins.Length)];
                }
                skin = ModEntry.Pets[type].FirstOrDefault(a => a.ID == id);
            }
            if (skin == null)
            {
                skin = ModEntry.Pets[type][random.Next(ModEntry.Pets[type].Count)];
            }
            AdoptQuestion q = new AdoptQuestion(skin);

            ModEntry.SHelper.Events.Display.RenderedHud += q.Display;
            Game1.currentLocation.lastQuestionKey        = "AdoptPetQuestion";
            Game1.currentLocation.createQuestionDialogue(
                ModEntry.SHelper.Translation.Get("AdoptMessage", new { petType = type, adoptionPrice = ModEntry.Config.AdoptionPrice }),
                Game1.player.Money < ModEntry.Config.AdoptionPrice
                    ? new[]
            {
                new Response("n", ModEntry.SHelper.Translation.Get("AdoptNoGold", new { adoptionPrice = ModEntry.Config.AdoptionPrice }))
            }
                    : new[]
            {
                new Response("y", ModEntry.SHelper.Translation.Get("AdoptYes")),
                new Response("n", ModEntry.SHelper.Translation.Get("AdoptNo"))
            },
                q.Resolver);
        }
Exemple #6
0
        public static void Show()
        {
            Random random = ModEntry.Random;
            string type   = "";
            int    id     = 0;

            if (ModEntry.Config.BalancedPetTypes)
            {
                Dictionary <string, double> types = ModEntry.Pets.Keys.ToDictionary(k => k, v => 1.0);
                foreach (Pet pet in ModEntry.GetAllPets())
                {
                    string petType = ModEntry.Sanitize(pet.GetType().Name);
                    types[petType] *= 0.5;
                }
                double typeChance = random.NextDouble();
                foreach (KeyValuePair <string, double> pair in types.OrderBy(a => a.Value))
                {
                    if (pair.Value >= typeChance)
                    {
                        type = pair.Key;
                        break;
                    }
                }
            }
            else
            {
                type = ModEntry.Pets.Keys.ToArray()[random.Next(ModEntry.Pets.Count)];
            }
            if (ModEntry.Config.BalancedPetSkins)
            {
                Dictionary <int, double> skins = ModEntry.Pets[type].ToDictionary(k => k.ID, v => 1.0);
                foreach (Pet pet in ModEntry.GetAllPets().Where(pet => ModEntry.Sanitize(pet.GetType().Name) == type))
                {
                    skins[pet.Manners] *= 0.5;
                }
                double skinChance = random.NextDouble();
                foreach (KeyValuePair <int, double> pair in skins.OrderBy(a => a.Value))
                {
                    if (pair.Value >= skinChance)
                    {
                        id = pair.Key;
                        break;
                    }
                }
            }
            else
            {
                id = ModEntry.Pets[type][random.Next(ModEntry.Pets[type].Count)].ID;
            }
            AdoptQuestion q = new AdoptQuestion(type, id);

            ModEntry.SHelper.Events.Display.RenderedHud += q.Display;
            Game1.currentLocation.lastQuestionKey        = "AdoptPetQuestion";
            Game1.currentLocation.createQuestionDialogue(
                ModEntry.SHelper.Translation.Get("AdoptMessage", new { petType = type, adoptionPrice = ModEntry.Config.AdoptionPrice }),
                Game1.player.money < ModEntry.Config.AdoptionPrice
                    ? new[]
            {
                new Response("n", ModEntry.SHelper.Translation.Get("AdoptNoGold", new { adoptionPrice = ModEntry.Config.AdoptionPrice }))
            }
                    : new[]
            {
                new Response("y", ModEntry.SHelper.Translation.Get("AdoptYes")),
                new Response("n", ModEntry.SHelper.Translation.Get("AdoptNo"))
            },
                q.Resolver);
        }