using System.Linq; using StardewValley; namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { /// A command which sets the current day. internal class SetDayCommand : TrainerCommand { /********* ** Public methods *********/ /// Construct an instance. public SetDayCommand() : base("world_setday", "Sets the day to the specified value.\n\nUsage: world_setday .\n- value: the target day (a number from 1 to 28).") { } /// 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 date is {Game1.currentSeason} {Game1.dayOfMonth}. Specify a value to change the day.", LogLevel.Info); return; } // parse arguments if (!args.TryGetInt(0, "day", out int day, min: 1, max: 28)) return; // handle Game1.dayOfMonth = day; monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info); } } }