Skip to content

Split Adventure save compatibility handling into separate methods#7799

Closed
Jetz72 wants to merge 17 commits into
Card-Forge:masterfrom
Jetz72:fixes20250704
Closed

Split Adventure save compatibility handling into separate methods#7799
Jetz72 wants to merge 17 commits into
Card-Forge:masterfrom
Jetz72:fixes20250704

Conversation

@Jetz72
Copy link
Copy Markdown
Contributor

@Jetz72 Jetz72 commented Jun 5, 2025

Renamed this issue because A) I think the original issue may have been fixed incidentally by the deck editor rewrite, and B) because the save compat stuff has grown to be the main feature of this PR.

This adds version numbers for adventure saves, and some methods that are applied when loading a save from an earlier version than Forge expects. This lets us split a bunch of special case backwards compatibility logic out of the main AdventurePlayer.load() method. In the future, any time we make a breaking change to the format of an Adventure Save, we can increment WorldSave.ADVENTURE_SAVE_VERSION and add the migration logic to the appropriate methods.

Original issue text below:


Attempts to resolve the issue discussed here. A user posted a file where A) They owned a deck containing over a thousand cards that weren't actually in their collection, and B) several cards in their auto-sell list also were not in their collection. It's not certain how this happened, but my working theory is that the cards were in both a deck and the auto-sell list, got auto-sold, and weren't removed from the deck as part of this process (because there's no logic to do so).

This PR attempts to solve the issue a bit upstream from the actual issue by preventing cards in auto-sell from being moved directly into decks. I'll see about doing a more direct fix to the sell logic in #7519.

This PR also adds some logic to clean up this issue from existing saves. Any cards that aren't in the collection will be removed from the auto-sell list (factoring in quantities appropriately). Any cards that aren't in the collection but are in decks will be added to the collection. I was going to just remove these from the decks as well, but that would likely cause substantial confusion for other users in this situation. We can change this in the future if this turns into the source of a card duplication bug.

Partially to that end, I've added a value ADVENTURE_SAVE_VERSION for adventure saves to track. Doesn't do much for now (And I haven't looked into whether the new dynamic deck count logic's legacy path can merge into it), but in the future we can increment it any time we need to modify the save system, and then check it to determine when migration logic should be applied. I've also added a field that stores the Forge version the file was saved with, for reference when debugging saves in the future.

Jetz72 added 5 commits June 4, 2025 22:27
Allow cards to be removed from auto-sell even if they aren't sellable in the first place for some reason.
# Conflicts:
#	forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java
@Jetz72 Jetz72 added the Adventure For the Adventure Module label Jun 5, 2025
Comment thread forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java Outdated
Jetz72 added 2 commits June 16, 2025 09:28
# Conflicts:
#	forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 8, 2025

This PR has not been updated in a while nad has been marked on stale. Stale PRs will be auto closed

# Conflicts:
#	forge-core/src/main/java/forge/util/ItemPool.java
#	forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java
#	forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java
#	forge-gui-mobile/src/forge/adventure/world/WorldSave.java
@Jetz72
Copy link
Copy Markdown
Contributor Author

Jetz72 commented Sep 10, 2025

@kevlahnota I've had this PR for a while to implement versioning and migration handling for Adventure Saves. Do you think it makes sense to roll your inventory item migration logic into something like this?

@Jetz72 Jetz72 requested a review from kevlahnota September 11, 2025 13:47
@github-actions
Copy link
Copy Markdown

This PR has not been updated in a while nad has been marked on stale. Stale PRs will be auto closed

@Jetz72 Jetz72 changed the title Attempt to fix desync between collection, decks, and auto-sell list Split Adventure save compatibility handling into separate methods Nov 5, 2025
@Jetz72 Jetz72 requested a review from tehdiplomat November 5, 2025 15:17
@Jetz72 Jetz72 added Serialization Relates to saving, loading, and compatibility of decks and games and removed no-pr-activity labels Nov 5, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 3, 2026

This PR has not been updated in a while nad has been marked on stale. Stale PRs will be auto closed

@github-actions
Copy link
Copy Markdown

This PR has not been updated in a while nad has been marked on stale. Stale PRs will be auto closed

@github-actions
Copy link
Copy Markdown

This PR has not been updated in a while nad has been marked on stale. Stale PRs will be auto closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Adventure For the Adventure Module no-pr-activity Serialization Relates to saving, loading, and compatibility of decks and games

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant