private void OnDayStarting(object sender, DayStartedEventArgs e) { // Check if the player should get the Joja Membership discount via config file JojaSite.SetMembershipStatus(this.config.giveJojaMemberDiscount); // Check if player should get the Joja Prime free shipping via config JojaSite.SetPrimeShippingStatus(this.config.giveJojaPrimeShipping); // Modify JojaStock to include all year seed stock (if past year 1) & other items JojaResources.SetJojaOnlineStock(this.config.itemNameToPriceOverrides, this.config.areAllSeedsAvailableBeforeYearOne, this.config.doCopyPiereeSeedStock); JojaSite.PickRandomItemForDiscount(this.config.minSalePercentage, this.config.maxSalePercentage); this.Monitor.Log($"Picked a random item for discount at JojaOnline store.", LogLevel.Debug); }
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); }