diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.form b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.form index ff7ddd68459..b712fbe518e 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.form @@ -44,6 +44,8 @@ + + @@ -156,6 +158,7 @@ + @@ -284,6 +287,12 @@ + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java index 9b59121999c..54dd00251e2 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java @@ -102,6 +102,7 @@ public class NewTableDialog extends MageDialog { cbGameType = new javax.swing.JComboBox(); chkRollbackTurnsAllowed = new javax.swing.JCheckBox(); chkSpectatorsAllowed = new javax.swing.JCheckBox(); + chkPlaneChase = new javax.swing.JCheckBox(); chkRated = new javax.swing.JCheckBox(); lblFreeMulligans = new javax.swing.JLabel(); spnFreeMulligans = new javax.swing.JSpinner(); @@ -154,6 +155,9 @@ public class NewTableDialog extends MageDialog { chkSpectatorsAllowed.setText("Allow Spectators"); chkSpectatorsAllowed.setToolTipText("Allow spectators to watch.\n"); + chkPlaneChase.setText("Use PlaneChase"); + chkPlaneChase.setToolTipText("Use planechase variant (suitable for all game types).\n"); + chkRated.setText("Rated"); chkRated.setToolTipText("Indicates if matches will be rated."); @@ -236,7 +240,9 @@ public class NewTableDialog extends MageDialog { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(13, 13, 13) - .addComponent(chkSpectatorsAllowed)) + .addComponent(chkSpectatorsAllowed) + .addGap(13, 13, 13) + .addComponent(chkPlaneChase)) .addGroup(layout.createSequentialGroup() .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -331,7 +337,8 @@ public class NewTableDialog extends MageDialog { .addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblFreeMulligans) .addComponent(chkRollbackTurnsAllowed) - .addComponent(chkSpectatorsAllowed)) + .addComponent(chkSpectatorsAllowed) + .addComponent(chkPlaneChase)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblGameType))) @@ -408,6 +415,7 @@ public class NewTableDialog extends MageDialog { options.setWinsNeeded((Integer) this.spnNumWins.getValue()); options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected()); options.setSpectatorsAllowed(chkSpectatorsAllowed.isSelected()); + options.setPlaneChase(chkPlaneChase.isSelected()); options.setRated(chkRated.isSelected()); options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue()); options.setPassword(this.txtPassword.getText()); @@ -671,6 +679,7 @@ public class NewTableDialog extends MageDialog { this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2"))); this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes")); this.chkSpectatorsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, "Yes").equals("Yes")); + this.chkPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, "No").equals("Yes")); this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes")); this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0"))); @@ -729,6 +738,7 @@ public class NewTableDialog extends MageDialog { PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No"); + PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio())); StringBuilder playerTypesString = new StringBuilder(); for (Object player : players) { @@ -754,6 +764,7 @@ public class NewTableDialog extends MageDialog { private javax.swing.JComboBox cbTimeLimit; private javax.swing.JCheckBox chkRollbackTurnsAllowed; private javax.swing.JCheckBox chkSpectatorsAllowed; + private javax.swing.JCheckBox chkPlaneChase; private javax.swing.JCheckBox chkRated; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java index eb621b01dce..ee7a329aee2 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -238,6 +238,7 @@ public class PreferencesDialog extends javax.swing.JDialog { public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins"; public static final String KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED = "newTableRollbackTurnsAllowed"; public static final String KEY_NEW_TABLE_SPECTATORS_ALLOWED = "newTableSpectatorsAllowed"; + public static final String KEY_NEW_TABLE_PLANECHASE = "newTablePlaneChase"; public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans"; public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile"; public static final String KEY_NEW_TABLE_RANGE = "newTableRange"; diff --git a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java index 70b69c26150..999ca0db409 100644 --- a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java @@ -24,8 +24,7 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. -*/ - + */ package mage.client.util; import java.util.List; @@ -44,7 +43,7 @@ public final class CardsViewUtil { public static CardsView convertSimple(SimpleCardsView view) { CardsView cards = new CardsView(); - for (SimpleCardView simple: view.values()) { + for (SimpleCardView simple : view.values()) { CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber()); Card card = cardInfo != null ? cardInfo.getMockCard() : null; if (card != null) { @@ -54,15 +53,14 @@ public final class CardsViewUtil { return cards; } - + public static CardsView convertSimple(SimpleCardsView view, Map loadedCards) { CardsView cards = new CardsView(); - for (SimpleCardView simple: view.values()) { + for (SimpleCardView simple : view.values()) { String key = simple.getExpansionSetCode() + '_' + simple.getCardNumber(); Card card = loadedCards.get(key); - if(card == null) - { + if (card == null) { CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber()); card = cardInfo != null ? cardInfo.getMockCard() : null; loadedCards.put(key, card); @@ -79,12 +77,15 @@ public final class CardsViewUtil { CardsView cards = new CardsView(); for (CommandObjectView commandObject : view) { - if(commandObject instanceof EmblemView ){ - CardView cardView = new CardView((EmblemView)commandObject); + if (commandObject instanceof EmblemView) { + CardView cardView = new CardView((EmblemView) commandObject); cards.put(commandObject.getId(), cardView); - } - else if(commandObject instanceof CommanderView ){ - cards.put(commandObject.getId(),(CommanderView)commandObject); + } else if (commandObject instanceof PlaneView) { + CardView cardView = null; + cardView = new CardView((PlaneView) commandObject); + cards.put(commandObject.getId(), cardView); + } else if (commandObject instanceof CommanderView) { + cards.put(commandObject.getId(), (CommanderView) commandObject); } } diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index 898915e6812..8349b60716f 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -768,6 +768,9 @@ public class CardView extends SimpleCardView { @Override public String getExpansionSetCode() { + if (expansionSetCode == null) { + expansionSetCode = ""; + } return expansionSetCode; } diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 4f1800c0bc8..6464095de5f 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -100,7 +100,8 @@ public class TableController { } else { controllerName = "System"; } - table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers()); + table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()), + options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers(), options.isPlaneChase()); chatId = ChatManager.instance.createChatSession("Match Table " + table.getId()); init(); } @@ -119,7 +120,8 @@ public class TableController { } else { controllerName = "System"; } - table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers()); + table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()), + options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers(), options.isPlaneChase()); chatId = ChatManager.instance.createChatSession("Tourn. table " + table.getId()); } @@ -615,6 +617,7 @@ public class TableController { GameOptions gameOptions = new GameOptions(); gameOptions.rollbackTurnsAllowed = match.getOptions().isRollbackTurnsAllowed(); gameOptions.bannedUsers = match.getOptions().getBannedUsers(); + gameOptions.planeChase = match.getOptions().isPlaneChase(); match.getGame().setGameOptions(gameOptions); GameManager.instance.createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId, gameOptions); String creator = null; diff --git a/Mage/src/main/java/mage/abilities/condition/common/MainPhaseStackEmptyCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MainPhaseStackEmptyCondition.java index 7973ffd2f48..ed50f9a2544 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MainPhaseStackEmptyCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MainPhaseStackEmptyCondition.java @@ -51,6 +51,6 @@ public enum MainPhaseStackEmptyCondition implements Condition { @Override public String toString() { - return "during the main phase and the stack is empty"; + return "during the main phase when the stack is empty"; } } diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 84d5600232c..ed19997ff58 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1074,7 +1074,7 @@ public abstract class GameImpl implements Game, Serializable { } // 20180408 - 901.5 - if (state.isPlaneChase()) { + if (gameOptions.planeChase) { addPlane(Plane.getRandomPlane(), null, getActivePlayerId()); } } diff --git a/Mage/src/main/java/mage/game/GameOptions.java b/Mage/src/main/java/mage/game/GameOptions.java index b9091f09065..81bf98babf1 100644 --- a/Mage/src/main/java/mage/game/GameOptions.java +++ b/Mage/src/main/java/mage/game/GameOptions.java @@ -50,5 +50,10 @@ public class GameOptions implements Serializable { * Names of users banned from participating in the game */ public Set bannedUsers = Collections.emptySet(); + + /** + * Use planechase variant + */ + public boolean planeChase = false; } diff --git a/Mage/src/main/java/mage/game/Table.java b/Mage/src/main/java/mage/game/Table.java index 8956a5c65af..fe9a7216e53 100644 --- a/Mage/src/main/java/mage/game/Table.java +++ b/Mage/src/main/java/mage/game/Table.java @@ -61,6 +61,7 @@ public class Table implements Serializable { private Tournament tournament; private TableRecorder recorder; private Set bannedUsernames; + private boolean isPlaneChase; @FunctionalInterface public interface TableRecorder { @@ -70,21 +71,21 @@ public class Table implements Serializable { protected TableEventSource tableEventSource = new TableEventSource(); - public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Tournament tournament, Set bannedUsernames) { - this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames); + public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Tournament tournament, Set bannedUsernames, boolean isPlaneChase) { + this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames, isPlaneChase); this.tournament = tournament; this.isTournament = true; setState(TableState.WAITING); } - public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Match match, Set bannedUsernames) { - this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames); + public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Match match, Set bannedUsernames, boolean isPlaneChase) { + this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames, isPlaneChase); this.match = match; this.isTournament = false; setState(TableState.WAITING); } - protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Set bannedUsernames) { + protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List playerTypes, TableRecorder recorder, Set bannedUsernames, boolean isPlaneChase) { tableId = UUID.randomUUID(); this.roomId = roomId; this.numSeats = playerTypes.size(); @@ -96,6 +97,7 @@ public class Table implements Serializable { this.validator = validator; this.recorder = recorder; this.bannedUsernames = new HashSet<>(bannedUsernames); + this.isPlaneChase = isPlaneChase; } private void createSeats(List playerTypes) { diff --git a/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java b/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java index 93f66eeb1e2..f2b6d4ba507 100644 --- a/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java @@ -59,13 +59,12 @@ import mage.watchers.common.PlanarRollWatcher; public class FeedingGroundsPlane extends Plane { private static final FilterCard filter = new FilterCard("Red spells or Green spells"); - private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("Red or Green creature"); + private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("a creature"); static { filter.add(Predicates.or( new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.GREEN))); - filter2.add(Predicates.or(new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.GREEN))); } private static final String rule = "put X +1/+1 counters on target creature, where X is that creature's converted mana cost"; diff --git a/Mage/src/main/java/mage/game/match/MatchOptions.java b/Mage/src/main/java/mage/game/match/MatchOptions.java index e0dbb153fa5..48a7e438a4d 100644 --- a/Mage/src/main/java/mage/game/match/MatchOptions.java +++ b/Mage/src/main/java/mage/game/match/MatchOptions.java @@ -61,6 +61,7 @@ public class MatchOptions implements Serializable { protected SkillLevel skillLevel; protected boolean rollbackTurnsAllowed; protected boolean spectatorsAllowed; + protected boolean planeChase; protected int quitRatio; protected int edhPowerLevel; protected boolean rated; @@ -213,6 +214,14 @@ public class MatchOptions implements Serializable { public void setSpectatorsAllowed(boolean spectatorsAllowed) { this.spectatorsAllowed = spectatorsAllowed; } + + public boolean isPlaneChase() { + return planeChase; + } + + public void setPlaneChase(boolean planeChase) { + this.planeChase = planeChase; + } public int getQuitRatio() { return quitRatio; diff --git a/Mage/src/main/java/mage/game/tournament/TournamentOptions.java b/Mage/src/main/java/mage/game/tournament/TournamentOptions.java index 4140eedec71..2ffa2a6acc3 100644 --- a/Mage/src/main/java/mage/game/tournament/TournamentOptions.java +++ b/Mage/src/main/java/mage/game/tournament/TournamentOptions.java @@ -46,6 +46,7 @@ public class TournamentOptions implements Serializable { protected MatchOptions matchOptions; protected LimitedOptions limitedOptions; protected boolean watchingAllowed = true; + protected boolean planeChase = false; protected int numberRounds; protected String password; protected int quitRatio; @@ -91,6 +92,14 @@ public class TournamentOptions implements Serializable { this.watchingAllowed = watchingAllowed; } + public boolean isPlaneChase() { + return planeChase; + } + + public void setPlaneChase(boolean planeChase) { + this.planeChase = planeChase; + } + public int getNumberRounds() { return numberRounds; }