// Lists the current and next movie and crane game status as of the // given date. public static Prediction PredictForDate(SDate date) { Utilities.CheckWorldReady(); if (!IsAvailable) { throw new UnavailableException("movies"); } Prediction prediction = new () { effectiveDate = date, currentMovie = MovieTheater.GetMovieForDate(date.ToWorldDate()), firstDateOfNextMovie = Utilities.GetNextSeasonStart(date), }; prediction.nextMovie = MovieTheater.GetMovieForDate (prediction.firstDateOfNextMovie.ToWorldDate()); // Logic from StardewValley.Locations.MovieTheater.addRandomNPCs() // as implemented in Stardew Predictor by MouseyPounds. if (Game1.getLocationFromName("MovieTheater") is MovieTheater theater) { Random rng = new ((int)Game1.uniqueIDForThisGame + date.DaysSinceStart - 1); prediction.craneGameAvailable = !(rng.NextDouble() < 0.25) && theater.dayFirstEntered.Value != -1 && theater.dayFirstEntered.Value != date.DaysSinceStart - 1; } return(prediction); }
// Lists the next several night events to occur on or after the given // date, up to the given limit, optionally of a given type. public static List <Prediction> ListNextEventsFromDate (SDate fromDate, uint limit, Event?onlyType = null) { Utilities.CheckWorldReady(); // Logic from StardewValley.Utility.<>c.<pickFarmEvent>b__146_0() // as implemented in Stardew Predictor by MouseyPounds. List <Prediction> predictions = new List <Prediction> (); for (int days = fromDate.DaysSinceStart; predictions.Count < limit && days < fromDate.DaysSinceStart + Utilities.MaxHorizon; ++days) { SDate tonight = SDate.FromDaysSinceStart(days); SDate tomorrow = SDate.FromDaysSinceStart(days + 1); // No event if there is a wedding tomorrow. foreach (Farmer farmer in Game1.getAllFarmers()) { Friendship spouse = farmer.GetSpouseFriendship(); if (spouse != null && spouse.WeddingDate == tomorrow.ToWorldDate()) { continue; } } Event @event = Event.None; Random rng = new Random(((int)Game1.uniqueIDForThisGame / 2) + days + 1); if (days == 29) { @event = Event.Earthquake; } // Ignoring the possibility of bundle completion here. else if (rng.NextDouble() < 0.01 && tomorrow.Season != "winter") { @event = Event.Fairy; } else if (rng.NextDouble() < 0.01) { @event = Event.Witch; } else if (rng.NextDouble() < 0.01) { @event = Event.Meteorite; } else if (rng.NextDouble() < 0.01 && tomorrow.Year > 1) { @event = Event.StrangeCapsule; } else if (rng.NextDouble() < 0.01) { @event = Event.StoneOwl; } if (@event == Event.None || (onlyType != null && @event != onlyType)) { continue; } predictions.Add(new Prediction { date = tonight, @event = @event }); } return(predictions); }
// Lists the next several night events to occur on or after the given // date, up to the given limit, optionally of a given type. public static List <Prediction> ListNextEventsFromDate(SDate fromDate, uint limit, Event?onlyType = null) { Utilities.CheckWorldReady(); if (!IsAvailable) { throw new UnavailableException("night events"); } // Logic from StardewValley.Utility.pickFarmEvent // as implemented in Stardew Predictor by MouseyPounds. List <Prediction> predictions = new (); for (int days = fromDate.DaysSinceStart; predictions.Count < limit && days < fromDate.DaysSinceStart + Utilities.MaxHorizon; ++days) { SDate tonight = SDate.FromDaysSinceStart(days); SDate tomorrow = SDate.FromDaysSinceStart(days + 1); // No event if there is a wedding tomorrow. foreach (Farmer farmer in Game1.getAllFarmers()) { Friendship spouse = farmer.GetSpouseFriendship(); if (spouse != null && spouse.WeddingDate == tomorrow.ToWorldDate()) { continue; } } Event @event = Event.None; Random rng = new (((int)Game1.uniqueIDForThisGame / 2) + days + 1); if (days == 29) { @event = Event.Earthquake; } // Ignoring the possibility of a WorldChangeEvent here. else if (rng.NextDouble() < 0.01 && tomorrow.Season != "winter") { @event = Event.Fairy; } else if (rng.NextDouble() < 0.01) { @event = Event.Witch; } else if (rng.NextDouble() < 0.01) { @event = Event.Meteorite; } else if (rng.NextDouble() < 0.005) { @event = Event.StoneOwl; } else if (rng.NextDouble() < 0.008 && tomorrow.Year > 1 && !Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("Got_Capsule")) { @event = Event.StrangeCapsule; } if (@event == Event.None || (onlyType != null && @event != onlyType)) { continue; } predictions.Add(new Prediction { date = tonight, @event = @event }); } return(predictions); }