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

Merged in ShotrayWW's fish fixes and updated forecasting to 1.6 #39

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a5542f6
Squashed a bunch of the commits transferred from the main branch
KhloeLeclair Mar 16, 2022
7bbe90f
1.6 dev stuff
KhloeLeclair Apr 2, 2022
883177b
Trying to get file to find Stardew
Vindeflei Mar 27, 2024
19bdbd7
Update the mod packages and other common.targets stuff for 1.6 and Sm…
Vindeflei Mar 27, 2024
997c81f
Remove GamePath hardcoding
Vindeflei Mar 27, 2024
e69df61
Update Weather
Vindeflei Mar 27, 2024
e1ceb23
Update AssetManager
Vindeflei Mar 27, 2024
a12dcd0
Update Fish
Vindeflei Mar 27, 2024
c0123d7
Update Managers
Vindeflei Mar 27, 2024
58556a3
Ledger and MoreRandomEvents not found
Vindeflei Mar 28, 2024
11aa2bb
Update Pages
Vindeflei Mar 28, 2024
a058634
Update Helpers
Vindeflei Mar 29, 2024
0d5ed71
Update Mod files
Vindeflei Mar 29, 2024
e3414c7
Update Query Patches
Vindeflei Mar 29, 2024
3769004
Update Menus
Vindeflei Mar 29, 2024
4244bf9
Alignment Update
Vindeflei Mar 29, 2024
2ef6d1d
Update Common
Vindeflei Mar 30, 2024
5de3a95
Update Crops
Vindeflei Mar 30, 2024
0096fb8
Update MenuFishTank
Vindeflei Mar 30, 2024
5bc3310
Rectangle shenanigans
Vindeflei Mar 30, 2024
a2d76a0
It builds now!!
Vindeflei Mar 30, 2024
2d66a76
REVERT: Remove Mods Paths
Vindeflei Mar 30, 2024
e55f2c9
(O) identifier unneeded
Vindeflei Mar 30, 2024
2d90b8d
Add Green Rain
Vindeflei Apr 1, 2024
f633e74
Fix Fish!!
Vindeflei Apr 1, 2024
12aeb53
Fix new crop sprites
Vindeflei Apr 1, 2024
5bb2401
Revert SeeMeRollin
Vindeflei Apr 1, 2024
617a49a
Revert SeeMeRollin
Vindeflei Apr 1, 2024
9f5dfc0
Add Bookseller and passive festivals
Vindeflei Apr 4, 2024
5d1d67a
Fix All Seasons bug
Vindeflei Apr 10, 2024
aa42d21
Edit the path for my path
ShotrayWW Nov 5, 2024
de9febb
Make Almanac can be used without the Random features in 1.6.9
ShotrayWW Nov 5, 2024
e007810
Revert "Edit the path for my path"
ShotrayWW Nov 5, 2024
91e74d6
Merge branch 'main' of https://github.com/Vindeflei/KhloeLeclairStard…
Vindeflei Jan 29, 2025
c91a55a
Merge branch 'main' of https://github.com/Vindeflei/KhloeLeclairStard…
Vindeflei Jan 29, 2025
9f34c5d
Merge branch 'pr/35'
Vindeflei Jan 29, 2025
3116389
Merged in ShotrayWW's fish fixes then added back the Random forecasts,
Vindeflei Jan 30, 2025
6b31007
Delete old BCBuildings files
Vindeflei Jan 30, 2025
fe97ce7
Delete old SeeMeRollin files
Vindeflei Jan 30, 2025
99085c2
Delete old GiantCropTweaks files
Vindeflei Jan 30, 2025
1042f95
Delete old BetterCrafting files
Vindeflei Jan 30, 2025
aa96af7
Update BetterCrafting/../GardenPotRecipe
Vindeflei Jan 30, 2025
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
11 changes: 8 additions & 3 deletions Almanac/Almanac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
<AssemblyName>Almanac</AssemblyName>
<Version>0.18.1</Version>
<RootNamespace>Leclair.Stardew.Almanac</RootNamespace>

<EnableHarmony>true</EnableHarmony>
<EnableTranslation>true</EnableTranslation>
<TargetFramework>net6.0</TargetFramework>
<UseCommon>Crafting;BCInventory;Inventory;GMCM;Mutex;Overlay;UI;SimpleLayout;Flow;SpookyAction;ThemeManager</UseCommon>
</PropertyGroup>

<Import Project="..\Common\Common.projitems" Label="Shared" />
<Import Project="..\_build\common.targets" />
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

</ItemGroup>
<Import Project="..\Common\Common.projitems" Label="Shared" />
<Import Project="..\_build\common.targets" />
</Project>
18 changes: 9 additions & 9 deletions Almanac/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ private void Load(string? locale) {
Locale = locale;
}

public struct EventData {
public static readonly Regex I18N_SPLITTER = new(@"{{(.+?)}}", RegexOptions.Compiled);
public struct EventData {
public static readonly Regex I18N_SPLITTER = new(@"{{(.+?)}}", RegexOptions.Compiled);

public string Id { get; set; }
public string[] Conditions { get; set; }
public string[] Script { get; set; }
public string Id { get; set; }
public string[] Conditions { get; set; }
public string[] Script { get; set; }

public string Key => $"{Id}/{string.Join("/", Conditions)}";
public string RealScript => string.Join("/", Script);
public string Key => $"{Id}/{string.Join("/", Conditions)}";
public string RealScript => string.Join("/", Script);

public string Localize(ITranslationHelper helper) {
string id = Id;
public string Localize(ITranslationHelper helper) {
string id = Id;

return I18N_SPLITTER.Replace(RealScript, match => {
string key = match.Groups[1].Value;
Expand Down
4 changes: 2 additions & 2 deletions Almanac/Crops/CropPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public CropPage(AlmanacMenu menu, ModEntry mod) : base(menu, mod) {
rightNeighborID = ClickableComponent.SNAP_AUTOMATIC
};
tabSeedsSprite = Game1.random.Next(2 * AlmanacMenu.TABS.Length);
spriteSeeds = SpriteHelper.GetSprite(InventoryHelper.CreateItemById("(O)495", 1));
spriteSeeds = SpriteHelper.GetSprite(ItemRegistry.Create("(O)495"));

// Cache Agriculturist status.
Agriculturist = Game1.player.professions.Contains(Farmer.agriculturist);
Expand Down Expand Up @@ -350,7 +350,7 @@ public override void Update() {
break;
}

spriteSeeds = SpriteHelper.GetSprite(InventoryHelper.CreateItemById(seasonSeeds, 1));
spriteSeeds = SpriteHelper.GetSprite(ItemRegistry.Create(seasonSeeds));

LastDays = new List<CropInfo>[ModEntry.DaysPerMonth];

Expand Down
29 changes: 20 additions & 9 deletions Almanac/FishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Dictionary<string, Dictionary<SubLocation, List<int>>> GetFishLoca
//Dictionary<SubLocation, seasons>
Dictionary<string, Dictionary<SubLocation, List<int>>> result = new();
//Dictionary<locationId, locationData>
var locations = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
var locations = Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");

foreach (var lp in locations) {
if (SkipLocation(lp.Key))
Expand Down Expand Up @@ -164,7 +164,7 @@ public static Dictionary<string, Dictionary<SubLocation, List<int>>> GetFishLoca
public static Dictionary<string, List<SubLocation>> GetFishLocations(int season) {
Dictionary<string, List<SubLocation>> result = new();

var locations = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
var locations = Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");
foreach (var lp in locations) {
if (SkipLocation(lp.Key))
continue;
Expand Down Expand Up @@ -197,7 +197,7 @@ public static Dictionary<string, List<string>> GetLocationFish(string key, int s
if (key == "BeachNightMarket")
key = "Beach";

locations ??= Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
locations ??= Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");
Dictionary<string, List<string>> result;
GameLocation loc;
if (locations.ContainsKey(key) && ContainsFish(locations[key]))
Expand Down Expand Up @@ -262,7 +262,7 @@ public static Dictionary<string, List<string>> GetLocationFish(string key, int s
}
}
try{
GetLocationFish(season, locations[Game1.GetFarmTypeKey()], result);
GetLocationFish(season, locations[Game1.GetFarmTypeID()], result);
} catch {
ModEntry.Instance.Log($"Error at {getLocName(locations[Game1.GetFarmTypeKey()])}, farm key section.", LogLevel.Warn);
}
Expand All @@ -288,10 +288,10 @@ public static Dictionary<string, List<string>> GetLocationFish(int season, Locat
if (data.Equals(null))
return existing;

string name = getLocName(data);
string name = data.DisplayName;
List<SpawnFishData> entries = data.Fish;
if (!data.Equals(Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations")["Default"])) {
LocationData Default = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations")["Default"];
if (!data.Equals(DataLoader.Locations(Game1.content)["Default"])) {
LocationData Default = DataLoader.Locations(Game1.content)["Default"];
foreach (SpawnFishData f in Default.Fish)
if (!entries.Contains(f))
entries.Add(f);
Expand All @@ -316,8 +316,19 @@ public static bool ContainsFish(LocationData loc) {
return false;
}
private static string getLocName(LocationData data) {
string name = data.DisplayName == null ? "No DisplayName" : data.DisplayName;
string name = data.DisplayName ?? "No DisplayName";
string endCheck = name.Substring(name.Length - 7);
switch (name) {
case "Farm_Standard":
case "Farm_Forest":
case "Farm_FourCorners":
case "Farm_Hilltop":
case "Farm_Riverland":
case "Farm_Wilderness":
case "Farm_Beach":
name = "Farm";
break;
}
switch (endCheck) {
case "Name]]]":
name = "Farm";
Expand All @@ -344,7 +355,7 @@ private static string getLocName(LocationData data) {
name = "Woods";
break;
}
if (name.Length > 25) name = endCheck;
//if (name.Length > 25) name = endCheck;
return name;
}
private static bool canAddFish(SpawnFishData fish, int season, LocationData data) {
Expand Down
45 changes: 17 additions & 28 deletions Almanac/Managers/LuckManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using StardewValley;

using Leclair.Stardew.Almanac.Models;
using StardewValley.TokenizableStrings;

namespace Leclair.Stardew.Almanac.Managers;

Expand Down Expand Up @@ -183,7 +184,7 @@ public void RegisterHook(IManifest mod, Func<ulong, WorldDate, IEnumerable<Tuple
#region Luck Lookup

public double GetLuckForDate(ulong seed, WorldDate date) {
Random rnd = new(date.TotalDays + (int)seed / 2);
Random rnd = new(date.TotalDays + (int) seed / 2);

int prewarm = rnd.Next(0, 100);
for (int j = 0; j < prewarm; j++)
Expand Down Expand Up @@ -211,7 +212,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {
// Lucky players have a 20% chance of maximum daily luck.
if (Mod.intLS.HasLucky(who)) {
// Don't use the seed, since we don't control that mod's seed.
Random rnd = new((int)Game1.uniqueIDForThisGame + date.TotalDays * 3);
Random rnd = new((int) Game1.uniqueIDForThisGame + date.TotalDays * 3);
if (rnd.NextDouble() <= 0.20)
result = 0.12;
}
Expand All @@ -229,7 +230,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {

#region Events

public IRichEvent? HydrateEvent(LocalNotice notice, WorldDate date, Common.GameStateQuery.GameState state, string? key = null) {
public IRichEvent? HydrateEvent(LocalNotice notice, WorldDate date, string? key = null) {
if (notice == null)
return null;

Expand Down Expand Up @@ -280,7 +281,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {
}

// Condition Validation
if (!string.IsNullOrEmpty(notice.Condition) && !Common.GameStateQuery.CheckConditions(notice.Condition, state))
if (!string.IsNullOrEmpty(notice.Condition) && !GameStateQuery.CheckConditions(notice.Condition))
return null;

// Get icon
Expand All @@ -291,7 +292,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {
// This will change in 1.6
if (!string.IsNullOrEmpty(notice.Item)) {
try {
item = InventoryHelper.CreateItemById(notice.Item, 1);
item = ItemRegistry.Create(notice.Item, 1);
} catch (Exception ex) {
Log($"Unable to get item instance for: {notice.Item}", LogLevel.Warn, ex);
item = null;
Expand Down Expand Up @@ -335,7 +336,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {
if (notice.Translation != null && !string.IsNullOrEmpty(notice.I18nKey))
notice.Description = notice.Translation.Get(notice.I18nKey).ToString();

string? desc = string.IsNullOrEmpty(notice.Description) ? null : StringTokenizer.ParseString(notice.Description, state);
string? desc = string.IsNullOrEmpty(notice.Description) ? null : TokenParser.ParseText(notice.Description);
if (desc != null && Mod.Config.DebugMode && !string.IsNullOrEmpty(key))
desc = $"{desc} @C@c@h(#{key})";

Expand All @@ -353,21 +354,10 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {

Load();

var state = new Common.GameStateQuery.GameState(
Random: Game1.random,
Date: date,
TimeOfDay: 600,
Ticks: 0,
Farmer: Game1.player,
Location: null,
Item: null,
Monitor: Mod.Monitor,
DoTrace: false
);

if (DataEvents != null)
foreach (var entry in DataEvents) {
IRichEvent? hydrated = HydrateEvent(entry.Value, date, state, entry.Key);
IRichEvent? hydrated = HydrateEvent(entry.Value, date, entry.Key);
if (hydrated != null)
yield return hydrated;
}
Expand Down Expand Up @@ -451,7 +441,7 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {

public static IRichEvent? GetTrashEvent(ulong seed, WorldDate date) {
for (int i = 0; i < 8; i++) {
Random rnd = new((date.TotalDays + 1) + ((int)seed / 2) + 777 + i * 77);
Random rnd = new((date.TotalDays + 1) + ((int) seed / 2) + 777 + i * 77);

int prewarm = rnd.Next(0, 100);
for (int j = 0; j < prewarm; j++)
Expand All @@ -466,7 +456,7 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
if (rnd.NextDouble() >= 0.002)
continue;

Item? item = InventoryHelper.CreateItemById("(H)66", 1);
Item? item = ItemRegistry.Create("(H)66", 1);
SpriteInfo? sprite = SpriteHelper.GetSprite(item);

return new RichEvent(
Expand All @@ -485,7 +475,7 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
if (days == 31)
return null;

Random rnd = new(days + (int)seed / 2);
Random rnd = new(days + (int) seed / 2);

// Don't track any of the Community Center / Joja events because
// those all rely on game state and are not random based on the
Expand Down Expand Up @@ -535,10 +525,11 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
I18n.Page_Fortune_Event_Ufo(),
null,
SpriteHelper.GetSprite(new SObject(Vector2.Zero, 96))
);*/
);
*/

return null;
}
return null;
}

private static IRichEvent? GetLuckSkillEventForDate(ulong seed, WorldDate date) {
int days = date.TotalDays + 1 + 999999;
Expand Down Expand Up @@ -596,12 +587,10 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
SpriteHelper.GetSprite(new SObject(Vector2.Zero, "95"))
);

// Don't track Strange Capsule, because that relies on whether
// or not the player has already seen it.

return null;
}

#endregion
#endregion

}

Loading