mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- Upgrading Sideboarding to M14 Rules for real this time (Constructed Sideboard can be 0-15 cards instead of 0 or 15 cards, no longer sideboard 1:1)
This commit is contained in:
@@ -39,10 +39,10 @@ import forge.util.Aggregates;
|
||||
public enum DeckFormat {
|
||||
|
||||
// Main board: allowed size SB: restriction Max distinct non basic cards
|
||||
Constructed ( new IntRange(60, Integer.MAX_VALUE), new IntRange(15), 4),
|
||||
QuestDeck ( new IntRange(40, Integer.MAX_VALUE), new IntRange(15), 4),
|
||||
Constructed ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0, 15), 4),
|
||||
QuestDeck ( new IntRange(40, Integer.MAX_VALUE), new IntRange(0, 15), 4),
|
||||
Limited ( new IntRange(40, Integer.MAX_VALUE), null, Integer.MAX_VALUE),
|
||||
Commander ( new IntRange(99), new IntRange(10), 1),
|
||||
Commander ( new IntRange(99), new IntRange(0, 10), 1),
|
||||
Vanguard ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
|
||||
Planechase ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
|
||||
Archenemy ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4);
|
||||
|
||||
@@ -244,14 +244,14 @@ public class GameNew {
|
||||
putCardsOnBattlefield(player, psc.getCardsOnBattlefield(player));
|
||||
initVariantsZones(player, psc);
|
||||
|
||||
boolean hasSideboard = psc.getOriginalDeck().has(DeckSection.Sideboard);
|
||||
if (canSideBoard && hasSideboard) {
|
||||
if (canSideBoard) {
|
||||
Deck sideboarded = player.getController().sideboard(psc.getCurrentDeck(), gameType);
|
||||
psc.setCurrentDeck(sideboarded);
|
||||
} else {
|
||||
psc.restoreOriginalDeck();
|
||||
}
|
||||
Deck myDeck = psc.getCurrentDeck();
|
||||
boolean hasSideboard = myDeck.has(DeckSection.Sideboard);
|
||||
|
||||
Set<CardPrinted> myRemovedAnteCards = useAnte ? null : getRemovedAnteCards(myDeck);
|
||||
Random generator = MyRandom.getRandom();
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.apache.commons.lang.math.IntRange;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
@@ -42,6 +43,7 @@ import forge.gui.input.InputSelectCardsFromList;
|
||||
import forge.gui.input.InputSynchronized;
|
||||
import forge.gui.match.CMatchUI;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
|
||||
@@ -119,23 +121,45 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public Deck sideboard(Deck deck, GameType gameType) {
|
||||
CardPool sideboard = deck.get(DeckSection.Sideboard);
|
||||
if (sideboard == null) {
|
||||
// Use an empty cardpool instead of null for 75/0 sideboarding scenario.
|
||||
sideboard = new CardPool();
|
||||
}
|
||||
|
||||
CardPool main = deck.get(DeckSection.Main);
|
||||
|
||||
int deckMinSize = Math.min(main.countAll(), gameType.getDecksFormat().getMainRange().getMinimumInteger());
|
||||
boolean conform = Singletons.getModel().getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY);
|
||||
int mainSize = main.countAll();
|
||||
int sbSize = sideboard.countAll();
|
||||
int combinedDeckSize = mainSize + sbSize;
|
||||
|
||||
int deckMinSize = Math.min(mainSize, gameType.getDecksFormat().getMainRange().getMinimumInteger());
|
||||
IntRange sbRange = gameType.getDecksFormat().getSideRange();
|
||||
// Limited doesn't have a sideboard max, so let the Main min take care of things.
|
||||
int sbMax = sbRange == null ? combinedDeckSize : sbRange.getMaximumInteger();
|
||||
|
||||
CardPool newSb = new CardPool();
|
||||
List<CardPrinted> newMain = null;
|
||||
|
||||
while (newMain == null || newMain.size() < deckMinSize) {
|
||||
if (newMain != null) {
|
||||
String errMsg = String.format("Too few cards in your main deck (minimum %d), please make modifications to your deck again.", deckMinSize);
|
||||
JOptionPane.showMessageDialog(null, errMsg, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
boolean isLimited = (gameType == GameType.Draft || gameType == GameType.Sealed);
|
||||
newMain = GuiChoose.sideboard(sideboard.toFlatList(), main.toFlatList(), isLimited);
|
||||
if (sbSize == 0 && mainSize == deckMinSize) {
|
||||
// Skip sideboard loop if there are no sideboarding opportunities
|
||||
newMain = main.toFlatList();
|
||||
} else {
|
||||
do {
|
||||
if (newMain != null) {
|
||||
if (newMain.size() < deckMinSize) {
|
||||
String errMsg = String.format("Too few cards in your main deck (minimum %d), please make modifications to your deck again.", deckMinSize);
|
||||
JOptionPane.showMessageDialog(null, errMsg, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
String errMsg = String.format("Too many cards in your sideboard (maximum %d), please make modifications to your deck again.", sbMax);
|
||||
JOptionPane.showMessageDialog(null, errMsg, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
// Sideboard rules have changed for M14, just need to consider min maindeck and max sideboard sizes
|
||||
// No longer need 1:1 sideboarding in non-limited formats
|
||||
newMain = GuiChoose.sideboard(sideboard.toFlatList(), main.toFlatList());
|
||||
} while (conform && (newMain.size() < deckMinSize || combinedDeckSize - newMain.size() > sbMax));
|
||||
}
|
||||
|
||||
newSb.clear();
|
||||
newSb.addAll(main);
|
||||
newSb.addAll(sideboard);
|
||||
|
||||
@@ -167,10 +167,10 @@ public class GuiChoose {
|
||||
return order(title, top, remainingObjects, sourceChoices, destChoices, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T extends Comparable<? super T>> List<T> sideboard(List<T> sideboard, List<T> deck, boolean isLimitedMode) {
|
||||
public static <T extends Comparable<? super T>> List<T> sideboard(List<T> sideboard, List<T> deck) {
|
||||
Collections.sort(deck);
|
||||
Collections.sort(sideboard);
|
||||
return order("Sideboard", "Main Deck", isLimitedMode ? -1 : sideboard.size(), sideboard, deck, null, true);
|
||||
return order("Sideboard", "Main Deck", -1, sideboard, deck, null, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user