Merge pull request #889 from daleao/develop

Replace slingshot ID check with type field check
This commit is contained in:
Jesse Plamondon-Willard 2022-12-28 11:33:31 -05:00 committed by GitHub
commit d438e49f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -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);
});
}
}