From 59dd604cf2905adf5fce7e9bb7b97886891aae81 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 27 Oct 2017 03:18:48 -0400 Subject: rename TrainerMod to Console Commands to clarify purpose --- .../Commands/World/DownMineLevelCommand.cs | 28 --------- .../Framework/Commands/World/FreezeTimeCommand.cs | 67 ---------------------- .../Framework/Commands/World/SetDayCommand.cs | 39 ------------- .../Commands/World/SetMineLevelCommand.cs | 33 ----------- .../Framework/Commands/World/SetSeasonCommand.cs | 46 --------------- .../Framework/Commands/World/SetTimeCommand.cs | 40 ------------- .../Framework/Commands/World/SetYearCommand.cs | 39 ------------- 7 files changed, 292 deletions(-) delete mode 100644 src/TrainerMod/Framework/Commands/World/DownMineLevelCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/FreezeTimeCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/SetDayCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/SetMineLevelCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/SetSeasonCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/World/SetYearCommand.cs (limited to 'src/TrainerMod/Framework/Commands/World') diff --git a/src/TrainerMod/Framework/Commands/World/DownMineLevelCommand.cs b/src/TrainerMod/Framework/Commands/World/DownMineLevelCommand.cs deleted file mode 100644 index 4e62cf77..00000000 --- a/src/TrainerMod/Framework/Commands/World/DownMineLevelCommand.cs +++ /dev/null @@ -1,28 +0,0 @@ -using StardewModdingAPI; -using StardewValley; -using StardewValley.Locations; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which moves the player to the next mine level. - internal class DownMineLevelCommand : TrainerCommand - { - /********* - ** Public methods - *********/ - /// Construct an instance. - public DownMineLevelCommand() - : base("world_downminelevel", "Goes down one mine level.") { } - - /// 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) - { - 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/TrainerMod/Framework/Commands/World/FreezeTimeCommand.cs b/src/TrainerMod/Framework/Commands/World/FreezeTimeCommand.cs deleted file mode 100644 index 13d08398..00000000 --- a/src/TrainerMod/Framework/Commands/World/FreezeTimeCommand.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which freezes the current time. - internal class FreezeTimeCommand : TrainerCommand - { - /********* - ** Properties - *********/ - /// The time of day at which to freeze time. - internal static int FrozenTime; - - /// Whether to freeze time. - private bool FreezeTime; - - - /********* - ** Accessors - *********/ - /// Whether the command needs to perform logic when the game updates. - public override bool NeedsUpdate => this.FreezeTime; - - - /********* - ** Public methods - *********/ - /// Construct an instance. - 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).") { } - - /// 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) - { - 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); - } - } - - /// Perform any logic needed on update tick. - /// Writes messages to the console and log file. - public override void Update(IMonitor monitor) - { - if (this.FreezeTime) - Game1.timeOfDay = FreezeTimeCommand.FrozenTime; - } - } -} diff --git a/src/TrainerMod/Framework/Commands/World/SetDayCommand.cs b/src/TrainerMod/Framework/Commands/World/SetDayCommand.cs deleted file mode 100644 index 54267384..00000000 --- a/src/TrainerMod/Framework/Commands/World/SetDayCommand.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.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); - } - } -} diff --git a/src/TrainerMod/Framework/Commands/World/SetMineLevelCommand.cs b/src/TrainerMod/Framework/Commands/World/SetMineLevelCommand.cs deleted file mode 100644 index 225ec091..00000000 --- a/src/TrainerMod/Framework/Commands/World/SetMineLevelCommand.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which moves the player to the given mine level. - internal class SetMineLevelCommand : TrainerCommand - { - /********* - ** Public methods - *********/ - /// Construct an instance. - public SetMineLevelCommand() - : base("world_setminelevel", "Sets the mine level?\n\nUsage: world_setminelevel \n- value: The target level (a number starting at 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) - { - // 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/TrainerMod/Framework/Commands/World/SetSeasonCommand.cs b/src/TrainerMod/Framework/Commands/World/SetSeasonCommand.cs deleted file mode 100644 index 96c3d920..00000000 --- a/src/TrainerMod/Framework/Commands/World/SetSeasonCommand.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which sets the current season. - internal class SetSeasonCommand : TrainerCommand - { - /********* - ** Properties - *********/ - /// The valid season names. - private readonly string[] ValidSeasons = { "winter", "spring", "summer", "fall" }; - - - /********* - ** Public methods - *********/ - /// Construct an instance. - public SetSeasonCommand() - : base("world_setseason", "Sets the season to the specified value.\n\nUsage: world_setseason \n- season: the target season (one of 'spring', 'summer', 'fall', 'winter').") { } - - /// 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 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/TrainerMod/Framework/Commands/World/SetTimeCommand.cs b/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs deleted file mode 100644 index c827ea5e..00000000 --- a/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which sets the current time. - internal class SetTimeCommand : TrainerCommand - { - /********* - ** Public methods - *********/ - /// Construct an instance. - public SetTimeCommand() - : base("world_settime", "Sets the time to the specified value.\n\nUsage: world_settime \n- value: the target time in military time (like 0600 for 6am and 1800 for 6pm).") { } - - /// 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 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/TrainerMod/Framework/Commands/World/SetYearCommand.cs b/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs deleted file mode 100644 index 760fc170..00000000 --- a/src/TrainerMod/Framework/Commands/World/SetYearCommand.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq; -using StardewModdingAPI; -using StardewValley; - -namespace TrainerMod.Framework.Commands.World -{ - /// A command which sets the current year. - internal class SetYearCommand : TrainerCommand - { - /********* - ** 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; - monitor.Log($"OK, the year is now {Game1.year}.", LogLevel.Info); - } - } -} -- cgit