summaryrefslogtreecommitdiff
path: root/src/TrainerMod/Framework/Commands/Player/AddFlooringCommand.cs
blob: 1bc96466a4c86d526a838f26561dac794a1d2956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using StardewModdingAPI;
using StardewValley;
using StardewValley.Objects;

namespace TrainerMod.Framework.Commands.Player
{
    /// <summary>A command which adds a floor item to the player inventory.</summary>
    internal class AddFlooringCommand : TrainerCommand
    {
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        public AddFlooringCommand()
            : base("player_addflooring", "Gives the player a flooring item.\n\nUsage: player_addflooring <flooring>\n- flooring: the flooring ID (ranges from 0 to 39).") { }

        /// <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)
        {
            // read arguments
            if (!args.TryGetInt(0, "floor ID", out int floorID, min: 0, max: 39))
                return;

            // handle
            Wallpaper wallpaper = new Wallpaper(floorID, isFloor: true);
            Game1.player.addItemByMenuIfNecessary(wallpaper);
            monitor.Log($"OK, added flooring {floorID} to your inventory.", LogLevel.Info);
        }
    }
}