Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Junimos Planting Tree Fertilizer #76

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions BetterJunimos/Abilities/Base/FertilizeAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace BetterJunimos.Abilities {
public class FertilizeAbility : IJunimoAbility {
private const int ItemCategory = SObject.fertilizerCategory;
private const string TreeFertilizer = "805";
private List<string> _RequiredItems;

public string AbilityName() {
Expand All @@ -31,7 +32,7 @@ public bool IsActionAvailable(GameLocation location, Vector2 pos, Guid guid) {

public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester junimo, Guid guid) {
var chest = Util.GetHutFromId(guid).GetOutputChest();
var foundItem = chest.Items.FirstOrDefault(item => item is {Category: ItemCategory});
var foundItem = chest.Items.FirstOrDefault(item => item is {Category: ItemCategory} && item.ItemId != TreeFertilizer);
if (foundItem == null) return false;

Fertilize(location, pos, foundItem.ParentSheetIndex);
Expand All @@ -43,7 +44,7 @@ public List<string> RequiredItems() {
// this is heavy, cache it
if (_RequiredItems is not null) return _RequiredItems;
var fertilizers = Game1.objectData
.Where(pair => pair.Value.Category == StardewValley.Object.fertilizerCategory);
.Where(pair => pair.Value.Category == StardewValley.Object.fertilizerCategory && pair.Key != TreeFertilizer);
// BetterJunimos.SMonitor.Log("RequiredItems called for Fertilize", LogLevel.Debug);
_RequiredItems = (from kvp in fertilizers select kvp.Key).ToList();

Expand Down
2 changes: 1 addition & 1 deletion BetterJunimos/Abilities/Base/VisitGreenhouseAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public bool IsActionAvailable(GameLocation location, Vector2 pos, Guid guid) {
if (!greenhouses.Any(greenhouseBuilding => greenhouseBuilding is not null)) return false;
var greenhouse = greenhouses.FirstOrDefault(greenhouseBuilding => greenhouseBuilding is not null);
//BetterJunimos.SMonitor.Log("Greenhouse found", LogLevel.Debug);
if (greenhouse.characters.Count(npc => npc is JunimoHarvester) > Util.Progression.MaxJunimosUnlocked / 2) {
if (greenhouse.characters.Count(npc => npc is JunimoHarvester) >= Util.Progression.MaxJunimosUnlocked - Util.Progression.BonusMaxJunimos) {
// greenhouse already kinda full
// BetterJunimos.SMonitor.Log("Greenhouse full", LogLevel.Debug);
return false;
Expand Down
2 changes: 1 addition & 1 deletion BetterJunimos/BetterJunimos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>BetterJunimos</AssemblyName>
<RootNamespace>BetterJunimos</RootNamespace>
<Version>3.0.5</Version>
<Version>3.1.2</Version>
<LangVersion>latest</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<EnableHarmony>true</EnableHarmony>
Expand Down
23 changes: 18 additions & 5 deletions BetterJunimos/Utils/JunimoProgression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Buildings;
using StardewValley.Characters;
using StardewValley.Locations;
using StardewValley.Objects;
using static System.String;
Expand Down Expand Up @@ -131,11 +132,23 @@ private bool LockedAndNotPrompted(string progression) {

public int MaxJunimosUnlocked {
get {
if (!BetterJunimos.Config.Progression.Enabled) return BetterJunimos.Config.JunimoHuts.MaxJunimos;
if (Unlocked("UnlimitedJunimos")) return BetterJunimos.Config.JunimoHuts.MaxJunimos;
if (Unlocked("MoreJunimos"))
return Math.Min(MoreJunimosLimit, BetterJunimos.Config.JunimoHuts.MaxJunimos);
return Math.Min(InitialJunimosLimit, BetterJunimos.Config.JunimoHuts.MaxJunimos);
if (!BetterJunimos.Config.Progression.Enabled) return BetterJunimos.Config.JunimoHuts.MaxJunimos + BonusMaxJunimos;
if (Unlocked("UnlimitedJunimos")) return BetterJunimos.Config.JunimoHuts.MaxJunimos + BonusMaxJunimos;
if (Unlocked("MoreJunimos")) return Math.Min(MoreJunimosLimit, BetterJunimos.Config.JunimoHuts.MaxJunimos + BonusMaxJunimos);
return Math.Min(InitialJunimosLimit, BetterJunimos.Config.JunimoHuts.MaxJunimos + BonusMaxJunimos);
}
}

public int BonusMaxJunimos {
get {
var bonusJunimos = 0;
foreach (var farm in Util.GetAllFarms()) {
if (farm.IsGreenhouse) {
bonusJunimos += farm.characters.Count(npc => npc is JunimoHarvester);
}
}

return bonusJunimos;
}
}

Expand Down
2 changes: 1 addition & 1 deletion BetterJunimos/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Better Junimos",
"Author": "ceruleandeep",
"Version": "3.0.5",
"Version": "3.1.2",
"Description": "Allow your Junimos (from Junimo huts) to automatically plant seeds, fertilize, and so much more!",
"UniqueID": "hawkfalcon.BetterJunimos",
"EntryDll": "BetterJunimos.dll",
Expand Down