diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-07-02 02:45:02 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-07-02 02:45:02 -0400 |
commit | 2ca49fba62f59135c2ed3ec7958cb78073ff486b (patch) | |
tree | 5b4e5251606622f615b105b683a2722f4e6b046c /src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs | |
parent | f9482906ae7ce4dfd41bb4236e094be5d4fa7689 (diff) | |
download | SMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.tar.gz SMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.tar.bz2 SMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.zip |
encapsulate TrainerMod's argument parsing (#302)
Diffstat (limited to 'src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs')
-rw-r--r-- | src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs b/src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs index 73ba252a..4b9d87dc 100644 --- a/src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs +++ b/src/TrainerMod/Framework/Commands/Player/SetMaxHealthCommand.cs @@ -18,7 +18,7 @@ namespace TrainerMod.Framework.Commands.Player /// <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, string[] args) + public override void Handle(IMonitor monitor, string command, ArgumentParser args) { // validate if (!args.Any()) @@ -28,13 +28,11 @@ namespace TrainerMod.Framework.Commands.Player } // handle - if (int.TryParse(args[0], out int maxHealth)) + if (args.TryGetInt(0, "amount", out int amount, min: 1)) { - Game1.player.maxHealth = maxHealth; + Game1.player.maxHealth = amount; monitor.Log($"OK, you now have {Game1.player.maxHealth} max health.", LogLevel.Info); } - else - this.LogArgumentNotInt(monitor, command); } } } |