teamducro / gloomhaven-storyline

The spoiler free storyline tracker for Gloomhaven.
https://gloomhaven-storyline.com
71 stars 56 forks source link

Limit cross-game items available in Frosthaven #304

Closed powellcj12 closed 2 months ago

powellcj12 commented 2 months ago

As described in #292, only certain items from other games are supposed to be available in Frosthaven. This change enforces that by presenting the user options for which specific items from Gloomhaven should be included.

I changed the crossGameItems object in the CampaignSheet (which is essentially only used by Frosthaven) to include specific items that can be enabled. The list of items right now only includes what is listed in the base Frosthaven rules - it's possible others (including from other games) should be added later, but I'm trying to avoid spoilers. :) Characters was similarly updated to account for this change.

In the event that existing storage is loaded, I'm checking the schema of the crossGameItems objects and re-initializing it if necessary. This is going to potentially reset existing Frosthaven campaigns but attempt to bring over any items that characters might already have. I tested that with existing storage of some items included to characters, those items appear (both on the Items and Character pages) as expected after using the new version of the app.

I'm including a basic test that validates the behavior of this state. I also did some testing manually be enabling and disabling the cross-game items here, including making sure they would show up in the list in the Characters UI when searching. Those seemed to be the only places making use of crossGameItems.

Screenshot 2024-07-03 at 11 02 20 PM Screenshot 2024-07-05 at 10 47 15 PM
dducro commented 2 months ago

I like this, I'll test a build on my end as well.

dducro commented 2 months ago

I'm thinking, what if someone already added other gh items to there fh campaign? Should we check there sheets and add them to the gh crossGameItems obj? Thoughts?

powellcj12 commented 2 months ago

I'm thinking, what if someone already added other gh items to there fh campaign? Should we check there sheets and add them to the gh crossGameItems obj? Thoughts?

Hrm so I had done this to just account for if cross-game items had been selected previously to basically reset things: https://github.com/teamducro/gloomhaven-storyline/pull/304#discussion_r1665792161

But your comments makes me realize that might not be sufficient for items in a character's inventory? Even if what I have does reset things there, that could be even more destructive than I intended... I'll play around with things a bit to see what I can come up with.

powellcj12 commented 2 months ago

I'm thinking, what if someone already added other gh items to there fh campaign? Should we check there sheets and add them to the gh crossGameItems obj? Thoughts?

Hrm so I had done this to just account for if cross-game items had been selected previously to basically reset things: #304 (comment)

But your comments makes me realize that might not be sufficient for items in a character's inventory? Even if what I have does reset things there, that could be even more destructive than I intended... I'll play around with things a bit to see what I can come up with.

I pushed some new changes that attempts to preserve any existing items that characters might have. I updated the PR description with the basic testing I did, but it's a bit of a pain to test the "upgrade" scenario... I see there's some existing tests for storage migration that I'll see if I can leverage to add some tests for this scenario as well.

dducro commented 2 months ago

I like this solution, thanks!