mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
spjspj - Implement a 'Use the first available mana ability for a land mode'.
This allows people to float mana more easily and to not have to get the popup forcing them to select which mana ability they would like to activate. There's a new option in the menu system under the Mana Payment section which is set via pressing 'Alt' and the number '1' key (aka Alt+1) (and is unset by releasing Alt+1). Or they can set it from the right click menu as well.
This commit is contained in:
parent
65b2d0f9fe
commit
e5ca1bd6d2
10 changed files with 115 additions and 10 deletions
|
@ -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")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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,11 +283,29 @@ 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("<html>Use the first mana ability when<br>"
|
||||
+ " tapping lands for mana<br>"
|
||||
+ "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");
|
||||
automaticConfirmsMenu.setMnemonic(KeyEvent.VK_U);
|
||||
popupMenu.add(automaticConfirmsMenu);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
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())) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -349,6 +349,8 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted);
|
||||
|
||||
void setUseFirstManaAbility(UUID playerId, boolean useFirstManaAbility);
|
||||
|
||||
void undo(UUID playerId);
|
||||
|
||||
void emptyManaPools();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 "";
|
||||
|
|
Loading…
Reference in a new issue