Skip to content

Commit

Permalink
fix fishing spawn rules not shown for non-fish catches like River Jelly
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Sep 14, 2024
1 parent 5bbaa62 commit 6d11d25
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
41 changes: 18 additions & 23 deletions LookupAnything/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public IEnumerable<FishPondPopulationGateData> GetFishPondPopulationGates(FishPo
public IEnumerable<FishPondDropData> GetFishPondDrops(FishPondData data)
{
foreach (FishPondReward drop in data.ProducedItems)
yield return new FishPondDropData(drop.RequiredPopulation, drop.ItemId, drop.MinQuantity, drop.MaxQuantity, drop.Chance);
yield return new FishPondDropData(drop.RequiredPopulation, drop.ItemId, drop.MinStack, drop.MaxStack, drop.Chance);
}

/// <summary>Read parsed data about the spawn rules for a specific fish.</summary>
Expand All @@ -149,16 +149,6 @@ public IEnumerable<FishPondDropData> GetFishPondDrops(FishPondData data)
/// <remarks>Derived from <see cref="GameLocation.getFish"/>.</remarks>
public FishSpawnData? GetFishSpawnRules(string fishID, Metadata metadata)
{
// get raw fish data
string[] fishFields;
{
if (!DataLoader.Fish(Game1.content).TryGetValue(fishID, out string? rawData))
return null;
fishFields = rawData.Split('/');
if (fishFields.Length < 13)
return null;
}

// parse location data
var locations = new List<FishSpawnLocationData>();
foreach ((string locationId, LocationData data) in DataLoader.Locations(Game1.content))
Expand Down Expand Up @@ -217,21 +207,26 @@ from areaGroup in curLocations.GroupBy(p => p.Area)
bool isUnique = false;
if (locations.Any()) // ignore default spawn criteria if the fish doesn't spawn naturally; in that case it should be specified explicitly in custom data below (if any)
{
// times of day
string[] timeFields = fishFields[5].Split(' ');
for (int i = 0, last = timeFields.Length + 1; i + 1 < last; i += 2)
if (DataLoader.Fish(Game1.content).TryGetValue(fishID, out string? rawData))
{
if (int.TryParse(timeFields[i], out int minTime) && int.TryParse(timeFields[i + 1], out int maxTime))
timesOfDay.Add(new FishSpawnTimeOfDayData(minTime, maxTime));
}
string[] fishFields = rawData.Split('/');

// weather
if (!Enum.TryParse(fishFields[7], true, out weather))
weather = FishSpawnWeather.Both;
// times of day
string[] timeFields = ArgUtility.Get(fishFields, 5)?.Split(' ') ?? Array.Empty<string>();
for (int i = 0, last = timeFields.Length + 1; i + 1 < last; i += 2)
{
if (int.TryParse(timeFields[i], out int minTime) && int.TryParse(timeFields[i + 1], out int maxTime))
timesOfDay.Add(new FishSpawnTimeOfDayData(minTime, maxTime));
}

// min fishing level
if (!int.TryParse(fishFields[12], out minFishingLevel))
minFishingLevel = 0;
// weather
if (!Enum.TryParse(ArgUtility.Get(fishFields, 7), true, out weather))
weather = FishSpawnWeather.Both;

// min fishing level
if (!int.TryParse(ArgUtility.Get(fishFields, 12), out minFishingLevel))
minFishingLevel = 0;
}
}

// read custom data
Expand Down
3 changes: 1 addition & 2 deletions LookupAnything/Framework/Lookups/Items/ItemSubject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ select name
}

// fish spawn rules
if (item.Category == SObject.FishCategory)
yield return new FishSpawnRulesField(this.GameHelper, I18n.Item_FishSpawnRules(), item.ItemId);
yield return new FishSpawnRulesField(this.GameHelper, I18n.Item_FishSpawnRules(), item.ItemId);

// fish pond data
// derived from FishPond::doAction
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Added monoculture achievement to item 'needed for' field (thanks to Mushymato!).
* Building recipes in item lookups now show the build gold price.
* Building lookups now show their build cost/materials.
* Fixed fishing spawn rules not shown for non-fish catches like River Jelly.
* Fixed support for custom machine rules using `ITEM_ID` and `ITEM_CONTEXT_TAG` game state queries.
* Fixed support for custom polyculture crops in 'needed for' field (thanks to Mushymato!).
* Fixed error getting recipes if a mod adds invalid machine data.
Expand Down

0 comments on commit 6d11d25

Please sign in to comment.