From 09b88b8575b3591c58bea1b4b050012e028e68ab Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 18 Aug 2025 19:05:02 -0400 Subject: [PATCH] Fix auto-sell not being removed from adventure collection --- .../adventure/scene/AdventureDeckEditor.java | 32 ++++++++++++++++--- .../src/forge/adventure/scene/ShopScene.java | 5 ++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java index 0efcda70181..de00b6979f1 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java +++ b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java @@ -266,7 +266,14 @@ public class AdventureDeckEditor extends FDeckEditor { @Override public void refresh() { - cardManager.setPool(Current.player().getSellableCards()); + cardManager.setPool(getCardPool()); + } + + @Override + public ItemPool getCardPool() { + ItemPool pool = Current.player().getSellableCards(); + pool.removeAll(Current.player().autoSellCards); + return pool; } public void sellAllByFilter() { @@ -319,6 +326,13 @@ public class AdventureDeckEditor extends FDeckEditor { scheduleRefresh(); } + @Override + public ItemPool getCardPool() { + ItemPool pool = super.getCardPool(); + pool.removeAll(Current.player().autoSellCards); + return pool; + } + @Override protected void buildMenu(final FDropDownMenu menu, final PaperCard card) { super.buildMenu(menu, card); @@ -444,6 +458,12 @@ public class AdventureDeckEditor extends FDeckEditor { return Current.player().getAutoSellCards(); } + @Override + public void refresh() { + super.refresh(); + //Used when executing an auto-sell. + this.updateCaption(); + } protected boolean isShop() { return parentScreen.getEditorConfig() instanceof ShopConfig; @@ -637,10 +657,12 @@ public class AdventureDeckEditor extends FDeckEditor { public void refresh() { FThreads.invokeInBackgroundThread(() -> { for (TabPage page : tabPages) { - if (page instanceof CatalogPage) - ((CatalogPage) page).scheduleRefresh(); - else if (page instanceof CardManagerPage) - ((CardManagerPage) page).refresh(); + if (page instanceof CollectionAutoSellPage p) + p.refresh(); + else if (page instanceof CatalogPage p) + p.scheduleRefresh(); + else if (page instanceof CardManagerPage p) + p.refresh(); } }); } diff --git a/forge-gui-mobile/src/forge/adventure/scene/ShopScene.java b/forge-gui-mobile/src/forge/adventure/scene/ShopScene.java index a837603110a..58f3bbdf5de 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/ShopScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/ShopScene.java @@ -11,6 +11,7 @@ import forge.model.FModel; import forge.screens.FScreen; import forge.toolbox.FOptionPane; import forge.util.Callback; +import forge.util.ItemPool; /** * DeckEditScene @@ -79,7 +80,9 @@ public class ShopScene extends ForgeScene { } private void doAutosell() { - AdventurePlayer.current().doBulkSell(AdventurePlayer.current().autoSellCards); + ItemPool autoSellCards = AdventurePlayer.current().autoSellCards; + AdventurePlayer.current().doBulkSell(autoSellCards); + autoSellCards.clear(); if (screen != null) screen.refresh(); }