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 ca80f4c160..d5c84568dd 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -154,6 +154,7 @@ public class PreferencesDialog extends javax.swing.JDialog { public static final String KEY_PASS_PRIORITY_CAST = "passPriorityCast"; public static final String KEY_PASS_PRIORITY_ACTIVATION = "passPriorityActivation"; public static final String KEY_AUTO_ORDER_TRIGGER = "autoOrderTrigger"; + public static final String KEY_USE_FIRST_MANA_ABILITY = "useFirstManaAbility"; // mana auto payment public static final String KEY_GAME_MANA_AUTOPAYMENT = "gameManaAutopayment"; @@ -3273,7 +3274,8 @@ public class PreferencesDialog extends javax.swing.JDialog { PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PASS_PRIORITY_CAST, "true").equals("true"), PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PASS_PRIORITY_ACTIVATION, "true").equals("true"), - PreferencesDialog.getCachedValue(PreferencesDialog.KEY_AUTO_ORDER_TRIGGER, "true").equals("true") + PreferencesDialog.getCachedValue(PreferencesDialog.KEY_AUTO_ORDER_TRIGGER, "true").equals("true"), + PreferencesDialog.getCachedValue(PreferencesDialog.KEY_USE_FIRST_MANA_ABILITY, "true").equals("true") ); } diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index d062ed5d76..b4c405eb36 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -129,6 +129,7 @@ import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST; import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST; import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST; import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL; +import mage.constants.UseFirstManaAbilityMode; import mage.constants.Zone; import mage.game.events.PlayerQueryEvent; import mage.remote.Session; @@ -594,7 +595,9 @@ public final class GamePanel extends javax.swing.JPanel { // default menu states setMenuStates( PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), - PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true")); + PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), + PreferencesDialog.getCachedValue(PreferencesDialog.KEY_USE_FIRST_MANA_ABILITY, "true").equals("true") + ); updateGame(game); } @@ -893,10 +896,11 @@ public final class GamePanel extends javax.swing.JPanel { * * @param manaPoolAutomatic * @param manaPoolAutomaticRestricted + * @param useFirstManaAbility */ - public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) { + public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted, boolean useFirstManaAbility) { for (PlayAreaPanel playAreaPanel : players.values()) { - playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted); + playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted, useFirstManaAbility); } } @@ -1589,6 +1593,19 @@ public final class GamePanel extends javax.swing.JPanel { } }); + KeyStroke ksAlt1 = KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK); + this.getInputMap(c).put(ksAlt1, "USEFIRSTMANAABILITY"); + this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + session.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null); + setMenuStates( + PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), + PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), + true); + } + }); + final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI(); final BasicSplitPaneDivider divider = myUi.getDivider(); final JButton upArrowButton = (JButton) divider.getComponent(0); @@ -1619,6 +1636,19 @@ public final class GamePanel extends javax.swing.JPanel { } }); + KeyStroke ksAlt1Released = KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK, true); + this.getInputMap(c).put(ksAlt1Released, "USEFIRSTMANAABILITY_RELEASE"); + this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + session.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null); + setMenuStates( + PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"), + PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"), + false); + } + }); + btnSwitchHands.setContentAreaFilled(false); btnSwitchHands.setBorder(new EmptyBorder(0, 0, 0, 0)); btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSwitchHandsButtonImage())); diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 0f1c215e28..8d6627eaf2 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -54,6 +54,7 @@ import mage.client.dialog.PreferencesDialog; import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS; import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT; import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE; +import static mage.client.dialog.PreferencesDialog.KEY_USE_FIRST_MANA_ABILITY; import mage.client.util.GUISizeHelper; import mage.constants.PlayerAction; import mage.view.PlayerView; @@ -75,6 +76,7 @@ public class PlayAreaPanel extends javax.swing.JPanel { private JCheckBoxMenuItem manaPoolMenuItem1; private JCheckBoxMenuItem manaPoolMenuItem2; + private JCheckBoxMenuItem useFirstManaAbilityItem; private JCheckBoxMenuItem allowViewHandCardsMenuItem; public static final int PANEL_HEIGHT = 242; @@ -263,7 +265,7 @@ public class PlayAreaPanel extends javax.swing.JPanel { public void actionPerformed(ActionEvent e) { boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState(); PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false"); - gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState()); + gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState()); gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null); } }); @@ -281,9 +283,27 @@ public class PlayAreaPanel extends javax.swing.JPanel { public void actionPerformed(ActionEvent e) { boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState(); PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false"); - gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted); + gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState()); gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null); } + }); + + useFirstManaAbilityItem = new JCheckBoxMenuItem("Use first mana ability when tapping lands", false); + useFirstManaAbilityItem.setMnemonic(KeyEvent.VK_F); + useFirstManaAbilityItem.setToolTipText("Use the first mana ability when
" + + " tapping lands for mana
" + + "You can hold Alt+1 whilst tapping lands to use this feature"); + manaPoolMenu.add(useFirstManaAbilityItem); + + // Use first mana ability of lands + useFirstManaAbilityItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState(); + PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false"); + gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility); + gamePanel.getSession().sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON: PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null); + } }); JMenu automaticConfirmsMenu = new JMenu("Automatic confirms"); @@ -610,13 +630,16 @@ public class PlayAreaPanel extends javax.swing.JPanel { this.playingMode = playingMode; } - public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) { + public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted, boolean useFirstManaAbility) { if (manaPoolMenuItem1 != null) { manaPoolMenuItem1.setSelected(manaPoolAutomatic); } if (manaPoolMenuItem2 != null) { manaPoolMenuItem2.setSelected(manaPoolAutomaticRestricted); } + if (useFirstManaAbilityItem != null) { + useFirstManaAbilityItem.setSelected(useFirstManaAbility); + } } private mage.client.game.BattlefieldPanel battlefieldPanel; diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index e8ebf4ce6d..2cd3826209 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -59,6 +59,7 @@ import mage.cards.decks.Deck; import mage.choices.Choice; import mage.choices.ChoiceImpl; import mage.constants.AbilityType; +import mage.constants.CardType; import mage.constants.Constants; import mage.constants.ManaType; import mage.constants.Outcome; @@ -1249,7 +1250,15 @@ public class HumanPlayer extends PlayerImpl { return; } } - game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(abilities.values())); + if (userData.isUseFirstManaAbility() && object instanceof Permanent && object.getCardType().contains(CardType.LAND)){ + ActivatedAbility ability = abilities.values().iterator().next(); + if (ability instanceof ManaAbility) { + activateAbility(ability, game); + return; + } + } else { + game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(abilities.values())); + } waitForResponse(game); if (response.getUUID() != null && isInGame()) { if (abilities.containsKey(response.getUUID())) { diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 07a5763a51..9fb6c6492d 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -556,6 +556,12 @@ public class GameController implements GameCallback { case MANA_AUTO_PAYMENT_RESTRICTED_ON: game.setManaPaymentModeRestricted(getPlayerId(userId), true); break; + case USE_FIRST_MANA_ABILITY_ON: + game.setUseFirstManaAbility(getPlayerId(userId), true); + break; + case USE_FIRST_MANA_ABILITY_OFF: + game.setUseFirstManaAbility(getPlayerId(userId), false); + break; case ADD_PERMISSION_TO_SEE_HAND_CARDS: if (data instanceof UUID) { UUID playerId = getPlayerId(userId); diff --git a/Mage/src/main/java/mage/constants/PlayerAction.java b/Mage/src/main/java/mage/constants/PlayerAction.java index 5568ac2f55..5f920906f8 100644 --- a/Mage/src/main/java/mage/constants/PlayerAction.java +++ b/Mage/src/main/java/mage/constants/PlayerAction.java @@ -53,6 +53,8 @@ public enum PlayerAction { MANA_AUTO_PAYMENT_OFF, MANA_AUTO_PAYMENT_RESTRICTED_ON, MANA_AUTO_PAYMENT_RESTRICTED_OFF, + USE_FIRST_MANA_ABILITY_ON, + USE_FIRST_MANA_ABILITY_OFF, RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, REQUEST_PERMISSION_TO_SEE_HAND_CARDS, diff --git a/Mage/src/main/java/mage/constants/UseFirstManaAbilityMode.java b/Mage/src/main/java/mage/constants/UseFirstManaAbilityMode.java new file mode 100644 index 0000000000..2e56c7ba6c --- /dev/null +++ b/Mage/src/main/java/mage/constants/UseFirstManaAbilityMode.java @@ -0,0 +1,12 @@ +package mage.constants; + +/** + * Allows user to either tap a land for the first mode directly (shortcut) + * or have the normal method which pops up a menu + * + * @author spjspj + */ +public enum UseFirstManaAbilityMode { + + NORMAL, FIRST +} diff --git a/Mage/src/main/java/mage/game/Game.java b/Mage/src/main/java/mage/game/Game.java index 3e44fb3657..700865fd27 100644 --- a/Mage/src/main/java/mage/game/Game.java +++ b/Mage/src/main/java/mage/game/Game.java @@ -348,6 +348,8 @@ public interface Game extends MageItem, Serializable { void setManaPaymentMode(UUID playerId, boolean autoPayment); void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted); + + void setUseFirstManaAbility(UUID playerId, boolean useFirstManaAbility); void undo(UUID playerId); diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index debe5347a1..e38d98857e 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1238,6 +1238,14 @@ public abstract class GameImpl implements Game, Serializable { } } + @Override + public synchronized void setUseFirstManaAbility(UUID playerId, boolean useFirstManaAbility) { + Player player = state.getPlayer(playerId); + if (player != null) { + player.getUserData().setUseFirstManaAbility(useFirstManaAbility); + } + } + @Override public void playPriority(UUID activePlayerId, boolean resuming) { int errorContinueCounter = 0; diff --git a/Mage/src/main/java/mage/players/net/UserData.java b/Mage/src/main/java/mage/players/net/UserData.java index 865ad606e9..2bf542a352 100644 --- a/Mage/src/main/java/mage/players/net/UserData.java +++ b/Mage/src/main/java/mage/players/net/UserData.java @@ -22,6 +22,7 @@ public class UserData implements Serializable { protected boolean passPriorityCast; protected boolean passPriorityActivation; protected boolean autoOrderTrigger; + protected boolean useFirstManaAbility; protected String matchHistory; protected int matchQuitRatio; @@ -31,7 +32,7 @@ public class UserData implements Serializable { public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted, - boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger) { + boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger, boolean useFirstManaAbility) { this.groupId = userGroup.getGroupId(); this.avatarId = avatarId; this.showAbilityPickerForced = showAbilityPickerForced; @@ -45,6 +46,7 @@ public class UserData implements Serializable { this.passPriorityCast = passPriorityCast; this.passPriorityActivation = passPriorityActivation; this.autoOrderTrigger = autoOrderTrigger; + this.useFirstManaAbility = useFirstManaAbility; this.matchHistory = ""; this.matchQuitRatio = 0; this.tourneyHistory = ""; @@ -65,10 +67,11 @@ public class UserData implements Serializable { this.passPriorityCast = userData.passPriorityCast; this.passPriorityActivation = userData.passPriorityActivation; this.autoOrderTrigger = userData.autoOrderTrigger; + this.useFirstManaAbility = useFirstManaAbility; } public static UserData getDefaultUserDataView() { - return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, getDefaultFlagName(), false, true, true, false, false, false); + return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, getDefaultFlagName(), false, true, true, false, false, false, false); } public void setGroupId(int groupId) { @@ -175,6 +178,14 @@ public class UserData implements Serializable { this.autoOrderTrigger = autoOrderTrigger; } + public boolean isUseFirstManaAbility() { + return useFirstManaAbility; + } + + public void setUseFirstManaAbility(boolean useFirstManaAbility) { + this.useFirstManaAbility = useFirstManaAbility; + } + public String getHistory() { if (UserGroup.COMPUTER.equals(this.groupId)) { return "";