diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-07 20:36:28 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-07 20:36:28 -0500 |
commit | b019dd4f69c9fefeba9f14c2049fb352127e448f (patch) | |
tree | ab848b0e044a10c2b2a3dd358768a5ddeb4e0132 /src/TrainerMod/ItemData/SearchableWeapon.cs | |
parent | f0433e5a41c01d73edcd20a6767b7979f636c0e6 (diff) | |
download | SMAPI-b019dd4f69c9fefeba9f14c2049fb352127e448f.tar.gz SMAPI-b019dd4f69c9fefeba9f14c2049fb352127e448f.tar.bz2 SMAPI-b019dd4f69c9fefeba9f14c2049fb352127e448f.zip |
replace out_items, out_melee, and out_rings commands with a searchable list_items command
Diffstat (limited to 'src/TrainerMod/ItemData/SearchableWeapon.cs')
-rw-r--r-- | src/TrainerMod/ItemData/SearchableWeapon.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/TrainerMod/ItemData/SearchableWeapon.cs b/src/TrainerMod/ItemData/SearchableWeapon.cs new file mode 100644 index 00000000..cc9ef459 --- /dev/null +++ b/src/TrainerMod/ItemData/SearchableWeapon.cs @@ -0,0 +1,48 @@ +using StardewValley.Tools; + +namespace TrainerMod.ItemData +{ + /// <summary>A weapon that can be searched and added to the player's inventory through the console.</summary> + internal class SearchableWeapon : ISearchItem + { + /********* + ** Properties + *********/ + /// <summary>The underlying item.</summary> + private readonly MeleeWeapon Weapon; + + + /********* + ** Accessors + *********/ + /// <summary>Whether the item is valid.</summary> + public bool IsValid => this.Weapon != null; + + /// <summary>The item ID.</summary> + public int ID => this.Weapon.initialParentTileIndex; + + /// <summary>The item name.</summary> + public string Name => this.Weapon.Name; + + /// <summary>The item type.</summary> + public ItemType Type => ItemType.Weapon; + + + /********* + ** Accessors + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="id">The weapon ID.</param> + public SearchableWeapon(int id) + { + try + { + this.Weapon = new MeleeWeapon(id); + } + catch + { + // invalid + } + } + } +}
\ No newline at end of file |