mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
* Changed handling of phases to stop to server based handling.
This commit is contained in:
parent
e6d2bce95d
commit
f3ea64e27c
19 changed files with 221 additions and 176 deletions
|
@ -714,6 +714,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
connection.setProxyPassword(proxyPassword);
|
||||
connection.setAvatarId(avatarId);
|
||||
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
||||
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
|
||||
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
|
||||
if (MageFrame.connect(connection)) {
|
||||
showGames(false);
|
||||
|
|
|
@ -310,6 +310,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setAvatarId(avatarId);
|
||||
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
|
||||
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
||||
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
|
||||
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
|
||||
task = new ConnectTask();
|
||||
task.execute();
|
||||
|
|
|
@ -499,7 +499,7 @@
|
|||
<Component id="panelCardImages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelBackgroundImages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="54" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
|
@ -62,10 +62,10 @@ import javax.swing.filechooser.FileFilter;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
@ -104,9 +104,26 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled";
|
||||
|
||||
|
||||
// Size of frame to check if divider locations should be used
|
||||
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
||||
// Phases
|
||||
public static String UPKEEP_YOU = "upkeepYou";
|
||||
public static String DRAW_YOU = "drawYou";
|
||||
public static String MAIN_YOU = "mainYou";
|
||||
public static String BEFORE_COMBAT_YOU = "beforeCombatYou";
|
||||
public static String END_OF_COMBAT_YOU = "endOfCombatYou";
|
||||
public static String MAIN_2_YOU = "main2You";
|
||||
public static String END_OF_TURN_YOU = "endOfTurnYou";
|
||||
|
||||
public static String UPKEEP_OTHERS = "upkeepOthers";
|
||||
public static String DRAW_OTHERS = "drawOthers";
|
||||
public static String MAIN_OTHERS = "mainOthers";
|
||||
public static String BEFORE_COMBAT_OTHERS = "beforeCombatOthers";
|
||||
public static String END_OF_COMBAT_OTHERS = "endOfCombatOthers";
|
||||
public static String MAIN_2_OTHERS = "main2Others";
|
||||
public static String END_OF_TURN_OTHERS = "endOfTurnOthers";
|
||||
|
||||
// Size of frame to check if divider locations should be used
|
||||
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
||||
|
||||
// positions of divider bars
|
||||
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
|
||||
public static final String KEY_TABLES_DIVIDER_LOCATION_2 = "tablePanelDividerLocation2";
|
||||
|
@ -188,7 +205,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab";
|
||||
|
||||
|
||||
public static String PHASE_ON = "on";
|
||||
public static String PHASE_OFF = "off";
|
||||
|
||||
public static final int DEFAULT_AVATAR_ID = 51;
|
||||
private static int selectedAvatarId = DEFAULT_AVATAR_ID;
|
||||
|
@ -1355,21 +1373,21 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
|
||||
// Phases
|
||||
save(prefs, dialog.checkBoxUpkeepYou, PhaseManager.UPKEEP_YOU);
|
||||
save(prefs, dialog.checkBoxDrawYou, PhaseManager.DRAW_YOU);
|
||||
save(prefs, dialog.checkBoxMainYou, PhaseManager.MAIN_YOU);
|
||||
save(prefs, dialog.checkBoxBeforeCYou, PhaseManager.BEFORE_COMBAT_YOU);
|
||||
save(prefs, dialog.checkBoxEndOfCYou, PhaseManager.END_OF_COMBAT_YOU);
|
||||
save(prefs, dialog.checkBoxMain2You, PhaseManager.MAIN_2_YOU);
|
||||
save(prefs, dialog.checkBoxEndTurnYou, PhaseManager.END_OF_TURN_YOU);
|
||||
save(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU);
|
||||
save(prefs, dialog.checkBoxDrawYou, DRAW_YOU);
|
||||
save(prefs, dialog.checkBoxMainYou, MAIN_YOU);
|
||||
save(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU);
|
||||
save(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU);
|
||||
save(prefs, dialog.checkBoxMain2You, MAIN_2_YOU);
|
||||
save(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU);
|
||||
|
||||
save(prefs, dialog.checkBoxUpkeepOthers, PhaseManager.UPKEEP_OTHERS);
|
||||
save(prefs, dialog.checkBoxDrawOthers, PhaseManager.DRAW_OTHERS);
|
||||
save(prefs, dialog.checkBoxMainOthers, PhaseManager.MAIN_OTHERS);
|
||||
save(prefs, dialog.checkBoxBeforeCOthers, PhaseManager.BEFORE_COMBAT_OTHERS);
|
||||
save(prefs, dialog.checkBoxEndOfCOthers, PhaseManager.END_OF_COMBAT_OTHERS);
|
||||
save(prefs, dialog.checkBoxMain2Others, PhaseManager.MAIN_2_OTHERS);
|
||||
save(prefs, dialog.checkBoxEndTurnOthers, PhaseManager.END_OF_TURN_OTHERS);
|
||||
save(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS);
|
||||
save(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS);
|
||||
save(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS);
|
||||
save(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS);
|
||||
save(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS);
|
||||
save(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
|
||||
save(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
|
||||
|
||||
// images
|
||||
save(prefs, dialog.cbUseDefaultImageFolder, KEY_CARD_IMAGES_USE_DEFAULT, "true", "false", UPDATE_CACHE_POLICY);
|
||||
|
@ -1408,7 +1426,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
try {
|
||||
MageFrame.getSession().updatePreferencesForServer(
|
||||
getSelectedAvatar(),
|
||||
dialog.showAbilityPickerForced.isSelected());
|
||||
dialog.showAbilityPickerForced.isSelected(),
|
||||
getUserSkipPrioritySteps());
|
||||
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException ex) {
|
||||
|
@ -1688,21 +1707,21 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private static void loadPhases(Preferences prefs) {
|
||||
load(prefs, dialog.checkBoxUpkeepYou, PhaseManager.UPKEEP_YOU);
|
||||
load(prefs, dialog.checkBoxDrawYou, PhaseManager.DRAW_YOU);
|
||||
load(prefs, dialog.checkBoxMainYou, PhaseManager.MAIN_YOU);
|
||||
load(prefs, dialog.checkBoxBeforeCYou, PhaseManager.BEFORE_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxEndOfCYou, PhaseManager.END_OF_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxMain2You, PhaseManager.MAIN_2_YOU);
|
||||
load(prefs, dialog.checkBoxEndTurnYou, PhaseManager.END_OF_TURN_YOU);
|
||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU);
|
||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU);
|
||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU);
|
||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU);
|
||||
load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU);
|
||||
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, PhaseManager.UPKEEP_OTHERS);
|
||||
load(prefs, dialog.checkBoxDrawOthers, PhaseManager.DRAW_OTHERS);
|
||||
load(prefs, dialog.checkBoxMainOthers, PhaseManager.MAIN_OTHERS);
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, PhaseManager.BEFORE_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, PhaseManager.END_OF_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxMain2Others, PhaseManager.MAIN_2_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, PhaseManager.END_OF_TURN_OTHERS);
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS);
|
||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS);
|
||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS);
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
|
||||
|
||||
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
|
||||
load(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true");
|
||||
|
@ -1824,6 +1843,31 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
return selectedAvatarId;
|
||||
}
|
||||
|
||||
public static UserSkipPrioritySteps getUserSkipPrioritySteps() {
|
||||
if (!dialog.isVisible()) {
|
||||
loadPhases(MageFrame.getPreferences());
|
||||
}
|
||||
UserSkipPrioritySteps userSkipPrioritySteps = new UserSkipPrioritySteps();
|
||||
|
||||
userSkipPrioritySteps.getYourTurn().setUpkeep(dialog.checkBoxUpkeepYou.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setDraw(dialog.checkBoxDrawYou.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setMain1(dialog.checkBoxMainYou.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setBeforeCombat(dialog.checkBoxBeforeCYou.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setEndOfCombat(dialog.checkBoxEndOfCYou.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setMain2(dialog.checkBoxMain2You.isSelected());
|
||||
userSkipPrioritySteps.getYourTurn().setEndOfTurn(dialog.checkBoxEndTurnYou.isSelected());
|
||||
|
||||
userSkipPrioritySteps.getOpponentTurn().setUpkeep(dialog.checkBoxUpkeepOthers.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setDraw(dialog.checkBoxDrawOthers.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setMain1(dialog.checkBoxMainOthers.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setBeforeCombat(dialog.checkBoxBeforeCOthers.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setEndOfCombat(dialog.checkBoxEndOfCOthers.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setMain2(dialog.checkBoxMain2Others.isSelected());
|
||||
userSkipPrioritySteps.getOpponentTurn().setEndOfTurn(dialog.checkBoxEndTurnOthers.isSelected());
|
||||
|
||||
return userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
private static void openTab(int index) {
|
||||
try {
|
||||
if (index > 0) {
|
||||
|
@ -1885,11 +1929,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private static void load(Preferences prefs, JCheckBox checkBox, String propName) {
|
||||
load(prefs, checkBox, propName, PhaseManager.PHASE_ON);
|
||||
load(prefs, checkBox, propName, PHASE_ON);
|
||||
}
|
||||
|
||||
private static void save(Preferences prefs, JCheckBox checkBox, String propName) {
|
||||
save(prefs, checkBox, propName, PhaseManager.PHASE_ON, PhaseManager.PHASE_OFF, false);
|
||||
save(prefs, checkBox, propName, PHASE_ON, PHASE_OFF, false);
|
||||
}
|
||||
|
||||
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String noValue, boolean updateCache) {
|
||||
|
@ -2000,7 +2044,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public void mousePressed(MouseEvent e) {
|
||||
if (selectedAvatarId != id) {
|
||||
setSelectedId(id);
|
||||
MageFrame.getSession().updatePreferencesForServer(id, PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"));
|
||||
MageFrame.getSession().updatePreferencesForServer(
|
||||
id,
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
|
||||
getUserSkipPrioritySteps());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -44,7 +44,6 @@ import mage.client.plugins.impl.Plugins;
|
|||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.Constants;
|
||||
import mage.constants.EnlargeMode;
|
||||
|
@ -735,13 +734,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
||||
if (PhaseManager.getInstance().isSkip(gameView, message)) {
|
||||
this.feedbackPanel.doClick();
|
||||
logger.debug(new StringBuilder("Phase skipped: ").append(message).append(" id: ").append(messageId));
|
||||
} else {
|
||||
logger.debug(new StringBuilder("Phase not skipped: ").append(message).append(" id: ").append(messageId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void playMana(String message, GameView gameView, int messageId) {
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.prefs.Preferences;
|
||||
import mage.client.MageFrame;
|
||||
import mage.view.GameView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class PhaseManager {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(PhaseManager.class);
|
||||
|
||||
private static final PhaseManager fInstance = new PhaseManager();
|
||||
|
||||
public static String DEFAULT_PLAYER_NAME = "player";
|
||||
|
||||
public static String PHASE_ON = "on";
|
||||
public static String PHASE_OFF = "off";
|
||||
public static String UPKEEP_YOU = "upkeepYou";
|
||||
public static String DRAW_YOU = "drawYou";
|
||||
public static String MAIN_YOU = "mainYou";
|
||||
public static String BEFORE_COMBAT_YOU = "beforeCombatYou";
|
||||
public static String END_OF_COMBAT_YOU = "endOfCombatYou";
|
||||
public static String MAIN_2_YOU = "main2You";
|
||||
public static String END_OF_TURN_YOU = "endOfTurnYou";
|
||||
|
||||
public static String UPKEEP_OTHERS = "upkeepOthers";
|
||||
public static String DRAW_OTHERS = "drawOthers";
|
||||
public static String MAIN_OTHERS = "mainOthers";
|
||||
public static String BEFORE_COMBAT_OTHERS = "beforeCombatOthers";
|
||||
public static String END_OF_COMBAT_OTHERS = "endOfCombatOthers";
|
||||
public static String MAIN_2_OTHERS = "main2Others";
|
||||
public static String END_OF_TURN_OTHERS = "endOfTurnOthers";
|
||||
|
||||
private static final Preferences prefs = MageFrame.getPreferences();
|
||||
|
||||
private static final Map<String, String> mapYou = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_YOU);
|
||||
put("Draw - play instants and activated abilities.", DRAW_YOU);
|
||||
put("Precombat Main - play spells and abilities.", MAIN_YOU);
|
||||
put("Begin Combat - play instants and activated abilities.", BEFORE_COMBAT_YOU);
|
||||
put("End Combat - play instants and activated abilities.", END_OF_COMBAT_YOU);
|
||||
put("Postcombat Main - play spells and abilities.", MAIN_2_YOU);
|
||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_YOU);
|
||||
}};
|
||||
|
||||
private static final Map<String, String> mapOthers = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_OTHERS);
|
||||
put("Draw - play instants and activated abilities.", DRAW_OTHERS);
|
||||
put("Precombat Main - play instants and activated abilities.", MAIN_OTHERS);
|
||||
put("Begin Combat - play instants and activated abilities.", BEFORE_COMBAT_OTHERS);
|
||||
put("End Combat - play instants and activated abilities.", END_OF_COMBAT_OTHERS);
|
||||
put("Postcombat Main - play instants and activated abilities.", MAIN_2_OTHERS);
|
||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||
}};
|
||||
|
||||
public static PhaseManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public boolean isSkip(GameView gameView, String message) {
|
||||
// no skipping if stack is not empty
|
||||
if (GameManager.getInstance().getStackSize() > 0) {
|
||||
return false;
|
||||
}
|
||||
if (gameView.getActivePlayerId() == null) {
|
||||
throw new IllegalStateException("No active player found.");
|
||||
}
|
||||
String prefKey;
|
||||
if (gameView.getActivePlayerId().equals(GameManager.getInstance().getCurrentPlayerUUID())) {
|
||||
prefKey = mapYou.get(message);
|
||||
} else {
|
||||
prefKey = mapOthers.get(message);
|
||||
}
|
||||
if (prefKey != null) {
|
||||
String prop = prefs.get(prefKey, PHASE_ON);
|
||||
return !prop.equals(PHASE_ON);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ import java.net.InterfaceAddress;
|
|||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,6 +54,7 @@ public class Connection {
|
|||
|
||||
private int avatarId;
|
||||
private boolean showAbilityPickerForced;
|
||||
private UserSkipPrioritySteps userSkipPrioritySteps;
|
||||
|
||||
private static final String serialization = "?serializationtype=jboss";
|
||||
private static final String transport = "bisocket";
|
||||
|
@ -219,4 +221,12 @@ public class Connection {
|
|||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
}
|
||||
|
||||
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
|
||||
return userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
public void setUserSkipPrioritySteps(UserSkipPrioritySteps userSkipPrioritySteps) {
|
||||
this.userSkipPrioritySteps = userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,16 @@
|
|||
|
||||
package mage.remote;
|
||||
|
||||
import mage.remote.interfaces.*;
|
||||
import mage.remote.interfaces.ChatSession;
|
||||
import mage.remote.interfaces.ClientData;
|
||||
import mage.remote.interfaces.Connect;
|
||||
import mage.remote.interfaces.Feedback;
|
||||
import mage.remote.interfaces.GamePlay;
|
||||
import mage.remote.interfaces.GameTypes;
|
||||
import mage.remote.interfaces.PlayerActions;
|
||||
import mage.remote.interfaces.Replays;
|
||||
import mage.remote.interfaces.ServerState;
|
||||
import mage.remote.interfaces.Testable;
|
||||
|
||||
/**
|
||||
* Extracted interface for SessionImpl class.
|
||||
|
|
|
@ -60,6 +60,7 @@ import mage.interfaces.MageServer;
|
|||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.MatchView;
|
||||
|
@ -270,7 +271,9 @@ public class SessionImpl implements Session {
|
|||
this.sessionId = callbackClient.getSessionId();
|
||||
boolean registerResult;
|
||||
if (connection.getPassword() == null) {
|
||||
UserDataView userDataView = new UserDataView(connection.getAvatarId(), connection.isShowAbilityPickerForced());
|
||||
UserDataView userDataView = new UserDataView(connection.getAvatarId(),
|
||||
connection.isShowAbilityPickerForced(),
|
||||
connection.getUserSkipPrioritySteps());
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion());
|
||||
if (registerResult) {
|
||||
|
@ -1303,10 +1306,10 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced) {
|
||||
public boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, UserSkipPrioritySteps userSkipPrioritySteps) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
UserDataView userDataView = new UserDataView(avatarId, showAbilityPickerForced);
|
||||
UserDataView userDataView = new UserDataView(avatarId, showAbilityPickerForced, userSkipPrioritySteps);
|
||||
server.setUserData(connection.getUsername(), sessionId, userDataView);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.remote.interfaces;
|
||||
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
|
@ -34,5 +36,5 @@ public interface ClientData {
|
|||
|
||||
String getUserName();
|
||||
|
||||
boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced);
|
||||
boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, UserSkipPrioritySteps userSkipPrioritySteps);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class PlayerView implements Serializable {
|
|||
if (player.getUserData() != null) {
|
||||
this.userDataView = new UserDataView(player.getUserData());
|
||||
} else {
|
||||
this.userDataView = new UserDataView(0, false);
|
||||
this.userDataView = new UserDataView(0, false, null);
|
||||
}
|
||||
|
||||
for (CommandObject commandObject : game.getState().getCommand()) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package mage.view;
|
|||
import mage.players.net.UserData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
|
||||
/**
|
||||
* Transfer object for {@link mage.players.net.UserData}
|
||||
|
@ -14,10 +15,12 @@ public class UserDataView implements Serializable {
|
|||
protected int avatarId;
|
||||
protected int userGroup;
|
||||
protected boolean showAbilityPickerForced;
|
||||
protected UserSkipPrioritySteps userSkipPrioritySteps;
|
||||
|
||||
public UserDataView(int avatarId, boolean showAbilityPickerForced) {
|
||||
public UserDataView(int avatarId, boolean showAbilityPickerForced, UserSkipPrioritySteps userSkipPrioritySteps) {
|
||||
this.avatarId = avatarId;
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
this.userSkipPrioritySteps = userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
public UserDataView(UserData userData) {
|
||||
|
@ -32,5 +35,9 @@ public class UserDataView implements Serializable {
|
|||
public boolean isShowAbilityPickerForced() {
|
||||
return showAbilityPickerForced;
|
||||
}
|
||||
|
||||
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
|
||||
return userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
public ComputerPlayer(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
human = false;
|
||||
userData = new UserData(UserGroup.COMPUTER, 64, false);
|
||||
userData = new UserData(UserGroup.COMPUTER, 64, false, null);
|
||||
pickedCards = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
@Override
|
||||
public Mode chooseMode(Modes modes, Ability source, Game game) {
|
||||
log.debug("chooseMode");
|
||||
if (modes.getMode() != null) {
|
||||
if (modes.getMode() != null && modes.getMaxModes() == modes.getSelectedModes().size()) {
|
||||
// mode was already set by the AI
|
||||
return modes.getMode();
|
||||
}
|
||||
|
|
|
@ -449,6 +449,11 @@ public class HumanPlayer extends PlayerImpl {
|
|||
pass(game);
|
||||
return false;
|
||||
}
|
||||
if (checkPassStep(game) && game.getStack().isEmpty()) {
|
||||
pass(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
updateGameStatePriority("priority", game);
|
||||
game.firePriorityEvent(playerId);
|
||||
waitForResponse(game);
|
||||
|
@ -490,6 +495,14 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean checkPassStep(Game game) {
|
||||
if (game.getActivePlayerId().equals(playerId)) {
|
||||
return !this.getUserData().getUserSkipPrioritySteps().getYourTurn().isPhaseStepSet(game.getStep().getType());
|
||||
} else {
|
||||
return !this.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) {
|
||||
updateGameStatePriority("chooseTriggeredAbility", game);
|
||||
|
@ -558,7 +571,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
game.fireGetAmountEvent(playerId, message, min, max);
|
||||
waitForIntegerResponse(game);
|
||||
if (response != null && response.getInteger() != null) {
|
||||
xValue = response.getInteger().intValue();
|
||||
xValue = response.getInteger();
|
||||
}
|
||||
return xValue;
|
||||
}
|
||||
|
@ -570,7 +583,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
game.fireGetAmountEvent(playerId, message, min, max);
|
||||
waitForIntegerResponse(game);
|
||||
if (response != null && response.getInteger() != null) {
|
||||
xValue = response.getInteger().intValue();
|
||||
xValue = response.getInteger();
|
||||
}
|
||||
return xValue;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class Session {
|
|||
if (user == null) {
|
||||
user = UserManager.getInstance().findUser("Admin");
|
||||
}
|
||||
user.setUserData(new UserData(UserGroup.ADMIN, 0, false));
|
||||
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, null));
|
||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||
logger.info("Error connecting Admin!");
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class Session {
|
|||
if (user != null) {
|
||||
UserData userData = user.getUserData();
|
||||
if (userData == null) {
|
||||
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(), userDataView.isShowAbilityPickerForced());
|
||||
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(), userDataView.isShowAbilityPickerForced(), userDataView.getUserSkipPrioritySteps());
|
||||
user.setUserData(userData);
|
||||
} else {
|
||||
if (userDataView.getAvatarId() == 51) { // Update special avatar if first avatar is selected
|
||||
|
@ -153,6 +153,7 @@ public class Session {
|
|||
}
|
||||
userData.setAvatarId(userDataView.getAvatarId());
|
||||
userData.setShowAbilityPickerForced(userDataView.isShowAbilityPickerForced());
|
||||
userData.setUserSkipPrioritySteps(userDataView.getUserSkipPrioritySteps());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@ import mage.abilities.costs.AdjustingSourceCosts;
|
|||
import mage.abilities.costs.AlternativeCost;
|
||||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.effects.RestrictionUntapNotMoreThanEffect;
|
||||
import mage.abilities.effects.common.LoseControlOnOtherPlayersControllerEffect;
|
||||
|
@ -1977,7 +1980,25 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (alternateSourceCostsAbility instanceof AlternativeSourceCosts) {
|
||||
if (((AlternativeSourceCosts)alternateSourceCostsAbility).isAvailable(ability, game)) {
|
||||
if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) {
|
||||
return true;
|
||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||
for(Cost cost:alternateSourceCostsAbility.getCosts()) {
|
||||
if (cost instanceof ManaCost) {
|
||||
manaCosts.add(cost);
|
||||
}
|
||||
}
|
||||
|
||||
if (manaCosts.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (Mana mana: manaCosts.getOptions()) {
|
||||
for (Mana avail: available) {
|
||||
if (mana.enough(avail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.utils;
|
||||
package mage.players.net;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -95,6 +97,26 @@ public class SkipPrioritySteps {
|
|||
public void setEndOfTurn(boolean endOfTurn) {
|
||||
this.endOfTurn = endOfTurn;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPhaseStepSet(PhaseStep phaseStep) {
|
||||
switch(phaseStep) {
|
||||
case UPKEEP:
|
||||
return isUpkeep();
|
||||
case DRAW:
|
||||
return isDraw();
|
||||
case PRECOMBAT_MAIN:
|
||||
return isMain1();
|
||||
case BEGIN_COMBAT:
|
||||
return isBeforeCombat();
|
||||
case END_COMBAT:
|
||||
return isEndOfCombat();
|
||||
case POSTCOMBAT_MAIN:
|
||||
return isMain2();
|
||||
case END_TURN:
|
||||
return isEndOfTurn();
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -12,12 +12,13 @@ public class UserData implements Serializable {
|
|||
protected int groupId;
|
||||
protected int avatarId;
|
||||
protected boolean showAbilityPickerForced;
|
||||
protected String privateKey;
|
||||
protected UserSkipPrioritySteps userSkipPrioritySteps;
|
||||
|
||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced) {
|
||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced, UserSkipPrioritySteps userSkipPrioritySteps) {
|
||||
this.groupId = userGroup.getGroupId();
|
||||
this.avatarId = avatarId;
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
this.userSkipPrioritySteps = userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
|
@ -43,5 +44,13 @@ public class UserData implements Serializable {
|
|||
public void setShowAbilityPickerForced(boolean showAbilityPickerForced) {
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
}
|
||||
|
||||
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
|
||||
return userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
public void setUserSkipPrioritySteps(UserSkipPrioritySteps userSkipPrioritySteps) {
|
||||
this.userSkipPrioritySteps = userSkipPrioritySteps;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,13 +25,30 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.utils;
|
||||
package mage.players.net;
|
||||
|
||||
import mage.players.net.SkipPrioritySteps;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class UserSkipPrioritySteps {
|
||||
SkipPrioritySteps you;
|
||||
SkipPrioritySteps opponent;
|
||||
SkipPrioritySteps yourTurn;
|
||||
SkipPrioritySteps opponentTurn;
|
||||
|
||||
public UserSkipPrioritySteps() {
|
||||
yourTurn = new SkipPrioritySteps();
|
||||
opponentTurn = new SkipPrioritySteps();
|
||||
}
|
||||
|
||||
public SkipPrioritySteps getYourTurn() {
|
||||
return yourTurn;
|
||||
}
|
||||
|
||||
public SkipPrioritySteps getOpponentTurn() {
|
||||
return opponentTurn;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue