diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
commit | 28e2695a19f7babf35d177367840a82b798beb55 (patch) | |
tree | 591b2badd77a7c9c0c36b8e09abdb6a323513307 /src/TrainerMod/ItemData | |
parent | aaf354761f18a18b0bcb81c9bd32819bb28deac9 (diff) | |
parent | a3376e2a6257c01c52a3c64c4f5f1f8de9a9c906 (diff) | |
download | SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.gz SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.bz2 SMAPI-28e2695a19f7babf35d177367840a82b798beb55.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/TrainerMod/ItemData')
-rw-r--r-- | src/TrainerMod/ItemData/ISearchItem.cs | 21 | ||||
-rw-r--r-- | src/TrainerMod/ItemData/ItemType.cs | 15 | ||||
-rw-r--r-- | src/TrainerMod/ItemData/SearchableObject.cs | 48 | ||||
-rw-r--r-- | src/TrainerMod/ItemData/SearchableRing.cs | 48 | ||||
-rw-r--r-- | src/TrainerMod/ItemData/SearchableWeapon.cs | 48 |
5 files changed, 180 insertions, 0 deletions
diff --git a/src/TrainerMod/ItemData/ISearchItem.cs b/src/TrainerMod/ItemData/ISearchItem.cs new file mode 100644 index 00000000..b2f7c2b8 --- /dev/null +++ b/src/TrainerMod/ItemData/ISearchItem.cs @@ -0,0 +1,21 @@ +namespace TrainerMod.ItemData +{ + /// <summary>An item that can be searched and added to the player's inventory through the console.</summary> + internal interface ISearchItem + { + /********* + ** Accessors + *********/ + /// <summary>Whether the item is valid.</summary> + bool IsValid { get; } + + /// <summary>The item ID.</summary> + int ID { get; } + + /// <summary>The item name.</summary> + string Name { get; } + + /// <summary>The item type.</summary> + ItemType Type { get; } + } +}
\ No newline at end of file diff --git a/src/TrainerMod/ItemData/ItemType.cs b/src/TrainerMod/ItemData/ItemType.cs new file mode 100644 index 00000000..2e049aa1 --- /dev/null +++ b/src/TrainerMod/ItemData/ItemType.cs @@ -0,0 +1,15 @@ +namespace TrainerMod.ItemData +{ + /// <summary>An item type that can be searched and added to the player through the console.</summary> + internal enum ItemType + { + /// <summary>Any object in <see cref="StardewValley.Game1.objectInformation"/> (except rings).</summary> + Object, + + /// <summary>A ring in <see cref="StardewValley.Game1.objectInformation"/>.</summary> + Ring, + + /// <summary>A weapon from <c>Data\weapons</c>.</summary> + Weapon + } +} diff --git a/src/TrainerMod/ItemData/SearchableObject.cs b/src/TrainerMod/ItemData/SearchableObject.cs new file mode 100644 index 00000000..30362f54 --- /dev/null +++ b/src/TrainerMod/ItemData/SearchableObject.cs @@ -0,0 +1,48 @@ +using StardewValley; + +namespace TrainerMod.ItemData +{ + /// <summary>An object that can be searched and added to the player's inventory through the console.</summary> + internal class SearchableObject : ISearchItem + { + /********* + ** Properties + *********/ + /// <summary>The underlying item.</summary> + private readonly Item Item; + + + /********* + ** Accessors + *********/ + /// <summary>Whether the item is valid.</summary> + public bool IsValid => this.Item != null && this.Item.Name != "Broken Item"; + + /// <summary>The item ID.</summary> + public int ID => this.Item.parentSheetIndex; + + /// <summary>The item name.</summary> + public string Name => this.Item.Name; + + /// <summary>The item type.</summary> + public ItemType Type => ItemType.Object; + + + /********* + ** Accessors + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="id">The item ID.</param> + public SearchableObject(int id) + { + try + { + this.Item = new Object(id, 1); + } + catch + { + // invalid + } + } + } +}
\ No newline at end of file diff --git a/src/TrainerMod/ItemData/SearchableRing.cs b/src/TrainerMod/ItemData/SearchableRing.cs new file mode 100644 index 00000000..7751e6aa --- /dev/null +++ b/src/TrainerMod/ItemData/SearchableRing.cs @@ -0,0 +1,48 @@ +using StardewValley.Objects; + +namespace TrainerMod.ItemData +{ + /// <summary>A ring that can be searched and added to the player's inventory through the console.</summary> + internal class SearchableRing : ISearchItem + { + /********* + ** Properties + *********/ + /// <summary>The underlying item.</summary> + private readonly Ring Ring; + + + /********* + ** Accessors + *********/ + /// <summary>Whether the item is valid.</summary> + public bool IsValid => this.Ring != null; + + /// <summary>The item ID.</summary> + public int ID => this.Ring.parentSheetIndex; + + /// <summary>The item name.</summary> + public string Name => this.Ring.Name; + + /// <summary>The item type.</summary> + public ItemType Type => ItemType.Ring; + + + /********* + ** Accessors + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="id">The ring ID.</param> + public SearchableRing(int id) + { + try + { + this.Ring = new Ring(id); + } + catch + { + // invalid + } + } + } +}
\ No newline at end of file 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 |