diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-12-28 11:33:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-28 11:33:31 -0500 |
commit | d438e49f76a83b995fcb9c3e95869b908d935e7f (patch) | |
tree | 498112ba928d88039debbbc1cbc124a97ba2ea11 | |
parent | 368b25b5411683192f4398616abed61441457799 (diff) | |
parent | 45979c57dd350fc5c08155fd0794cf3c3519a256 (diff) | |
download | SMAPI-d438e49f76a83b995fcb9c3e95869b908d935e7f.tar.gz SMAPI-d438e49f76a83b995fcb9c3e95869b908d935e7f.tar.bz2 SMAPI-d438e49f76a83b995fcb9c3e95869b908d935e7f.zip |
Merge pull request #889 from daleao/develop
Replace slingshot ID check with type field check
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 88ddfe6b..c4619577 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -104,12 +104,18 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework // weapons if (ShouldGet(ItemType.Weapon)) { - foreach (int id in this.TryLoad<int, string>("Data\\weapons").Keys) + Dictionary<int, string> weaponsData = this.TryLoad<int, string>("Data\\weapons"); + foreach (KeyValuePair<int, string> pair in weaponsData) { - yield return this.TryCreate(ItemType.Weapon, id, p => p.ID is >= 32 and <= 34 - ? new Slingshot(p.ID) - : new MeleeWeapon(p.ID) - ); + string rawFields = pair.Value; + yield return this.TryCreate(ItemType.Weapon, pair.Key, p => + { + string[] fields = rawFields.Split('/'); + bool isSlingshot = fields.Length > 8 && fields[8] == "4"; + return isSlingshot + ? new Slingshot(p.ID) + : new MeleeWeapon(p.ID); + }); } } |