summaryrefslogtreecommitdiff
path: root/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-08 12:54:06 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-08 12:54:06 -0400
commit1edd98aef027faa768f56cf0b3591e64e20ba096 (patch)
treeaec210e2b44c9654f29572dd084206a4598896e1 /src/TrainerMod/Framework/Commands/World/SetYearCommand.cs
parent36930ffd7d363d6afd7f8cac4918c7d1c1c3e339 (diff)
parent8743c4115aa142113d791f2d2cd9ba811dcada2c (diff)
downloadSMAPI-1edd98aef027faa768f56cf0b3591e64e20ba096.tar.gz
SMAPI-1edd98aef027faa768f56cf0b3591e64e20ba096.tar.bz2
SMAPI-1edd98aef027faa768f56cf0b3591e64e20ba096.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/TrainerMod/Framework/Commands/World/SetYearCommand.cs')
-rw-r--r--src/TrainerMod/Framework/Commands/World/SetYearCommand.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs b/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs
new file mode 100644
index 00000000..760fc170
--- /dev/null
+++ b/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs
@@ -0,0 +1,39 @@
+using System.Linq;
+using StardewModdingAPI;
+using StardewValley;
+
+namespace TrainerMod.Framework.Commands.World
+{
+ /// <summary>A command which sets the current year.</summary>
+ internal class SetYearCommand : TrainerCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public SetYearCommand()
+ : base("world_setyear", "Sets the year to the specified value.\n\nUsage: world_setyear <year>\n- year: the target year (a number starting from 1).") { }
+
+ /// <summary>Handle the command.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="command">The command name.</param>
+ /// <param name="args">The command arguments.</param>
+ 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;
+ monitor.Log($"OK, the year is now {Game1.year}.", LogLevel.Info);
+ }
+ }
+}