Skip to content

Commit

Permalink
fix soft lock from receiving shop items multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
alwaysintreble committed Dec 1, 2023
1 parent 5f8daba commit 44777df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Archipelago/ArchipelagoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static void SyncLocations()
catch (Exception e)
{
Console.WriteLine(e);
Console.WriteLine($"{Session.Locations.GetLocationNameFromId(location)} {location}");
Console.WriteLine($"{Session.Locations.GetLocationNameFromId(location)}: {location}");
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion Archipelago/ItemsAndLocationsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,25 @@ public static void Unlock(long itemToUnlock, int quantity = APQuantity)
}
break;
default:
Manager<InventoryManager>.Instance.AddItem(randoItem.Item, quantity);
Console.WriteLine($"Checking if {randoItem.Item} is a shop item: {ShopItem(randoItem.Item)}");
if (ShopItem(randoItem.Item))
{
// don't award shuriken twice if we already got it from windmill shuriken
if (randoItem.Item.Equals(EItems.SHURIKEN) &
ArchipelagoClient.ServerData.ReceivedItems.ContainsKey(itemToUnlock)) return;
if (!new List<EItems> { EItems.HEART_CONTAINER, EItems.SHURIKEN_UPGRADE }.Contains(
randoItem.Item))
{
Console.WriteLine($"checking if {itemToUnlock} has been received already");
if (ArchipelagoClient.ServerData.ReceivedItems.ContainsKey(itemToUnlock))
{
Console.WriteLine("bailing");
return;
}
}
else if (ArchipelagoClient.ServerData.ReceivedItems.TryGetValue(itemToUnlock, out var count) &&
count > 1) return;
Manager<InventoryManager>.Instance.AddItem(randoItem.Item, quantity);
var view = Manager<UIManager>.Instance.GetView<InGameHud>();
view.UpdateMaxHeart();
view.UpdateMaxMana();
Expand Down

0 comments on commit 44777df

Please sign in to comment.