diff --git a/StardewArchipelago/Archipelago/ChatForwarder.cs b/StardewArchipelago/Archipelago/ChatForwarder.cs index 6c6ba8e80..bade06989 100644 --- a/StardewArchipelago/Archipelago/ChatForwarder.cs +++ b/StardewArchipelago/Archipelago/ChatForwarder.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using StardewArchipelago.Archipelago.Gifting; using StardewArchipelago.GameModifications; +using StardewArchipelago.GameModifications.CodeInjections; using StardewArchipelago.Goals; using StardewArchipelago.Items.Traps; using StardewArchipelago.Locations.CodeInjections.Vanilla; @@ -159,6 +160,12 @@ private static bool TryHandleCommand(string message) return true; } + if (HandlePrankCommand(messageLower)) + { + _lastCommand = message; + return true; + } + if (HandleHelpCommand(messageLower)) { return true; @@ -296,6 +303,17 @@ private static bool HandleSyncCommand(string message) return true; } + private static bool HandlePrankCommand(string message) + { + if (message != $"{COMMAND_PREFIX}fish" && message != $"{COMMAND_PREFIX}prank" && message != $"{COMMAND_PREFIX}stop") + { + return false; + } + + ZeldaAnimationInjections.TogglePrank(); + return true; + } + private static bool HandleHideEmptyLettersCommand(string message) { if (message != $"{COMMAND_PREFIX}letters") diff --git a/StardewArchipelago/GameModifications/CodeInjections/ZeldaAnimationInjections.cs b/StardewArchipelago/GameModifications/CodeInjections/ZeldaAnimationInjections.cs index 4e8a1d057..3a5ab3c9a 100644 --- a/StardewArchipelago/GameModifications/CodeInjections/ZeldaAnimationInjections.cs +++ b/StardewArchipelago/GameModifications/CodeInjections/ZeldaAnimationInjections.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using Microsoft.Xna.Framework; +using System.Reflection.Metadata.Ecma335; using StardewArchipelago.Archipelago; -using StardewArchipelago.Extensions; using StardewModdingAPI; using StardewValley; -using StardewValley.Buildings; namespace StardewArchipelago.GameModifications.CodeInjections { @@ -13,11 +11,15 @@ public static class ZeldaAnimationInjections { private static IMonitor _monitor; private static ArchipelagoClient _archipelago; + private static bool _shouldPrankOnFishDay; + private static bool _shouldPrankOnOtherDays; public static void Initialize(IMonitor monitor, ArchipelagoClient archipelago) { _monitor = monitor; _archipelago = archipelago; + _shouldPrankOnFishDay = true; + _shouldPrankOnOtherDays = false; } // public void holdUpItemThenMessage(Item item, bool showMessage = true) @@ -26,7 +28,7 @@ public static bool HoldUpItemThenMessage_SkipBasedOnConfig_Prefix(Farmer __insta try { // We skip this whole method when skipping hold up animations is true - return !ModEntry.Instance.Config.SkipHoldUpAnimations && !IsPrankDay(); + return !ModEntry.Instance.Config.SkipHoldUpAnimations || ShouldPrank(); } catch (Exception ex) { @@ -40,7 +42,7 @@ public static void AddItemToInventory_Position_PrankDay_Postfix(Farmer __instanc { try { - if (!IsPrankDay()) + if (!ShouldPrank()) { return; } @@ -59,7 +61,7 @@ public static void AddItemToInventory_AffectedItems_PrankDay_Postfix(Farmer __in { try { - if (!IsPrankDay()) + if (!ShouldPrank()) { return; } @@ -92,9 +94,26 @@ private static void DoZeldaAnimation(Farmer farmer,Item item, bool showMessage) farmer.canMove = false; } - private static bool IsPrankDay() + public static bool IsPrankDay() { return DateTime.Now.Month == 4 && DateTime.Now.Day == 1; } + + internal static bool ShouldPrank() + { + return IsPrankDay() ? _shouldPrankOnFishDay : _shouldPrankOnOtherDays; + } + + internal static void TogglePrank() + { + if (IsPrankDay()) + { + _shouldPrankOnFishDay = !_shouldPrankOnFishDay; + } + else + { + _shouldPrankOnOtherDays = !_shouldPrankOnOtherDays; + } + } } }