public DataLoader(IModHelper helper, IManifest manifest)
        {
            Helper    = helper;
            I18N      = helper.Translation;
            ModConfig = helper.ReadConfig <ModConfig>();

            Dictionary <object, int> CrystalariumData = DataLoader.Helper.Data.ReadJsonFile <Dictionary <object, int> >(CrystalariumDataJson) ?? DefaultCystalariumData;

            DataLoader.Helper.Data.WriteJsonFile(CrystalariumDataJson, CrystalariumData);

            Dictionary <int, string> objects = DataLoader.Helper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent);

            CrystalariumData.ToList().ForEach(d =>
            {
                int?id = GetId(d.Key, objects);
                if (id.HasValue && !CrystalariumDataId.ContainsKey(id.Value))
                {
                    CrystalariumDataId[id.Value] = d.Value;
                }
            });

            DataLoader.LoadContentPacksCommand();

            if (!ModConfig.DisableLetter)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "CustomCrystalarium"
                        , I18N.Get("CustomCrystalarium.Letter")
                        , (l) => !Game1.player.mailReceived.Contains(l.Id)
                        , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                {
                    Title = I18N.Get("CustomCrystalarium.Letter.Title")
                }
                );
            }
            CreateConfigMenu(manifest);
        }
Example #2
0
        public void LoadMails()
        {
            MailDao.SaveLetter(new Letter("meatloafRecipe", DataLoader.i18n.Get("Cooking.Meatloaf.Letter"), Cooking.Meatloaf.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Lewis") >= 9 * 250 && GetNpcFriendship("Marnie") >= 7 * 250));

            MailDao.SaveLetter(new Letter("baconCheeseburgerRecipe", DataLoader.i18n.Get("Cooking.BaconCheeseburger.Letter"), Cooking.BaconCheeseburger.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Gus") >= 9 * 250 && SDate.Now() > new SDate(16, "fall", 1)));

            MailDao.SaveLetter(new Letter("sweetAndSourPorkRecipe", DataLoader.i18n.Get("Cooking.SweetAndSourPork.Letter"), Cooking.SweetAndSourPork.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Jodi") >= 9 * 250 && GetNpcFriendship("Kent") >= 9 * 250));

            Func <Letter, bool> glazedHamCondition = (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) &&
                                                     GetNpcFriendship("Clint") >= 9 &&
                                                     Game1.stats.GeodesCracked > 80;

            MailDao.SaveLetter(new Letter("glazedHamRecipe", DataLoader.i18n.Get("Cooking.GlazedHam.Letter"), Cooking.GlazedHam.GetDescription(), glazedHamCondition));

            MailDao.SaveLetter(new Letter("cowboyDinnerkRecipe", DataLoader.i18n.Get("Cooking.CowboyDinner.Letter"), Cooking.CowboyDinner.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && (Game1.getLocationFromName("ArchaeologyHouse") as LibraryMuseum)?.museumPieces.Count() >= 70));

            MailDao.SaveLetter(new Letter("rabbitStewRecipe", DataLoader.i18n.Get("Cooking.RabbitStew.Letter"), Cooking.RabbitStew.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Linus") >= 9 * 250 && (Game1.stats.TimesUnconscious >= 1 || Game1.player.deepestMineLevel >= 100)));

            MailDao.SaveLetter(new Letter("monteCristoRecipe", DataLoader.i18n.Get("Cooking.MonteCristo.Letter"), Cooking.MonteCristo.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Leah") >= 8 * 250 && Game1.stats.ItemsForaged >= 1200));

            MailDao.SaveLetter(new Letter("steakWithMushroomsRecipe", DataLoader.i18n.Get("Cooking.SteakWithMushrooms.Letter"), Cooking.SteakWithMushrooms.GetDescription(), (letter) => !Game1.player.cookingRecipes.ContainsKey(letter.Recipe) && GetNpcFriendship("Alex") >= 8 * 250 && Game1.stats.MonstersKilled >= 1000));
        }
Example #3
0
        private void GameLoopOnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            //var WhatIsthis = Game1.objectInformation[20];
            //Monitor.Log(WhatIsthis, LogLevel.Info);
            //Every Second, Draw a random number and if it hits, the spouse has spent a bit of money.
            // var tempItem = getRandomItem();
            //Monitor.Log(tempItem.DisplayName + tempItem.salePrice(), LogLevel.Info);
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (!Game1.player.isMarried())
            {
                return;
            }



            int hit = 250; //When the spouse makes a purchase

            if (rand.Next(0, 500) == hit)
            {
                int randomInteger = rand.Next();
                var Spouse        = GetSpouse();
                var item          = getRandomItem();
                ShowNotification(Spouse.Name + " has spent " + item.salePrice() + " on " + item.DisplayName, 1);
                string letterId = "SpousePurchase" + item.DisplayName + randomInteger;
                MailDao.SaveLetter(
                    new Letter(
                        letterId,
                        "Your Joja Prime Package has Arrived!",
                        new List <Item> {
                    item
                },
                        (l => Game1.player.mailReceived.Contains(l.Id))
                        ));
            }
        }
Example #4
0
        public DataLoader(IModHelper helper)
        {
            Helper    = helper;
            I18N      = helper.Translation;
            ModConfig = helper.ReadConfig <ModConfig>();

            CaskData = DataLoader.Helper.Data.ReadJsonFile <Dictionary <object, float> >("data\\CaskData.json") ?? new Dictionary <object, float>()
            {
                { 342, 2.66f }, { 724, 2f }
            };
            DataLoader.Helper.Data.WriteJsonFile("data\\CaskData.json", CaskData);
            DataLoader.LoadContentPacksCommand();

            if (!ModConfig.DisableLetter)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "CustomCaskRecipe"
                        , I18N.Get("CustomCask.RecipeLetter")
                        , "Cask"
                        , (l) => !Game1.player.mailReceived.Contains(l.Id) && !Game1.player.mailReceived.Contains("CustomCask.Letter") && (Utility.getHomeOfFarmer(Game1.player).upgradeLevel >= 3 || ModConfig.EnableCasksAnywhere) && !Game1.player.craftingRecipes.ContainsKey("Cask")
                        , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "CustomCask"
                        , I18N.Get("CustomCask.Letter")
                        , (l) => !Game1.player.mailReceived.Contains(l.Id) && !Game1.player.mailReceived.Contains("CustomCask.RecipeLetter") && (Utility.getHomeOfFarmer(Game1.player).upgradeLevel >= 3 || ModConfig.EnableCasksAnywhere) && Game1.player.craftingRecipes.ContainsKey("Cask")
                        , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                );
            }
        }
Example #5
0
        /// <summary>
        /// Adds all letters for getting recipes to MailFrameworkMod.
        /// </summary>
        /// <param name="machines"></param>
        public static void SetupMail()
        {
            string idPrefix   = "JacquePott.MP.";
            string textFormat = "@:^^Congratulations on the progress of your farm. In the interest of helping you continue to bring prosperity to the valley, " +
                                "we would like to give you these blueprints to help with production.^^- The Ferngill Industrial Co-Operative";
            Dictionary <string, string> craftingData = ModEntry.Instance.Helper.Content.Load <Dictionary <string, string> >("Data\\CraftingRecipes", ContentSource.GameContent);

            foreach (MPMSettings setting in ModEntry.MPMSettings.Values)
            {
                if (!craftingData.ContainsKey(setting.UpgradeObject))
                {
                    ModEntry.Instance.Monitor.Log(string.Format("Could not find recipe for {0} when adding mail - skipping.", setting.UpgradeObject), LogLevel.Warn);
                    continue;
                }

                string id = idPrefix + setting.UpgradeObject.Replace(" ", "").Replace("(", "").Replace(")", "");

                Letter letter = new Letter(id, textFormat, setting.UpgradeObject, setting.CheckIfRecipeCanBeLearned);
                letter.GroupId = "MassProduction.Blueprints";

                MailDao.SaveLetter(letter);
            }
        }
Example #6
0
        public static bool CreateMailOrder(Farmer recipient, int daysToWait, List <Item> packagedItems)
        {
            try
            {
                // Check if packagedItems contains Joja Prime item
                int jojaPrimeID = JojaItems.GetJojaPrimeMembershipID();
                if (packagedItems.Any(i => i.ParentSheetIndex == jojaPrimeID))
                {
                    // Remove Joja Prime from the store
                    JojaResources.RemoveFromJojaOnlineStock(packagedItems.First(i => i.ParentSheetIndex == jojaPrimeID));

                    // Now send out mail with JojaPrimeShipping id
                    SendMail(recipient, "JojaPrimeShippingInfo", $"Valued Member,^^Thank you for purchasing Joja Prime. You are now able to use free next day delivery on Joja Online.^^We look forward to your continued business.^^- Joja Co.");

                    // Add JojaPrimeShipping mailID to the player's received mail so the flags recognize the membership has been purchased
                    // Otherwise the player will not have the membership until they read the mail the next day
                    Game1.MasterPlayer.mailReceived.Add("JojaPrimeShipping");

                    // Set the hasPrimeShipping to true manually, as it otherwise wouldn't update until the next day
                    JojaSite.SetPrimeShippingStatus(true);

                    // Remove Joja Prime from the list of shipped items, as we actually don't want to ship it
                    packagedItems = packagedItems.Where(i => i.ParentSheetIndex != jojaPrimeID).ToList();

                    // Skip rest of logic of there are no more items to ship due to removing Joja Prime
                    if (packagedItems.Count == 0)
                    {
                        return(true);
                    }
                }

                // Determine order number
                int orderNumber = 0;
                while (MailDao.FindLetter($"JojaMailOrder[#{orderNumber}]") != null || recipient.mailReceived.Contains($"JojaMailOrder[#{orderNumber}]") || IsOrderNumberScheduled(recipient, orderNumber))
                {
                    orderNumber++;
                }
                string mailOrderID = $"JojaMailOrder[#{orderNumber}]";

                // Generate mail message
                string message = $"Valued Customer,^^Thank you for using Joja Online. Your items for order #{orderNumber:0000} are packaged below.^^We look forward to your continued business.^^- Joja Co.";

                if (JojaSite.GetMembershipStatus() || JojaSite.GetPrimeShippingStatus())
                {
                    message = $"Valued Member,^^Thank you for using Joja Online. Your items for order #{orderNumber:0000} are packaged below.^^We look forward to your continued business.^^- Joja Co.";
                }

                // Determine the deliveryDate
                int deliveryDate = daysToWait + Game1.dayOfMonth > 28 ? daysToWait : daysToWait + Game1.dayOfMonth;

                // Need to save this mail data if it can't be delivered before shutdown
                recipient.mailForTomorrow.Add($"{mailOrderID}[{message}][{deliveryDate}][{String.Join(", ", packagedItems.Select(i => $"[{i.Name}, {i.category}, {i.parentSheetIndex}, {i.Stack}]"))}]");

                monitor.Log($"JojaMail order [#{orderNumber}] created with delivery date of [{deliveryDate}] {String.Join(", ", packagedItems.Select(i => $"[{i.Name}, {i.category}, {i.parentSheetIndex}, {i.Stack}]"))}!", LogLevel.Debug);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
        public DataLoader(IModHelper modHelper)
        {
            Helper    = modHelper;
            I18N      = modHelper.Translation;
            ModConfig = Helper.ReadConfig <ModConfig>();

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.DeliveryQuestsInfo"
                    , I18N.Get("Shipment.Quest.DeliveryQuestsLetter")
                    , (l) => !DataLoader.ModConfig.DisableQuestService && !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(2, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Quest.DeliveryQuestsLetter.Title")
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.ToolUpgradeInfo"
                    , I18N.Get("Shipment.Clint.UpgradeLetter")
                    , (l) => !DataLoader.ModConfig.DisableToolShipmentService && !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(6, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Clint.UpgradeLetter.Title")
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.GiftShipmentInfo"
                    , I18N.Get("Shipment.Wizard.GiftShipmentLetter")
                    , (l) => !DataLoader.ModConfig.DisableGiftService && !Game1.player.mailReceived.Contains(l.Id) && Game1.player.eventsSeen.Contains(112)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title   = I18N.Get("Shipment.Wizard.GiftShipmentLetter.Title"),
                WhichBG = 2
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.MarlonRecoveryReward"
                    , I18N.Get("Delivery.Marlon.RecoveryRewardLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.hasCompletedAllMonsterSlayerQuests.Value && !GetRecoveryConfig(Game1.player).DisableRecoveryConfigInGameChanges
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
                SaveRecoveryConfig(Game1.player, true, true, true);
            }
                    )
            {
                Title   = I18N.Get("Delivery.Marlon.RecoveryRewardLetter.Title"),
                GroupId = "MailServicesMod.GuildRecovery"
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServicesMod.MarlonRecoveryOffer"
                    , I18N.Get("Delivery.Marlon.RecoveryOfferLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && !Game1.player.mailReceived.Contains("MailServiceMod.MarlonRecoveryReward") && Game1.player.mailReceived.Contains("guildMember") && !DataLoader.GetRecoveryConfig(Game1.player).EnableRecoveryService&& !GetRecoveryConfig(Game1.player).DisableRecoveryConfigInGameChanges
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
                GuildRecoveryController.OpenOfferDialog();
            }
                    )
            {
                Title   = I18N.Get("Delivery.Marlon.RecoveryOfferLetter.Title"),
                GroupId = "MailServicesMod.GuildRecovery"
            }
                );

            Letter upgradeLetter = new Letter(
                ToolUpgradeMailId
                , I18N.Get("Delivery.Clint.UpgradeLetter")
                , (l) => !DataLoader.ModConfig.DisableToolDeliveryService && Game1.player.toolBeingUpgraded.Value != null && Game1.player.daysLeftForToolUpgrade.Value <= 0
                , (l) =>
            {
                if (!Game1.player.mailReceived.Contains(l.Id))
                {
                    Game1.player.mailReceived.Add(l.Id);
                }
                if (Game1.player.toolBeingUpgraded.Value != null)
                {
                    Tool tool = Game1.player.toolBeingUpgraded.Value;
                    Game1.player.toolBeingUpgraded.Value          = null;
                    Game1.player.hasReceivedToolUpgradeMessageYet = false;
                    Game1.player.holdUpItemThenMessage(tool);
                    if (tool is GenericTool)
                    {
                        tool.actionWhenClaimed();
                    }
                    if (Game1.player.team.useSeparateWallets.Value && tool.UpgradeLevel == 4)
                    {
                        Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                        multiplayer.globalChatInfoMessage("IridiumToolUpgrade", Game1.player.Name, tool.DisplayName);
                    }
                }
            }
                )
            {
                Title        = I18N.Get("Delivery.Clint.UpgradeLetter.Title"),
                DynamicItems = (l) => Game1.player.toolBeingUpgraded.Value != null ? new List <Item> {
                    Game1.player.toolBeingUpgraded.Value
                } : new List <Item>()
            };

            MailDao.SaveLetter(upgradeLetter);

            Letter recoveryLetter = new Letter(
                ItemRecoveryMailId
                , I18N.Get("Delivery.Marlon.RecoveryLetter")
                , (l) => GetRecoveryConfig(Game1.player).EnableRecoveryService&& GuildRecoveryController.GetItemsToRecover()?.Count > 0
                , (l) =>
            {
                if (!Game1.player.mailReceived.Contains(l.Id))
                {
                    Game1.player.mailReceived.Add(l.Id);
                }
                GuildRecoveryController.ItemsRecovered();
            }
                )
            {
                Title        = I18N.Get("Delivery.Marlon.RecoveryLetter.Title"),
                DynamicItems = (l) => GuildRecoveryController.GetItemsToRecover()
            };

            MailDao.SaveLetter(recoveryLetter);
        }
Example #8
0
        public void LoadMail()
        {
            string meatCleaverText;

            if (DataLoader.ModConfig.Softmode)
            {
                meatCleaverText = DataLoader.i18n.Get("Tool.MeatCleaver.Letter.Soft");
            }
            else
            {
                meatCleaverText = DataLoader.i18n.Get("Tool.MeatCleaver.Letter");
            }


            bool HasAnimal()
            {
                return(Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return farm.buildings
                        .Any((b => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0));
                    }
                    return false;
                }));
            }

            bool MeatCleaverCondition(Letter l)
            {
                return(HasAnimal() && !HasTool(typeof(MeatCleaver)));
            }

            List <string> validBuildingsForInsemination = new List <string>(new string[] { "Deluxe Barn", "Big Barn", "Deluxe Coop" });

            bool InseminationSyringeCondition(Letter l)
            {
                bool hasAnimalInValidBuildings = Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return(farm.buildings
                               .Any((b) => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0 && validBuildingsForInsemination.Contains(((AnimalHouse)b.indoors.Value)?.Name)));
                    }
                    return(false);
                });

                return(Context.IsMainPlayer && hasAnimalInValidBuildings && !HasTool(typeof(InseminationSyringe)));
            }

            bool FeedingBasketCondition(Letter l)
            {
                return(Context.IsMainPlayer && !Game1.player.mailReceived.Contains("feedingBasket") && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 2 && (Game1.player.hasPet() || HasAnimal()));
            }

            bool FeedingBasketRedeliveryCondition(Letter l)
            {
                return(Context.IsMainPlayer && Game1.player.mailReceived.Contains("feedingBasket") && !HasTool(typeof(FeedingBasket)) && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 6);
            }

            if (!DataLoader.ModConfig.DisableMeat)
            {
                Letter meatCleaverLetter = new Letter("meatCleaver", meatCleaverText, new List <Item> {
                    new MeatCleaver()
                }, MeatCleaverCondition);
                meatCleaverLetter.LetterTexture = _customLetterBG;
                meatCleaverLetter.TextColor     = 4;
                MailDao.SaveLetter(meatCleaverLetter);
            }

            if (!DataLoader.ModConfig.DisablePregnancy)
            {
                Letter inseminationSyringeLetter = new Letter("inseminationSyringe", DataLoader.i18n.Get("Tool.InseminationSyringe.Letter"), new List <Item> {
                    new InseminationSyringe()
                }, InseminationSyringeCondition);
                inseminationSyringeLetter.LetterTexture = _customLetterBG;
                inseminationSyringeLetter.TextColor     = 4;
                MailDao.SaveLetter(inseminationSyringeLetter);
            }


            //MailDao.SaveLetter(new Letter("participantRibbon", DataLoader.i18n.Get("Tool.ParticipantRibbon.Letter"), new List<Item> { new ParticipantRibbon() }, (l)=> true));


            if (!DataLoader.ModConfig.DisableTreats)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasket",
                        DataLoader.i18n.Get("Tool.FeedingBasket.Letter"),
                        new List <Item> {
                    new FeedingBasket()
                },
                        FeedingBasketCondition,
                        (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasketRedelivery",
                        DataLoader.i18n.Get("Tool.FeedingBasket.LetterRedelivery"),
                        new List <Item> {
                    new FeedingBasket()
                },
                        FeedingBasketRedeliveryCondition
                    )
                );
            }
        }
Example #9
0
        public static void Setup(DBLayer dbLayer, string smtpHost, int dbRetries, int dbSleepSeconds)
        {
            #region create daos
            IUserDao userDAO = new UserDao(dbLayer);
            IQueueDao queueDao = new QueueDao(dbLayer);
            ICommonDao commonDao = new CommonDao(dbLayer);

            ICampaignDao campaignDAO = new CampaignDao(dbLayer);
            IPageDao pageDAO = new PageDao(dbLayer);
            IPageElementDao pageElementDAO = new PageElementDao(dbLayer);
            IPredefinedQuestionDao predefinedQuestionDAO = new PredefinedQuestionDao(dbLayer);
            IQuestionnaireDao questionnaireDAO = new QuestionnaireDao(dbLayer);
            IResponseDao responseDAO = new ResponseDao(dbLayer);
            IReportingDao reportingDAO = new ReportingDao(dbLayer);
            IStatisticsDao statisticsDAO = new StatisticsDao(dbLayer);
            IOmnitureDao omnitureDAO = new OmnitureDao(dbLayer);
            IMasterReportDao masterDAO = new MasterReportDao(dbLayer);

            IEmailDao emailDAO = new EmailDao(dbLayer);
            IPrivacyDataSectionDao privacyDao = new PrivacyDataSectionDao(dbLayer);
            IPersonalDataSectionDao personalDao = new PersonalDataSectionDao(dbLayer);

            IMailDao mailDao = new MailDao(dbLayer);
            IMailer mailer = new Mailer(smtpHost);

            IHpFramesDao hpFramesDao = new HpFramesDao(dbLayer);

            #endregion

            IDictionary<Type, object> typeMap = new Dictionary<Type, object>();

            #region init map

            typeMap[typeof(IUserDao)] = userDAO;
            typeMap[typeof(IQueueDao)] = queueDao;
            typeMap[typeof(ICommonDao)] = commonDao;

            typeMap[typeof(ICampaignDao)] = campaignDAO;
            typeMap[typeof(IPageDao)] = pageDAO;
            typeMap[typeof(IPageElementDao)] = pageElementDAO;
            typeMap[typeof(IPredefinedQuestionDao)] = predefinedQuestionDAO;
            typeMap[typeof(IQuestionnaireDao)] = questionnaireDAO;
            typeMap[typeof(IResponseDao)] = responseDAO;
            typeMap[typeof(IReportingDao)] = reportingDAO;
            typeMap[typeof(IStatisticsDao)] = statisticsDAO;
            typeMap[typeof(IOmnitureDao)] = omnitureDAO;
            typeMap[typeof(IMasterReportDao)] = masterDAO;
            typeMap[typeof(IEmailDao)] = emailDAO;
            typeMap[typeof(IPrivacyDataSectionDao)] = privacyDao;
            typeMap[typeof(IPersonalDataSectionDao)] = personalDao;
            typeMap[typeof(IMailer)] = mailer;
            typeMap[typeof(IMailDao)] = mailDao;

            typeMap[typeof(IHpFramesDao)] = hpFramesDao;
            #endregion

            if (_unityProvider != null)
            {
                _unityProvider.Dispose();
            }
            _unityProvider = new UnityProvider(typeMap, dbRetries, dbSleepSeconds);
            
            Register(_unityProvider);

            SetupComponents();
            SetupValidators();

        }
Example #10
0
        public void LoadMail()
        {
            string meatCleaverText  = DataLoader.i18n.Get(DataLoader.ModConfig.Softmode ? "Tool.MeatCleaver.Letter.Soft" : "Tool.MeatCleaver.Letter");
            string meatCleaverTitle = DataLoader.i18n.Get(DataLoader.ModConfig.Softmode ? "Tool.MeatCleaver.Letter.Soft.Title" : "Tool.MeatCleaver.Letter.Title");

            bool HasAnimal()
            {
                return(Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return farm.buildings
                        .Any((b => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0));
                    }
                    return false;
                }));
            }

            bool MeatCleaverCondition(Letter l)
            {
                return(!DataLoader.ModConfig.DisableMeatToolLetter && HasAnimal() && (!ItemUtility.HasModdedItem(MeatCleaverOverrides.MeatCleaverKey) || !Game1.player.mailReceived.Contains(l.Id)));
            }

            List <string> validBuildingsForInsemination = new List <string>(new string[] { "Deluxe Barn", "Big Barn", "Deluxe Coop" });

            bool InseminationSyringeCondition(Letter l)
            {
                bool hasAnimalInValidBuildings = Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return(farm.buildings
                               .Any((b) => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0 && validBuildingsForInsemination.Contains(((AnimalHouse)b.indoors.Value)?.Name)));
                    }
                    return(false);
                });

                return(hasAnimalInValidBuildings && (!ItemUtility.HasModdedItem(InseminationSyringeOverrides.InseminationSyringeKey) || !Game1.player.mailReceived.Contains(l.Id)));
            }

            bool FeedingBasketCondition(Letter l)
            {
                return(!Game1.player.mailReceived.Contains(l.Id) && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 2 && (Game1.player.hasPet() || HasAnimal()));
            }

            bool FeedingBasketRedeliveryCondition(Letter l)
            {
                return(Game1.player.mailReceived.Contains("feedingBasket") && !ItemUtility.HasModdedItem(FeedingBasketOverrides.FeedingBasketKey) && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 6);
            }

            if (!DataLoader.ModConfig.DisableMeat)
            {
                Letter meatCleaverLetter = new Letter("meatCleaver", meatCleaverText, new List <Item> {
                    ToolsFactory.GetMeatCleaver()
                }, MeatCleaverCondition, (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                                  {
                                                      Game1.player.mailReceived.Add(l.Id);
                                                  }
                    })
                {
                    GroupId = "AHM.InterdimentionalFriend",
                    Title   = meatCleaverTitle
                };
                meatCleaverLetter.LetterTexture = _customLetterBG;
                meatCleaverLetter.TextColor     = 4;
                MailDao.SaveLetter(meatCleaverLetter);
            }

            if (!DataLoader.ModConfig.DisablePregnancy)
            {
                Letter inseminationSyringeLetter = new Letter("inseminationSyringe", DataLoader.i18n.Get("Tool.InseminationSyringe.Letter"), new List <Item> {
                    ToolsFactory.GetInseminationSyringe()
                }, InseminationSyringeCondition, (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                                          {
                                                              Game1.player.mailReceived.Add(l.Id);
                                                          }
                    })
                {
                    GroupId = "AHM.InterdimentionalFriend",
                    Title   = DataLoader.i18n.Get("Tool.InseminationSyringe.Letter.Title")
                };
                inseminationSyringeLetter.LetterTexture = _customLetterBG;
                inseminationSyringeLetter.TextColor     = 4;
                MailDao.SaveLetter(inseminationSyringeLetter);
            }

            if (!DataLoader.ModConfig.DisableAnimalContest)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "participantRibbon"
                        , DataLoader.i18n.Get("Tool.ParticipantRibbon.Letter")
                        , new List <Item> {
                    ToolsFactory.GetParticipantRibbon()
                }
                        , (l) => SDate.Now().AddDays(1).Equals(AnimalContestController.GetNextContestDate()) && AnimalContestController.GetContestCount() == 0 && !Game1.player.mailReceived.Contains(l.Id + AnimalContestController.GetNextContestDateKey())
                        , (l) =>
                {
                    Game1.player.mailReceived.Add(l.Id + AnimalContestController.GetNextContestDateKey());
                    if (!Game1.player.mailReceived.Contains(l.Id))
                    {
                        Game1.player.mailReceived.Add(l.Id);
                    }
                })
                {
                    Title = DataLoader.i18n.Get("Tool.ParticipantRibbon.Letter.Title")
                }
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "participantRibbonRedelivery"
                        , DataLoader.i18n.Get("Tool.ParticipantRibbon.LetterRedelivery")
                        , new List <Item> {
                    ToolsFactory.GetParticipantRibbon()
                }
                        , (l) => SDate.Now().AddDays(1).Equals(AnimalContestController.GetNextContestDate()) && AnimalContestController.GetContestCount() > 0 && !Game1.player.mailReceived.Contains(l.Id + AnimalContestController.GetNextContestDateKey())
                        , (l) =>
                {
                    Game1.player.mailReceived.Add(l.Id + AnimalContestController.GetNextContestDateKey());
                    if (!Game1.player.mailReceived.Contains(l.Id))
                    {
                        Game1.player.mailReceived.Add(l.Id);
                    }
                })
                {
                    Title = DataLoader.i18n.Get("Tool.ParticipantRibbon.LetterRedelivery.Title")
                }
                );
            }

            if (!DataLoader.ModConfig.DisableTreats)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasket",
                        DataLoader.i18n.Get("Tool.FeedingBasket.Letter"),
                        new List <Item> {
                    ToolsFactory.GetFeedingBasket()
                },
                        FeedingBasketCondition,
                        (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                 {
                                     Game1.player.mailReceived.Add(l.Id);
                                 }
                        }
                    )
                {
                    Title = DataLoader.i18n.Get("Tool.FeedingBasket.Letter.Title")
                }
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasketRedelivery",
                        DataLoader.i18n.Get("Tool.FeedingBasket.LetterRedelivery"),
                        new List <Item> {
                    ToolsFactory.GetFeedingBasket()
                },
                        FeedingBasketRedeliveryCondition,
                        (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                 {
                                     Game1.player.mailReceived.Add(l.Id);
                                 }
                        }
                    )
                {
                    Title = DataLoader.i18n.Get("Tool.FeedingBasket.LetterRedelivery.Title")
                }
                );
            }
        }
Example #11
0
        public DataLoader(IModHelper modHelper)
        {
            Helper    = modHelper;
            I18N      = modHelper.Translation;
            ModConfig = Helper.ReadConfig <ModConfig>();

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.DeliveryQuestsInfo"
                    , I18N.Get("Shipment.Quest.DeliveryQuestsLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(2, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Quest.DeliveryQuestsLetter.Title")
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.ToolUpgradeInfo"
                    , I18N.Get("Shipment.Clint.UpgradeLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(6, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Clint.UpgradeLetter.Title")
            }
                );

            Letter upgradeLetter = new Letter(
                ToolUpgradeMailId
                , I18N.Get("Delivery.Clint.UpgradeLetter")
                , (l) => Game1.player.toolBeingUpgraded.Value != null && Game1.player.daysLeftForToolUpgrade.Value <= 0
                , (l) =>
            {
                if (!Game1.player.mailReceived.Contains(l.Id))
                {
                    Game1.player.mailReceived.Add(l.Id);
                }
                if (Game1.player.toolBeingUpgraded.Value != null)
                {
                    Tool tool = Game1.player.toolBeingUpgraded.Value;
                    Game1.player.toolBeingUpgraded.Value          = null;
                    Game1.player.hasReceivedToolUpgradeMessageYet = false;
                    Game1.player.holdUpItemThenMessage(tool);
                    if (tool is GenericTool)
                    {
                        tool.actionWhenClaimed();
                    }
                    if (Game1.player.team.useSeparateWallets.Value && tool.UpgradeLevel == 4)
                    {
                        Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                        multiplayer.globalChatInfoMessage("IridiumToolUpgrade", Game1.player.Name, tool.DisplayName);
                    }
                }
            }
                )
            {
                Title = I18N.Get("Delivery.Clint.UpgradeLetter.Title")
            };

            upgradeLetter.DynamicItems = (l) => Game1.player.toolBeingUpgraded.Value != null ? new List <Item> {
                Game1.player.toolBeingUpgraded.Value
            } : new List <Item>();
            MailDao.SaveLetter(upgradeLetter);
        }
        public DataLoader(IModHelper helper)
        {
            Helper    = helper;
            I18N      = helper.Translation;
            ModConfig = helper.ReadConfig <ModConfig>();

            CraftingData = DataLoader.Helper.Data.ReadJsonFile <CraftingData>("data\\CraftingRecipes.json") ?? new CraftingData();
            DataLoader.Helper.Data.WriteJsonFile("data\\CraftingRecipes.json", CraftingData);

            var editors = Helper.Content.AssetEditors;

            editors.Add(this);

            if (!ModConfig.DisableIridiumQualityFish)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "IridiumQualityFishWithWildBait"
                        , I18N.Get("IridiumQualityFishWithWildBait.Letter")
                        , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.craftingRecipes.ContainsKey("Wild Bait") && Game1.player.FishingLevel >= 4
                        , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                );
            }

            AddLetter(BaitTackle.EverlastingBait, (l) => Game1.player.FishingLevel >= 10 && GetNpcFriendship("Willy") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingBait.GetDescription()));
            AddLetter(BaitTackle.EverlastingWildBait, (l) => Game1.player.craftingRecipes.ContainsKey("Wild Bait") && Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingBait.GetDescription()) && Game1.player.craftingRecipes[BaitTackle.EverlastingBait.GetDescription()] > 0 && GetNpcFriendship("Linus") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingWildBait.GetDescription()));
            AddLetter(BaitTackle.EverlastingMagnet, (l) => Game1.player.FishingLevel >= 10 && GetNpcFriendship("Wizard") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingMagnet.GetDescription()), null, 2);
            MailDao.SaveLetter
            (
                new Letter
                (
                    "UnbreakableTackleIntroduction"
                    , I18N.Get("UnbreakableTackleIntroduction.Letter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.achievements.Contains(21) && Game1.player.FishingLevel >= 8 && GetNpcFriendship("Willy") >= 6 * 250 && GetNpcFriendship("Clint") >= 6 * 250
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                )
            );
            AddLetter
            (
                BaitTackle.UnbreakableSpinner
                , (l) => Game1.player.achievements.Contains(21) && Game1.player.FishingLevel >= 8 && GetNpcFriendship("Willy") >= 6 * 250 && GetNpcFriendship("Clint") >= 6 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableSpinner.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableSpinner)
            );
            AddLetter
            (
                BaitTackle.UnbreakableLeadBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableSpinner.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableLeadBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableLeadBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableTrapBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableLeadBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableTrapBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableTrapBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableCorkBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableTrapBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableCorkBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableCorkBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableTreasureHunter
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableCorkBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableTreasureHunter.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableTreasureHunter)
            );
            AddLetter
            (
                BaitTackle.UnbreakableBarbedHook
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableTreasureHunter.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableBarbedHook.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableBarbedHook)
            );
            AddLetter
            (
                BaitTackle.UnbreakableDressedSpinner
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableBarbedHook.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableDressedSpinner.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableDressedSpinner)
            );
            MailDao.SaveLetter
            (
                new Letter
                (
                    "UnbreakableTackleReward"
                    , I18N.Get("UnbreakableTackleReward.Letter")
                    , new List <Item> {
                new StardewValley.Object(74, 1)
            }
                    , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableDressedSpinner.GetQuestName()) && !Game1.player.mailReceived.Contains(l.Id)
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
            }
                )
            );
        }
 private void AddLetter(BaitTackle baitTackle, Func <Letter, bool> condition, Action <Letter> callback = null, int whichBG = 0)
 {
     MailDao.SaveLetter(new Letter(baitTackle.ToString() + "Recipe", I18N.Get(baitTackle.ToString() + ".Letter"), baitTackle.GetDescription(), condition, callback, whichBG));
 }