Skip to content

Commit

Permalink
- Added a chat command
Browse files Browse the repository at this point in the history
  • Loading branch information
agilbert1412 committed Mar 31, 2024
1 parent 7a554c9 commit 00ded1c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
18 changes: 18 additions & 0 deletions StardewArchipelago/Archipelago/ChatForwarder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -159,6 +160,12 @@ private static bool TryHandleCommand(string message)
return true;
}

if (HandlePrankCommand(messageLower))
{
_lastCommand = message;
return true;
}

if (HandleHelpCommand(messageLower))
{
return true;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
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
{
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)
Expand All @@ -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)
{
Expand All @@ -40,7 +42,7 @@ public static void AddItemToInventory_Position_PrankDay_Postfix(Farmer __instanc
{
try
{
if (!IsPrankDay())
if (!ShouldPrank())
{
return;
}
Expand All @@ -59,7 +61,7 @@ public static void AddItemToInventory_AffectedItems_PrankDay_Postfix(Farmer __in
{
try
{
if (!IsPrankDay())
if (!ShouldPrank())
{
return;
}
Expand Down Expand Up @@ -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;
}
}
}
}

0 comments on commit 00ded1c

Please sign in to comment.