mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix null pointer when creating a custom constructed game. Enforce deck conformance check for ai deck.
This commit is contained in:
@@ -116,6 +116,10 @@ public enum DeckFormat {
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public String getDeckConformanceProblem(Deck deck) {
|
||||
if(deck == null) {
|
||||
return "is not selected";
|
||||
}
|
||||
|
||||
// That's really a bad dependence
|
||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
|
||||
return null;
|
||||
|
||||
@@ -92,14 +92,22 @@ public enum CSubmenuConstructed implements ICDoc {
|
||||
view.getCbRemoveSmall().setSelected(prefs.getPrefBoolean(FPref.DECKGEN_NOSMALL));
|
||||
}
|
||||
|
||||
/** @param gameType
|
||||
* @param lists0   {@link java.util.List}<{@link javax.swing.JList}> */
|
||||
/**
|
||||
*
|
||||
* @param gameType
|
||||
*/
|
||||
private void startGame(final GameType gameType) {
|
||||
Deck humanDeck = VSubmenuConstructed.SINGLETON_INSTANCE.getDcHuman().getDeck();
|
||||
String humanDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(humanDeck);
|
||||
if (null != humanDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "Your deck " + humanDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String errorMessage = gameType.getDecksFormat().getDeckConformanceProblem(humanDeck);
|
||||
if (null != errorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "Your deck " + errorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
Deck aiDeck = VSubmenuConstructed.SINGLETON_INSTANCE.getDcAi().getDeck();
|
||||
String aiDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(aiDeck);
|
||||
if (null != aiDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "AI deck " + aiDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user