summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs27
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs66
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs38
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs32
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs45
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs39
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs38
7 files changed, 285 insertions, 0 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs
new file mode 100644
index 00000000..da117006
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs
@@ -0,0 +1,27 @@
+using StardewValley;
+using StardewValley.Locations;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which moves the player to the next mine level.</summary>
+ internal class DownMineLevelCommand : TrainerCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public DownMineLevelCommand()
+ : base("world_downminelevel", "Goes down one mine level.") { }
+
+ /// <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)
+ {
+ int level = (Game1.currentLocation as MineShaft)?.mineLevel ?? 0;
+ monitor.Log($"OK, warping you to mine level {level + 1}.", LogLevel.Info);
+ Game1.enterMine(false, level + 1, "");
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
new file mode 100644
index 00000000..2627b714
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
@@ -0,0 +1,66 @@
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which freezes the current time.</summary>
+ internal class FreezeTimeCommand : TrainerCommand
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The time of day at which to freeze time.</summary>
+ internal static int FrozenTime;
+
+ /// <summary>Whether to freeze time.</summary>
+ private bool FreezeTime;
+
+
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>Whether the command needs to perform logic when the game updates.</summary>
+ public override bool NeedsUpdate => this.FreezeTime;
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public FreezeTimeCommand()
+ : base("world_freezetime", "Freezes or resumes time.\n\nUsage: world_freezetime [value]\n- value: one of 0 (resume), 1 (freeze), or blank (toggle).") { }
+
+ /// <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)
+ {
+ if (args.Any())
+ {
+ // parse arguments
+ if (!args.TryGetInt(0, "value", out int value, min: 0, max: 1))
+ return;
+
+ // handle
+ this.FreezeTime = value == 1;
+ FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
+ monitor.Log($"OK, time is now {(this.FreezeTime ? "frozen" : "resumed")}.", LogLevel.Info);
+ }
+ else
+ {
+ this.FreezeTime = !this.FreezeTime;
+ FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
+ monitor.Log($"OK, time is now {(this.FreezeTime ? "frozen" : "resumed")}.", LogLevel.Info);
+ }
+ }
+
+ /// <summary>Perform any logic needed on update tick.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ public override void Update(IMonitor monitor)
+ {
+ if (this.FreezeTime)
+ Game1.timeOfDay = FreezeTimeCommand.FrozenTime;
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs
new file mode 100644
index 00000000..8d6bd759
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs
@@ -0,0 +1,38 @@
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which sets the current day.</summary>
+ internal class SetDayCommand : TrainerCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public SetDayCommand()
+ : base("world_setday", "Sets the day to the specified value.\n\nUsage: world_setday <value>.\n- value: the target day (a number from 1 to 28).") { }
+
+ /// <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 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);
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs
new file mode 100644
index 00000000..1024b7b6
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs
@@ -0,0 +1,32 @@
+using System;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which moves the player to the given mine level.</summary>
+ internal class SetMineLevelCommand : TrainerCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public SetMineLevelCommand()
+ : base("world_setminelevel", "Sets the mine level?\n\nUsage: world_setminelevel <value>\n- value: The target level (a number starting at 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)
+ {
+ // parse arguments
+ if (!args.TryGetInt(0, "mine level", out int level, min: 1))
+ return;
+
+ // handle
+ level = Math.Max(1, level);
+ monitor.Log($"OK, warping you to mine level {level}.", LogLevel.Info);
+ Game1.enterMine(true, level, "");
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs
new file mode 100644
index 00000000..897d052f
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs
@@ -0,0 +1,45 @@
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which sets the current season.</summary>
+ internal class SetSeasonCommand : TrainerCommand
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The valid season names.</summary>
+ private readonly string[] ValidSeasons = { "winter", "spring", "summer", "fall" };
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public SetSeasonCommand()
+ : base("world_setseason", "Sets the season to the specified value.\n\nUsage: world_setseason <season>\n- season: the target season (one of 'spring', 'summer', 'fall', 'winter').") { }
+
+ /// <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 season is {Game1.currentSeason}. Specify a value to change it.", LogLevel.Info);
+ return;
+ }
+
+ // parse arguments
+ if (!args.TryGet(0, "season", out string season, oneOf: this.ValidSeasons))
+ return;
+
+ // handle
+ Game1.currentSeason = season;
+ monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info);
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs
new file mode 100644
index 00000000..d6c71387
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs
@@ -0,0 +1,39 @@
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which sets the current time.</summary>
+ internal class SetTimeCommand : TrainerCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public SetTimeCommand()
+ : base("world_settime", "Sets the time to the specified value.\n\nUsage: world_settime <value>\n- value: the target time in military time (like 0600 for 6am and 1800 for 6pm).") { }
+
+ /// <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 time is {Game1.timeOfDay}. Specify a value to change it.", LogLevel.Info);
+ return;
+ }
+
+ // parse arguments
+ if (!args.TryGetInt(0, "time", out int time, min: 600, max: 2600))
+ return;
+
+ // handle
+ Game1.timeOfDay = time;
+ FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
+ monitor.Log($"OK, the time is now {Game1.timeOfDay.ToString().PadLeft(4, '0')}.", LogLevel.Info);
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs
new file mode 100644
index 00000000..66abd6dc
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs
@@ -0,0 +1,38 @@
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.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);
+ }
+ }
+}