Skip to content

Commit 07ece6c

Browse files
committed
fix(draft): conspiracy cards work in custom cube drafts
- CustomLimited.parse(): merge DeckSection.Conspiracy into the card pool so cards like Backup Plan appear in packs alongside regular cards. - GauntletMini.startRound(): call assignConspiracies() on each player before starting the match (LoadDraftScreen already did this; Gauntlet mode was the missing path). - FDeckEditor CatalogPage: pass forceCreateIfAbsent=true to getPageForSection() in onCardActivated() and buildMenu() so the Conspiracy tab is created on demand when a conspiracy card is drafted. - BackupPlanService.initializeExtraHands(): guard each extra-hand draw with a library-size check to prevent a turn-0 game loss when a player holds multiple Backup Plans. Use getMaxHandSize() instead of hardcoded 7.
1 parent be880ac commit 07ece6c

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

forge-game/src/main/java/forge/game/extrahands/BackupPlanService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ public boolean initializeExtraHands() {
2626
if (player.getExtraZones() == null) {
2727
return multipleHands;
2828
}
29+
final int handSize = player.getMaxHandSize();
2930
for(PlayerZone extraHand : player.getExtraZones()) {
3031
if (extraHand.getZoneType() == ZoneType.ExtraHand) {
31-
player.drawCards(7, extraHand);
32+
// Only draw an extra hand if there are enough cards in the library.
33+
// Multiple Backup Plans in test decks (or edge cases) could exhaust
34+
// the library and incorrectly trigger a Turn-0 game loss.
35+
if (player.getZone(ZoneType.Library).size() < handSize) {
36+
break;
37+
}
38+
player.drawCards(handSize, extraHand);
3239
multipleHands = true;
3340
hands.add(extraHand);
3441
// If we figure out how to render the zone in the UI, do it here

forge-gui-mobile/src/forge/deck/FDeckEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ else if(parentScreen.shouldEnforceConformity()) //If we have a commander, filter
18061806
@Override
18071807
protected void onCardActivated(PaperCard card) {
18081808
DeckSection destination = DeckSection.matchingSection(card);
1809-
final DeckSectionPage destinationPage = parentScreen.getPageForSection(destination);
1809+
final DeckSectionPage destinationPage = parentScreen.getPageForSection(destination, true);
18101810
if(destinationPage == null) {
18111811
System.err.println("Unable to quick-move card (no page for destination) - " + card + " -> " + destination);
18121812
return; //Shouldn't happen?
@@ -1835,7 +1835,7 @@ protected void buildMenu(final FDropDownMenu menu, final PaperCard card) {
18351835
return;
18361836

18371837
DeckSection destination = DeckSection.matchingSection(card);
1838-
final DeckSectionPage destinationPage = parentScreen.getPageForSection(destination);
1838+
final DeckSectionPage destinationPage = parentScreen.getPageForSection(destination, true);
18391839

18401840
if (!needsCommander() && !canOnlyBePartnerCommander(card) && destinationPage != null) {
18411841
addMoveCardMenuItem(menu, card, this, destinationPage);

forge-gui/src/main/java/forge/gamemodes/limited/CustomLimited.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import forge.deck.CardPool;
2222
import forge.deck.Deck;
2323
import forge.deck.DeckBase;
24+
import forge.deck.DeckSection;
2425
import forge.item.PaperCard;
2526
import forge.item.SealedTemplate;
2627
import forge.model.FModel;
@@ -121,7 +122,16 @@ public static CustomLimited parse(final List<String> dfData, final IStorage<Deck
121122
cd.numPlayers = data.getInt("NumPlayers");
122123
cd.customRankingsFile = data.get("CustomRankings", "rankings_cubecobra.txt");
123124
final Deck deckCube = cubes.get(data.get("DeckFile"));
124-
cd.cardPool = deckCube == null ? ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class) : deckCube.getMain();
125+
if (deckCube == null) {
126+
cd.cardPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class);
127+
} else {
128+
// Include conspiracy cards (e.g. Backup Plan) in the draft pool alongside regular cards
129+
CardPool pool = new CardPool(deckCube.getMain());
130+
if (deckCube.has(DeckSection.Conspiracy)) {
131+
pool.addAll(deckCube.get(DeckSection.Conspiracy));
132+
}
133+
cd.cardPool = pool;
134+
}
125135

126136
return cd;
127137
}

forge-gui/src/main/java/forge/gamemodes/limited/GauntletMini.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ private void startRound() {
139139
starter.add(human);
140140
starter.add(aiOpponents.get(currentRound - 1).setPlayer(GamePlayerUtil.createAiPlayer()));
141141

142+
for (final RegisteredPlayer pl : starter) {
143+
pl.assignConspiracies();
144+
}
145+
142146
hostedMatch = GuiBase.getInterface().hostMatch();
143147
hostedMatch.startMatch(gauntletType, null, starter, human, GuiBase.getInterface().getNewGuiGame());
144148
}

0 commit comments

Comments
 (0)