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")
|
@SuppressWarnings("incomplete-switch")
|
||||||
public String getDeckConformanceProblem(Deck deck) {
|
public String getDeckConformanceProblem(Deck deck) {
|
||||||
|
if(deck == null) {
|
||||||
|
return "is not selected";
|
||||||
|
}
|
||||||
|
|
||||||
// That's really a bad dependence
|
// That's really a bad dependence
|
||||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
|
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -92,14 +92,22 @@ public enum CSubmenuConstructed implements ICDoc {
|
|||||||
view.getCbRemoveSmall().setSelected(prefs.getPrefBoolean(FPref.DECKGEN_NOSMALL));
|
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) {
|
private void startGame(final GameType gameType) {
|
||||||
Deck humanDeck = VSubmenuConstructed.SINGLETON_INSTANCE.getDcHuman().getDeck();
|
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);
|
Deck aiDeck = VSubmenuConstructed.SINGLETON_INSTANCE.getDcAi().getDeck();
|
||||||
if (null != errorMessage) {
|
String aiDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(aiDeck);
|
||||||
JOptionPane.showMessageDialog(null, "Your deck " + errorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
if (null != aiDeckErrorMessage) {
|
||||||
|
JOptionPane.showMessageDialog(null, "AI deck " + aiDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user