/// <summary>Determines whether a bush should regrow today.</summary>
        /// <param name="dateDestroyed">The <see cref="SDate"/> on which the bush was destroyed.</param>
        /// <returns>True if the bush should regrow; otherwise false.</returns>
        private bool BushShouldRegrowToday(SDate dateDestroyed)
        {
            if (dateDestroyed == null || Config.regrowNumber == null || Config.regrowUnit == null) //if any required information is null
            {
                return false; //this bush should NOT regrow
            }
            else
            {
                SDate regrowDate = null; //the date when this bush should regrow

                switch (Config.regrowUnit.Value)
                {
                    case RegrowUnit.Days:
                        regrowDate = dateDestroyed.AddDays(Config.regrowNumber.Value); //regrow after (regrowNumber) seasons
                        break;
                    case RegrowUnit.Seasons:
                        regrowDate = dateDestroyed.AddDays(28 * Config.regrowNumber.Value); //get a date after (regrowNumber) seasons
                        regrowDate = new SDate(1, regrowDate.Season, regrowDate.Year); //regrow on the first day of that season
                        break;
                    case RegrowUnit.Years:
                        regrowDate = new SDate(1, "spring", dateDestroyed.Year + Config.regrowNumber.Value); //regrow after (regrowNumber) years on the first day of spring
                        break;
                    default:
                        return false; //this bush should NOT regrow
                }

                if (SDate.Now() >= regrowDate) //if the regrow date is today or has already passed
                    return true; //this bush should regrow
                else
                    return false; //this bush should NOT regrow
            }
        }
Beispiel #2
0
        /// <summary>Get the next date when the bush will produce forage.</summary>
        /// <param name="bush">The bush to check.</param>
        /// <remarks>Derived from <see cref="Bush.inBloom"/>.</remarks>
        private SDate GetNextHarvestDate(Bush bush)
        {
            SDate today = SDate.Now();

            // currently has produce
            if (bush.tileSheetOffset.Value == 1)
            {
                return(today);
            }

            // wild bushes produce salmonberries in spring 15-18, and blackberries in fall 8-11
            SDate springStart = new SDate(15, "spring");
            SDate springEnd   = new SDate(18, "spring");
            SDate fallStart   = new SDate(8, "fall");
            SDate fallEnd     = new SDate(11, "fall");

            if (today < springStart)
            {
                return(springStart);
            }
            if (today > springEnd && today < fallStart)
            {
                return(fallStart);
            }
            if (today > fallEnd)
            {
                return(new SDate(springStart.Day, springStart.Season, springStart.Year + 1));
            }
            return(today.AddDays(1));
        }
Beispiel #3
0
        /// <summary>Get the next date when the bush will produce forage.</summary>
        /// <param name="bush">The bush to check.</param>
        /// <remarks>Derived from <see cref="Bush.inBloom"/>.</remarks>
        private SDate GetNextHarvestDate(Bush bush)
        {
            SDate today = SDate.Now();

            // currently has produce
            if (bush.tileSheetOffset.Value == 1)
            {
                return(today);
            }

            // tea bushes take 20 days to grow, then produce leaves on day 22+ of each season (except winter if not in the greenhouse).
            if (this.IsTeaBush(bush))
            {
                SDate fromDate = this.GetDateFullyGrown(bush);
                if (fromDate < SDate.Now())
                {
                    fromDate = SDate.Now();
                }

                SDate nextHarvest;
                if (fromDate.Season == "winter" && !bush.greenhouseBush.Value)
                {
                    nextHarvest = new SDate(22, "spring", fromDate.Year + 1);
                }
                else if (fromDate.Day < 22)
                {
                    nextHarvest = new SDate(22, fromDate.Season);
                }
                else
                {
                    nextHarvest = fromDate.AddDays(1);
                }

                return(nextHarvest);
            }

            // wild bushes produce salmonberries in spring 15-18, and blackberries in fall 8-11
            SDate springStart = new SDate(15, "spring");
            SDate springEnd   = new SDate(18, "spring");
            SDate fallStart   = new SDate(8, "fall");
            SDate fallEnd     = new SDate(11, "fall");

            if (today < springStart)
            {
                return(springStart);
            }
            if (today > springEnd && today < fallStart)
            {
                return(fallStart);
            }
            if (today > fallEnd)
            {
                return(new SDate(springStart.Day, springStart.Season, springStart.Year + 1));
            }
            return(today.AddDays(1));
        }
Beispiel #4
0
        /// <summary>Get the date when the bush will be fully grown.</summary>
        /// <param name="bush">The bush to check.</param>
        private SDate GetDateFullyGrown(Bush bush)
        {
            SDate date = this.GetDatePlanted(bush);

            if (this.IsTeaBush(bush))
            {
                date = date.AddDays(Bush.daysToMatureGreenTeaBush);
            }
            return(date);
        }
Beispiel #5
0
        /// <summary>Get the date when the bush was planted.</summary>
        /// <param name="bush">The bush to check.</param>
        private SDate GetDatePlanted(Bush bush)
        {
            SDate date = new SDate(1, "spring", 1);

            if (this.IsTeaBush(bush) && bush.datePlanted.Value > 0) // Caroline's sun room bush has datePlanted = -999
            {
                date = date.AddDays(bush.datePlanted.Value);
            }
            return(date);
        }
Beispiel #6
0
        /// <summary>Get the date when the bush was planted.</summary>
        /// <param name="bush">The bush to check.</param>
        private SDate GetDatePlanted(Bush bush)
        {
            SDate date = new SDate(1, "spring", 1);

            if (this.IsTeaBush(bush))
            {
                date = date.AddDays(bush.datePlanted.Value);
            }
            return(date);
        }
Beispiel #7
0
        /// <summary>Get the next date when the bush will produce forage.</summary>
        /// <param name="bush">The bush to check.</param>
        /// <remarks>Derived from <see cref="Bush.inBloom"/>.</remarks>
        private SDate GetNextHarvestDate(Bush bush)
        {
            SDate today    = SDate.Now();
            var   tomorrow = today.AddDays(1);

            // currently has produce
            if (bush.tileSheetOffset.Value == 1)
            {
                return(today);
            }

            // tea bushes take 20 days to grow, then produce leaves on day 22+ of each season (except winter if not in the greenhouse)
            if (this.IsTeaBush(bush))
            {
                SDate minDate = this.GetDateFullyGrown(bush);
                if (minDate < tomorrow)
                {
                    minDate = tomorrow;
                }

                if (minDate.Season == "winter" && !bush.greenhouseBush.Value && bush.currentLocation.locationContext != GameLocation.LocationContext.Island)
                {
                    return(new SDate(22, "spring", minDate.Year + 1));
                }
                if (minDate.Day < 22)
                {
                    return(new SDate(22, minDate.Season));
                }
                return(minDate);
            }

            // wild bushes produce salmonberries in spring 15-18, and blackberries in fall 8-11
            SDate springStart = new SDate(15, "spring");
            SDate springEnd   = new SDate(18, "spring");
            SDate fallStart   = new SDate(8, "fall");
            SDate fallEnd     = new SDate(11, "fall");

            if (tomorrow < springStart)
            {
                return(springStart);
            }
            if (tomorrow > springEnd && tomorrow < fallStart)
            {
                return(fallStart);
            }
            if (tomorrow > fallEnd)
            {
                return(new SDate(springStart.Day, springStart.Season, springStart.Year + 1));
            }
            return(tomorrow);
        }
Beispiel #8
0
        public static string GetChildNPCBirthday(int childNumber)
        {
            if (!Context.IsWorldReady)
            {
                return(null);
            }

            if (children != null && children.Count >= childNumber && children[childNumber - 1].daysOld >= ageForCP)
            {
                SDate todaySDate    = new SDate(Game1.dayOfMonth, Game1.currentSeason, Game1.year);
                SDate birthdaySDate = new SDate(1, "spring");
                try
                {
                    birthdaySDate = todaySDate.AddDays(-children[childNumber - 1].daysOld);
                }
                catch (ArithmeticException) { }

                return(birthdaySDate.Season + " " + birthdaySDate.Day);
            }
            return(null);
        }
        private static HashSet <Tuple <string, string> > NPCBirthdaysInNextNDays(int n)
        {
            HashSet <Tuple <string, string> > birthdayNPCs = new HashSet <Tuple <string, string> >();
            SDate         startDate    = SDate.Now().AddDays(1);
            SDate         endDate      = startDate.AddDays(n);
            SDate         todaysDate   = SDate.Now();
            List <string> validSeasons = new List <string> {
                "spring", "summer", "fall", "winter"
            };

            List <SDate> datesToCheck = new List <SDate>();


            foreach (NPC k in Utility.getAllCharacters())
            {
                //Log.Debug($"checking {k?.Name}, {k?.Birthday_Season}");
                if (k.isVillager() && k.Birthday_Season != null && validSeasons.Contains(k.Birthday_Season.ToLower()) && (Game1.player.friendshipData.ContainsKey(k.Name)))
                {
                    SDate birthday = new SDate(k.Birthday_Day, k.Birthday_Season.ToLower());
                    if (birthday < todaysDate)
                    {
                        //if birthday in the past, add a year
                        birthday = birthday.AddDays(112);
                    }
                    if (startDate <= birthday && birthday <= endDate)
                    {
                        birthdayNPCs.Add(new Tuple <string, string>(k.Name, $"{birthday.Day}-{birthday.Season}-{birthday.Year}"));
                    }
                }
            }
            Log.Debug("Birthdays: ");
            foreach (var entry in birthdayNPCs)
            {
                Log.Debug($"{entry.Item1} {entry.Item2}");
            }

            return(birthdayNPCs);
        }
        public void PlaceAssets()
        {
            GameLocation town = Game1.getLocationFromName("Town");

            if (town.map.GetTileSheet("z-candidate-box") == null &&
                SDate.Now() >= initialEntryDate && SDate.Now() <= finalEntryDate)
            {
                Location candidateBoxPosition = new Location((int)boxPosition.X, (int)boxPosition.Y);
                Layer    buildingLayer        = town.map.GetLayer("Buildings");

                town.map.AddTileSheet(candidateBoxTile);
                town.map.LoadTileSheets(Game1.mapDisplayDevice);

                buildingLayer.Tiles[candidateBoxPosition] = new
                                                            StaticTile(buildingLayer, candidateBoxTile, BlendMode.Alpha, 0);
            }

            if (SDate.Now() == finalEntryDate.AddDays(1) &&
                town.map.GetTileSheet("z-candidate-box") != null)
            {
                town.map.RemoveTileSheetDependencies(candidateBoxTile);
                town.map.RemoveTileSheet(candidateBoxTile);
            }
        }