using System.Linq; using StardewModdingAPI.Utilities; using StardewValley; namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { /// A command which sets the current year. internal class SetYearCommand : ConsoleCommand { /********* ** Public methods *********/ /// Construct an instance. public SetYearCommand() : base("world_setyear", "Sets the year to the specified value.\n\nUsage: world_setyear \n- year: the target year (a number starting from 1).") { } /// Handle the command. /// Writes messages to the console and log file. /// The command name. /// The command arguments. public override void Handle(IMonitor monitor, string command, ArgumentParser args) { // no-argument mode if (!args.Any()) { monitor.Log($"The current year is {Game1.year}. Specify a value to change the year.", LogLevel.Info); return; } // parse arguments if (!args.TryGetInt(0, "year", out int year, min: 1)) return; // handle Game1.year = year; Game1.stats.DaysPlayed = (uint)SDate.Now().DaysSinceStart; monitor.Log($"OK, the year is now {Game1.year}.", LogLevel.Info); } } }