mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Adding game type requirements
- Quests now enforcing game type requirements
This commit is contained in:
@@ -38,6 +38,7 @@ import forge.deck.io.DeckSerializer;
|
||||
import forge.gui.deckeditor.tables.TableSorter;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
import forge.game.GameType;
|
||||
import forge.game.limited.ReadDraftRankings;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.FileUtil;
|
||||
@@ -316,6 +317,18 @@ public class Deck extends DeckBase implements Serializable {
|
||||
return (20.0 / (best + (2 * value)));
|
||||
}
|
||||
|
||||
public boolean meetsGameTypeRequirements(GameType type) {
|
||||
int deckSize = main.countAll();
|
||||
int deckDistinct = main.countDistinct();
|
||||
Integer max = type.getDeckMaximum();
|
||||
|
||||
if (deckSize < type.getDeckMinimum() || (max != null && deckSize > max) ||
|
||||
(type.isSingleton() && deckDistinct != deckSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final Function<Deck, String> FN_NAME_SELECTOR = new Function<Deck, String>() {
|
||||
@Override
|
||||
|
||||
@@ -23,19 +23,22 @@ package forge.game;
|
||||
public enum GameType {
|
||||
|
||||
/** The Constructed. */
|
||||
Constructed(false),
|
||||
Constructed(false, 60),
|
||||
/** The Sealed. */
|
||||
Sealed(true),
|
||||
Sealed(true, 40),
|
||||
/** The Draft. */
|
||||
Draft(true),
|
||||
Draft(true, 40),
|
||||
/** The Commander. */
|
||||
Commander(false),
|
||||
Commander(false, 100, 100, true),
|
||||
/** The Quest. */
|
||||
Quest(true),
|
||||
Quest(true, 40),
|
||||
/** */
|
||||
Gauntlet(true);
|
||||
Gauntlet(true, 40);
|
||||
|
||||
private final boolean bLimited;
|
||||
private final int deckMinimum;
|
||||
private final Integer deckMaximum;
|
||||
private final boolean singleton;
|
||||
|
||||
/**
|
||||
* Checks if is limited.
|
||||
@@ -46,14 +49,34 @@ public enum GameType {
|
||||
return this.bLimited;
|
||||
}
|
||||
|
||||
public final int getDeckMinimum() {
|
||||
return this.deckMinimum;
|
||||
}
|
||||
|
||||
public final Integer getDeckMaximum() {
|
||||
return this.deckMaximum;
|
||||
}
|
||||
|
||||
public final boolean isSingleton() {
|
||||
return this.singleton;
|
||||
}
|
||||
|
||||
GameType(final boolean isLimited, int min) {
|
||||
this(isLimited, min, null, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new game type.
|
||||
*
|
||||
* @param isLimited
|
||||
* the is limited
|
||||
*/
|
||||
GameType(final boolean isLimited) {
|
||||
GameType(final boolean isLimited, int min, Integer max, boolean singleton) {
|
||||
this.bLimited = isLimited;
|
||||
this.deckMinimum = min;
|
||||
this.deckMaximum = max;
|
||||
this.singleton = singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
|
||||
@@ -222,6 +223,14 @@ public class SSubmenuQuestUtil {
|
||||
final QuestController qData = Singletons.getModel().getQuest();
|
||||
final QuestEvent event = selectedOpponent.getEvent();
|
||||
|
||||
Deck deck = SSubmenuQuestUtil.getCurrentDeck();
|
||||
if (!deck.meetsGameTypeRequirements(GameType.Quest)) {
|
||||
String msg = "Chosen Deck doesn't meet the requirements (Minimum 40 cards). Please edit or choose a different deck.";
|
||||
JOptionPane.showMessageDialog(null, msg);
|
||||
System.out.println(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user