Closed #168 : Enhance priority hot keys

This commit is contained in:
magenoxx 2013-03-29 17:18:12 +04:00
parent a1e16942cd
commit 05191e8793
20 changed files with 475 additions and 151 deletions

View file

@ -34,18 +34,19 @@
package mage.client.chat; package mage.client.chat;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.components.ColorPane; import mage.client.components.ColorPane;
import mage.remote.Session; import mage.remote.Session;
import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageColor;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.List;
/** /**
* *
* @author BetaSteward_at_googlemail.com, nantuko * @author BetaSteward_at_googlemail.com, nantuko
@ -166,17 +167,26 @@ public class ChatPanel extends javax.swing.JPanel {
public void receiveMessage(String username, String message, String time, MessageColor color) { public void receiveMessage(String username, String message, String time, MessageColor color) {
if (extendedViewMode.equals(VIEW_MODE.GAME)) { if (extendedViewMode.equals(VIEW_MODE.GAME)) {
this.txtConversation.append(TIMESTAMP_COLOR, time + " "); this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
this.txtConversation.append(MESSAGE_COLOR, (username.isEmpty() ? "" : username + ":") + message + "\n"); Color textColor = MESSAGE_COLOR;
if (color.equals(MessageColor.ORANGE)) {
textColor = Color.ORANGE;
}
this.txtConversation.append(textColor, (username.isEmpty() ? "" : username + ":") + message + "\n");
} else { } else {
this.txtConversation.append(TIMESTAMP_COLOR, time + " "); this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
Color userColor; Color userColor;
Color textColor = MESSAGE_COLOR;
if (parentChatRef != null) { if (parentChatRef != null) {
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR; userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
} else { } else {
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR; userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
if (color.equals(MessageColor.ORANGE)) {
userColor = Color.ORANGE;
textColor = userColor;
}
} }
this.txtConversation.append(userColor, username + ": "); this.txtConversation.append(userColor, username + ": ");
this.txtConversation.append(MESSAGE_COLOR, message + "\n"); this.txtConversation.append(textColor, message + "\n");
} }
} }
@ -192,6 +202,14 @@ public class ChatPanel extends javax.swing.JPanel {
this.parentChatRef = parentChatRef; this.parentChatRef = parentChatRef;
} }
public ChatPanel getParentChatRef() {
return parentChatRef;
}
public void setParentChatRef(ChatPanel parentChatRef) {
this.parentChatRef = parentChatRef;
}
public void disableInput() { public void disableInput() {
this.txtMessage.setVisible(false); this.txtMessage.setVisible(false);
} }

View file

@ -23,9 +23,9 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" pref="439" max="32767" attributes="0"/> <Component id="jTabbedPane1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace pref="311" max="32767" attributes="0"/> <EmptySpace pref="316" max="32767" attributes="0"/>
<Component id="saveButton" min="-2" max="-2" attributes="0"/> <Component id="saveButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="exitButton" min="-2" pref="55" max="-2" attributes="0"/> <Component id="exitButton" min="-2" pref="55" max="-2" attributes="0"/>
@ -109,7 +109,7 @@
<Component id="showToolTipsInAnyZone" min="-2" max="-2" attributes="0"/> <Component id="showToolTipsInAnyZone" min="-2" max="-2" attributes="0"/>
<Component id="displayBigCardsInHand" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="displayBigCardsInHand" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="161" max="32767" attributes="0"/> <EmptySpace pref="166" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -163,7 +163,7 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" min="-2" max="-2" attributes="0"/> <Component id="nonLandPermanentsInOnePile" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="199" max="32767" attributes="0"/> <EmptySpace pref="204" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -261,7 +261,7 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace pref="100" max="32767" attributes="0"/> <EmptySpace pref="105" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -486,7 +486,7 @@
<Component id="saveToZipFiles" min="-2" max="-2" attributes="0"/> <Component id="saveToZipFiles" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="32767" attributes="0"/> <EmptySpace pref="15" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -548,6 +548,46 @@
</Container> </Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="jPanel22">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Sounds">
<Property name="tabTitle" type="java.lang.String" value="Sounds"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="jEnableSounds" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="325" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<Component id="jEnableSounds" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="217" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="jEnableSounds">
<Properties>
<Property name="text" type="java.lang.String" value="enable sounds"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEnableSoundsActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6"> <Container class="javax.swing.JPanel" name="jPanel6">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
@ -662,7 +702,7 @@
<Component id="txtPasswordField" alignment="0" max="32767" attributes="1"/> <Component id="txtPasswordField" alignment="0" max="32767" attributes="1"/>
<Component id="txtProxyUserName" alignment="0" min="-2" pref="148" max="-2" attributes="1"/> <Component id="txtProxyUserName" alignment="0" min="-2" pref="148" max="-2" attributes="1"/>
</Group> </Group>
<Component id="txtProxyServer" alignment="0" pref="295" max="32767" attributes="1"/> <Component id="txtProxyServer" alignment="0" pref="300" max="32767" attributes="1"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -770,7 +810,7 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="434" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" pref="439" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">

View file

@ -72,6 +72,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_CARD_IMAGES_CHECK = "cardImagesCheck"; public static final String KEY_CARD_IMAGES_CHECK = "cardImagesCheck";
public static final String KEY_CARD_IMAGES_SAVE_TO_ZIP = "cardImagesSaveToZip"; public static final String KEY_CARD_IMAGES_SAVE_TO_ZIP = "cardImagesSaveToZip";
public static final String KEY_SOUNDS_ON = "soundsOn";
public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled"; public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled";
public static final String KEY_GAMEPANEL_LAST_SIZE = "gamepanelLastSize"; public static final String KEY_GAMEPANEL_LAST_SIZE = "gamepanelLastSize";
@ -186,6 +188,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
browseButton = new javax.swing.JButton(); browseButton = new javax.swing.JButton();
checkForNewImages = new javax.swing.JCheckBox(); checkForNewImages = new javax.swing.JCheckBox();
saveToZipFiles = new javax.swing.JCheckBox(); saveToZipFiles = new javax.swing.JCheckBox();
jPanel22 = new javax.swing.JPanel();
jEnableSounds = new javax.swing.JCheckBox();
jPanel6 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel();
lblProxyType = new javax.swing.JLabel(); lblProxyType = new javax.swing.JLabel();
cbProxyType = new javax.swing.JComboBox(); cbProxyType = new javax.swing.JComboBox();
@ -250,7 +254,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(showToolTipsInAnyZone) .addComponent(showToolTipsInAnyZone)
.addComponent(displayBigCardsInHand)) .addComponent(displayBigCardsInHand))
.addContainerGap(161, Short.MAX_VALUE)) .addContainerGap(166, Short.MAX_VALUE))
); );
jPanel3Layout.setVerticalGroup( jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -278,7 +282,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(jPanel7Layout.createSequentialGroup() .addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(nonLandPermanentsInOnePile) .addComponent(nonLandPermanentsInOnePile)
.addContainerGap(199, Short.MAX_VALUE)) .addContainerGap(204, Short.MAX_VALUE))
); );
jPanel7Layout.setVerticalGroup( jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -380,7 +384,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1))) .addComponent(jLabel1)))
.addContainerGap(100, Short.MAX_VALUE)) .addContainerGap(105, Short.MAX_VALUE))
); );
jPanel2Layout.setVerticalGroup( jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -490,7 +494,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(saveToZipFiles))) .addComponent(saveToZipFiles)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(15, Short.MAX_VALUE))
); );
jPanel5Layout.setVerticalGroup( jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -527,6 +531,32 @@ public class PreferencesDialog extends javax.swing.JDialog {
jTabbedPane1.addTab("Images", jPanel4); jTabbedPane1.addTab("Images", jPanel4);
jEnableSounds.setText("enable sounds");
jEnableSounds.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jEnableSoundsActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
jPanel22.setLayout(jPanel22Layout);
jPanel22Layout.setHorizontalGroup(
jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel22Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jEnableSounds)
.addContainerGap(325, Short.MAX_VALUE))
);
jPanel22Layout.setVerticalGroup(
jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel22Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jEnableSounds)
.addContainerGap(217, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Sounds", jPanel22);
lblProxyType.setText("Proxy:"); lblProxyType.setText("Proxy:");
cbProxyType.addActionListener(new java.awt.event.ActionListener() { cbProxyType.addActionListener(new java.awt.event.ActionListener() {
@ -590,7 +620,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(pnlProxyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtPasswordField, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPasswordField, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtProxyUserName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtProxyUserName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtProxyServer, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)) .addComponent(txtProxyServer, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
pnlProxyLayout.setVerticalGroup( pnlProxyLayout.setVerticalGroup(
@ -905,7 +935,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
jPanel8.setLayout(jPanel8Layout); jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup( jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)
); );
jPanel8Layout.setVerticalGroup( jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -932,9 +962,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE) .addComponent(jTabbedPane1)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(311, Short.MAX_VALUE) .addContainerGap(316, Short.MAX_VALUE)
.addComponent(saveButton) .addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -985,6 +1015,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.checkForNewImages, KEY_CARD_IMAGES_CHECK, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.checkForNewImages, KEY_CARD_IMAGES_CHECK, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.saveToZipFiles, KEY_CARD_IMAGES_SAVE_TO_ZIP, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.saveToZipFiles, KEY_CARD_IMAGES_SAVE_TO_ZIP, "true", "false", UPDATE_CACHE_POLICY);
// sounds
save(prefs, dialog.jEnableSounds, KEY_SOUNDS_ON, "true", "false", UPDATE_CACHE_POLICY);
// connection // connection
save(prefs, dialog.cbProxyType, KEY_PROXY_TYPE); save(prefs, dialog.cbProxyType, KEY_PROXY_TYPE);
save(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS); save(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS);
@ -1002,8 +1035,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
updateCache(KEY_AVATAR, String.valueOf(selectedId)); updateCache(KEY_AVATAR, String.valueOf(selectedId));
} }
try { try {
prefs.flush(); prefs.flush();
} catch (BackingStoreException ex) { } catch (BackingStoreException ex) {
@ -1078,6 +1109,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here: // TODO add your handling code here:
}//GEN-LAST:event_checkForNewImagesActionPerformed }//GEN-LAST:event_checkForNewImagesActionPerformed
private void jEnableSoundsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEnableSoundsActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jEnableSoundsActionPerformed
private void showProxySettings() { private void showProxySettings() {
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) { if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
this.pnlProxy.setVisible(true); this.pnlProxy.setVisible(true);
@ -1122,7 +1157,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
loadSelectedAvatar(prefs); loadSelectedAvatar(prefs);
// Images // Images
loadImages(prefs); loadImagesSettings(prefs);
// Images
loadSoundSettings(prefs);
// open specified tab before displaying // open specified tab before displaying
openTab(openedTab); openTab(openedTab);
@ -1159,7 +1197,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true"); load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
} }
private static void loadImages(Preferences prefs) { private static void loadImagesSettings(Preferences prefs) {
String prop = prefs.get(KEY_CARD_IMAGES_USE_DEFAULT, "true"); String prop = prefs.get(KEY_CARD_IMAGES_USE_DEFAULT, "true");
if (prop.equals("true")) { if (prop.equals("true")) {
dialog.useDefaultImageFolder.setSelected(true); dialog.useDefaultImageFolder.setSelected(true);
@ -1175,6 +1213,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.saveToZipFiles, KEY_CARD_IMAGES_SAVE_TO_ZIP, "true"); load(prefs, dialog.saveToZipFiles, KEY_CARD_IMAGES_SAVE_TO_ZIP, "true");
} }
private static void loadSoundSettings(Preferences prefs) {
String prop = prefs.get(KEY_SOUNDS_ON, "true");
if (prop.equals("true")) {
dialog.jEnableSounds.setSelected(true);
} else {
dialog.jEnableSounds.setSelected(false);
}
}
private static void loadProxySettings(Preferences prefs) { private static void loadProxySettings(Preferences prefs) {
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase())); dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase()));
@ -1391,6 +1438,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox displayBigCardsInHand; private javax.swing.JCheckBox displayBigCardsInHand;
private javax.swing.JButton exitButton; private javax.swing.JButton exitButton;
private javax.swing.JTextField imageFolderPath; private javax.swing.JTextField imageFolderPath;
private javax.swing.JCheckBox jEnableSounds;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel11;
@ -1418,6 +1466,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel20; private javax.swing.JPanel jPanel20;
private javax.swing.JPanel jPanel21; private javax.swing.JPanel jPanel21;
private javax.swing.JPanel jPanel22;
private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel5;

View file

@ -34,15 +34,6 @@
package mage.client.game; package mage.client.game;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.Serializable;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.chat.ChatPanel; import mage.client.chat.ChatPanel;
import mage.client.components.MageTextArea; import mage.client.components.MageTextArea;
@ -52,6 +43,16 @@ import mage.client.util.gui.ArrowBuilder;
import mage.remote.Session; import mage.remote.Session;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.Serializable;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/** /**
* *
@ -433,6 +434,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
public void setConnectedChatPanel(ChatPanel chatPanel) { public void setConnectedChatPanel(ChatPanel chatPanel) {
this.connectedChatPanel = chatPanel; this.connectedChatPanel = chatPanel;
} }
public void pressOKYesOrDone() {
if (btnLeft.getText().equals("OK") || btnLeft.getText().equals("Yes")) {
btnLeft.doClick();
} else if (btnRight.getText().equals("OK") || btnRight.getText().equals("Yes") || btnRight.getText().equals("Done")) {
btnRight.doClick();
}
}
private javax.swing.JButton btnLeft; private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight; private javax.swing.JButton btnRight;

View file

@ -798,17 +798,35 @@ public final class GamePanel extends javax.swing.JPanel {
} }
}); });
KeyStroke ks8 = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0); KeyStroke ks9 = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
this.getInputMap(c).put(ks8, "F9_PRESS"); this.getInputMap(c).put(ks9, "F9_PRESS");
this.getActionMap().put("F9_PRESS", new AbstractAction() { this.getActionMap().put("F9_PRESS", new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) { btnPassPriorityUntilNextYourTurnActionPerformed(actionEvent);
session.sendPlayerInteger(gameId, -9999); }
});
KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
this.getInputMap(c).put(ks2, "F2_PRESS");
this.getActionMap().put("F2_PRESS", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (feedbackPanel != null) {
feedbackPanel.pressOKYesOrDone();
} }
} }
}); });
KeyStroke ks3 = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0);
this.getInputMap(c).put(ks3, "F3_PRESS");
this.getActionMap().put("F3_PRESS", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
restorePriorityActionPerformed(actionEvent);
}
});
KeyStroke ksAltE = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK); KeyStroke ksAltE = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK);
this.getInputMap(c).put(ksAltE, "ENLARGE"); this.getInputMap(c).put(ksAltE, "ENLARGE");
this.getActionMap().put("ENLARGE", new AbstractAction() { this.getActionMap().put("ENLARGE", new AbstractAction() {
@ -1123,7 +1141,19 @@ public final class GamePanel extends javax.swing.JPanel {
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) { if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
session.sendPlayerInteger(gameId, 0); session.passTurnPriority(gameId);
}
}
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
session.passPriorityUntilNextYourTurn(gameId);
}
}
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
if (feedbackPanel != null) {
session.restorePriority(gameId);
} }
} }

View file

@ -28,6 +28,7 @@
package mage.client.remote; package mage.client.remote;
import mage.Constants;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.chat.ChatPanel; import mage.client.chat.ChatPanel;
@ -58,12 +59,12 @@ public class CallbackClientImpl implements CallbackClient {
private UUID clientId; private UUID clientId;
private MageFrame frame; private MageFrame frame;
private int messageId = 0; private int messageId = 0;
private boolean firstRun;
public CallbackClientImpl(MageFrame frame) { public CallbackClientImpl(MageFrame frame) {
this.clientId = UUID.randomUUID(); this.clientId = UUID.randomUUID();
this.frame = frame; this.frame = frame;
this.firstRun = true;
} }
@Override @Override
@ -99,10 +100,18 @@ public class CallbackClientImpl implements CallbackClient {
ChatMessage message = (ChatMessage) callback.getData(); ChatMessage message = (ChatMessage) callback.getData();
ChatPanel panel = frame.getChat(callback.getObjectId()); ChatPanel panel = frame.getChat(callback.getObjectId());
if (panel != null) { if (panel != null) {
if (message.isUserMessage() && panel.getConnectedChat() != null) { if (message.getMessage().equals(Constants.MSG_TIP_HOT_KEYS_CODE)) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK); panel.receiveMessage("[Tips] ", "You may use hot keys to play faster: " + "" +
"\nF2 - press Ok, Yes or Done" +
"\nF4 - skip current turn but stop on declare attackers" +
"\nF9 - skip everything until you next turn" +
"\nF2 - undo F4/F9", "", ChatMessage.MessageColor.ORANGE);
} else { } else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor()); if (message.isUserMessage() && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor());
}
} }
} }
} else if (callback.getMethod().equals("serverMessage")) { } else if (callback.getMethod().equals("serverMessage")) {
@ -138,7 +147,6 @@ public class CallbackClientImpl implements CallbackClient {
GamePanel panel = frame.getGame(callback.getObjectId()); GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null) { if (panel != null) {
panel.init((GameView) callback.getData()); panel.init((GameView) callback.getData());
} }
} }
else if (callback.getMethod().equals("gameOver")) { else if (callback.getMethod().equals("gameOver")) {

View file

@ -1,6 +1,7 @@
package mage.client.util; package mage.client.util;
import mage.client.constants.Constants; import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.sound.sampled.*; import javax.sound.sampled.*;
@ -116,7 +117,10 @@ public class AudioManager {
private static void checkAndPlayClip(Clip clip) { private static void checkAndPlayClip(Clip clip) {
try { try {
if (clip != null) { if (clip != null) {
audioManager.play(clip); String soundsOn = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SOUNDS_ON, "true");
if (soundsOn.equals("true")) {
audioManager.play(clip);
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -102,6 +102,11 @@ public interface MageServer {
void concedeGame(UUID gameId, String sessionId) throws MageException; void concedeGame(UUID gameId, String sessionId) throws MageException;
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException; GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
//priority methods
void passPriorityUntilNextYourTurn(UUID gameId, String sessionId) throws MageException;
void passTurnPriority(UUID gameId, String sessionId) throws MageException;
void restorePriority(UUID gameId, String sessionId) throws MageException;
//tournament methods //tournament methods
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException; void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
void joinTournament(UUID draftId, String sessionId) throws MageException; void joinTournament(UUID draftId, String sessionId) throws MageException;

View file

@ -28,8 +28,6 @@
package mage.remote; package mage.remote;
import java.net.*;
import java.util.*;
import mage.MageException; import mage.MageException;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException; import mage.cards.decks.InvalidDeckException;
@ -53,6 +51,9 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterClient;
import java.net.*;
import java.util.*;
/** /**
* *
@ -928,6 +929,51 @@ public class SessionImpl implements Session {
return false; return false;
} }
@Override
public boolean passPriorityUntilNextYourTurn(UUID gameId) {
try {
if (isConnected()) {
server.passPriorityUntilNextYourTurn(gameId, sessionId);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
@Override
public boolean passTurnPriority(UUID gameId) {
try {
if (isConnected()) {
server.passTurnPriority(gameId, sessionId);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
@Override
public boolean restorePriority(UUID gameId) {
try {
if (isConnected()) {
server.restorePriority(gameId, sessionId);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
@Override @Override
public boolean stopWatching(UUID gameId) { public boolean stopWatching(UUID gameId) {
try { try {

View file

@ -58,4 +58,37 @@ public interface GamePlay {
boolean updateDeck(UUID tableId, DeckCardLists deck); boolean updateDeck(UUID tableId, DeckCardLists deck);
DraftPickView sendCardPick(UUID draftId, UUID cardId); DraftPickView sendCardPick(UUID draftId, UUID cardId);
/*** Separate methods for priority handling ***/
/**
* magenoxx:
* it should be done separately as sendPlayer* methods calls are injected into the game flow
* - this is similar to concedeGame method
*/
/**
* Pass priority until next your turn.
* Don't stop at all even if something happens.
*
* @param gameId
* @return
*/
boolean passPriorityUntilNextYourTurn(UUID gameId);
/**
* Passes current turn but stop on pre combat phase.
*
* @param gameId
* @return
*/
boolean passTurnPriority(UUID gameId);
/**
* This method cancels all other calls made before.
*
* @param gameId
* @return
*/
boolean restorePriority(UUID gameId);
} }

View file

@ -28,47 +28,12 @@
package mage.player.ai; package mage.player.ai;
import java.io.IOException; import mage.Constants.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.ColoredManaSymbol;
import mage.Constants.Outcome;
import mage.Constants.RangeOfInfluence;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageObject; import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.*;
import mage.abilities.ActivatedAbility; import mage.abilities.costs.mana.*;
import mage.abilities.Mode;
import mage.abilities.Modes;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.HybridManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.MonoHybridManaCost;
import mage.abilities.costs.mana.PhyrexianManaCost;
import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continious.BecomesCreatureSourceEffect; import mage.abilities.effects.common.continious.BecomesCreatureSourceEffect;
import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.DoubleStrikeAbility;
@ -86,13 +51,7 @@ import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureForCombat; import mage.filter.common.*;
import mage.filter.common.FilterCreatureOrPlayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterLandCard;
import mage.filter.common.FilterNonlandCard;
import mage.filter.common.FilterPermanentOrPlayer;
import mage.filter.common.FilterPlaneswalkerPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.combat.CombatGroup; import mage.game.combat.CombatGroup;
import mage.game.draft.Draft; import mage.game.draft.Draft;
@ -111,27 +70,17 @@ import mage.players.Player;
import mage.players.PlayerImpl; import mage.players.PlayerImpl;
import mage.players.net.UserData; import mage.players.net.UserData;
import mage.players.net.UserGroup; import mage.players.net.UserGroup;
import mage.target.Target; import mage.target.*;
import mage.target.TargetAmount; import mage.target.common.*;
import mage.target.TargetCard;
import mage.target.TargetPermanent;
import mage.target.TargetPlayer;
import mage.target.TargetSpell;
import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreatureOrPlayer;
import mage.target.common.TargetCreatureOrPlayerAmount;
import mage.target.common.TargetDefender;
import mage.target.common.TargetDiscard;
import mage.target.common.TargetPermanentOrPlayer;
import mage.util.Copier; import mage.util.Copier;
import mage.util.TreeNode; import mage.util.TreeNode;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
@ -1058,6 +1007,10 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
abort = true; abort = true;
} }
@Override
public void skip() {
}
@Override @Override
public boolean chooseUse(Outcome outcome, String message, Game game) { public boolean chooseUse(Outcome outcome, String message, Game game) {
log.debug("chooseUse: " + outcome.isGood()); log.debug("chooseUse: " + outcome.isGood());

View file

@ -34,8 +34,9 @@ import mage.Constants.Zone;
import mage.MageObject; import mage.MageObject;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.*; import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.ReplacementEffect; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.PhyrexianManaCost;
import mage.abilities.effects.RequirementEffect; import mage.abilities.effects.RequirementEffect;
import mage.abilities.mana.ManaAbility; import mage.abilities.mana.ManaAbility;
import mage.cards.Card; import mage.cards.Card;
@ -404,11 +405,11 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
pass(); pass();
return false; return false;
} else if (response.getInteger() != null) { } else if (response.getInteger() != null) {
if (response.getInteger() == -9999) { /*if (response.getInteger() == -9999) {
passedAllTurns = true; passedAllTurns = true;
} }*/
pass(); pass();
passedTurn = true; //passedTurn = true;
return false; return false;
} else if (response.getString() != null && response.getString().equals("special")) { } else if (response.getString() != null && response.getString().equals("special")) {
specialAction(game); specialAction(game);
@ -509,7 +510,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
FilterCreatureForCombat filter = filterCreatureForCombat.copy(); FilterCreatureForCombat filter = filterCreatureForCombat.copy();
filter.add(new ControllerIdPredicate(attackingPlayerId)); filter.add(new ControllerIdPredicate(attackingPlayerId));
while (!abort) { while (!abort) {
if (passedAllTurns || passedTurn) { if (passedAllTurns /*|| passedTurn*/) {
return; return;
} }
game.fireSelectEvent(playerId, "Select attackers"); game.fireSelectEvent(playerId, "Select attackers");
@ -517,10 +518,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
if (response.getBoolean() != null) { if (response.getBoolean() != null) {
return; return;
} else if (response.getInteger() != null) { } else if (response.getInteger() != null) {
if (response.getInteger() == -9999) { //if (response.getInteger() == -9999) {
passedAllTurns = true; // passedAllTurns = true;
} //}
passedTurn = true; //passedTurn = true;
return; return;
} else if (response.getUUID() != null) { } else if (response.getUUID() != null) {
Permanent attacker = game.getPermanent(response.getUUID()); Permanent attacker = game.getPermanent(response.getUUID());
@ -579,10 +580,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
if (response.getBoolean() != null) { if (response.getBoolean() != null) {
return; return;
} else if (response.getInteger() != null) { } else if (response.getInteger() != null) {
if (response.getInteger() == -9999) { //if (response.getInteger() == -9999) {
passedAllTurns = true; // passedAllTurns = true;
} //}
passedTurn = true; //passedTurn = true;
return; return;
} else if (response.getUUID() != null) { } else if (response.getUUID() != null) {
Permanent blocker = game.getPermanent(response.getUUID()); Permanent blocker = game.getPermanent(response.getUUID());
@ -801,6 +802,15 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
} }
} }
@Override
public void skip() {
synchronized(response) {
response.setInteger(0);
response.notify();
log.debug("Got skip action from player: " + getId());
}
}
@Override @Override
public HumanPlayer copy() { public HumanPlayer copy() {
return new HumanPlayer(this); return new HumanPlayer(this);

View file

@ -28,10 +28,6 @@
package mage.server; package mage.server;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import mage.MageException; import mage.MageException;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.game.GameException; import mage.game.GameException;
@ -57,6 +53,11 @@ import mage.view.*;
import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
//import mage.interfaces.Server; //import mage.interfaces.Server;
@ -569,6 +570,40 @@ public class MageServerImpl implements MageServer {
}); });
} }
@Override
public void passPriorityUntilNextYourTurn(final UUID gameId, final String sessionId) throws MageException {
execute("passPriorityUntilNextYourTurn", sessionId, new Action() {
@Override
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
GameManager.getInstance().passPriorityUntilNextYourTurn(gameId, userId);
}
});
}
@Override
public void passTurnPriority(final UUID gameId, final String sessionId) throws MageException {
execute("passTurnPriority", sessionId, new Action() {
@Override
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
GameManager.getInstance().passTurnPriority(gameId, userId);
}
});
}
@Override
public void restorePriority(final UUID gameId, final String sessionId) throws MageException {
execute("restorePriority", sessionId, new Action() {
@Override
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
GameManager.getInstance().restorePriority(gameId, userId);
}
});
}
@Override @Override
public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException { public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() { return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {

View file

@ -28,13 +28,6 @@
package mage.server.game; package mage.server.game;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
import mage.Constants.Zone; import mage.Constants.Zone;
import mage.MageException; import mage.MageException;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -62,6 +55,14 @@ import mage.view.GameView;
import mage.view.PermanentView; import mage.view.PermanentView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
/** /**
* *
@ -254,6 +255,18 @@ public class GameController implements GameCallback {
game.concede(getPlayerId(userId)); game.concede(getPlayerId(userId));
} }
public void passPriorityUntilNextYourTurn(UUID userId) {
game.passPriorityUntilNextYourTurn(getPlayerId(userId));
}
public void passTurnPriority(UUID userId) {
game.passTurnPriority(getPlayerId(userId));
}
public void restorePriority(UUID userId) {
game.restorePriority(getPlayerId(userId));
}
private void leave(UUID userId) { private void leave(UUID userId) {
game.quit(getPlayerId(userId)); game.quit(getPlayerId(userId));
} }

View file

@ -28,12 +28,13 @@
package mage.server.game; package mage.server.game;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.game.Game; import mage.game.Game;
import mage.view.GameView; import mage.view.GameView;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -95,6 +96,21 @@ public class GameManager {
gameControllers.get(gameId).concede(userId); gameControllers.get(gameId).concede(userId);
} }
public void passPriorityUntilNextYourTurn(UUID gameId, UUID userId) {
if (gameControllers.containsKey(gameId))
gameControllers.get(gameId).passPriorityUntilNextYourTurn(userId);
}
public void passTurnPriority(UUID gameId, UUID userId) {
if (gameControllers.containsKey(gameId))
gameControllers.get(gameId).passTurnPriority(userId);
}
public void restorePriority(UUID gameId, UUID userId) {
if (gameControllers.containsKey(gameId))
gameControllers.get(gameId).restorePriority(userId);
}
public void watchGame(UUID gameId, UUID userId) { public void watchGame(UUID gameId, UUID userId) {
if (gameControllers.containsKey(gameId)) if (gameControllers.containsKey(gameId))
gameControllers.get(gameId).watch(userId); gameControllers.get(gameId).watch(userId);

View file

@ -30,6 +30,8 @@ package mage;
public final class Constants { public final class Constants {
public static final String MSG_TIP_HOT_KEYS_CODE = "MSG_TIPS_0001";
public enum ColoredManaSymbol { public enum ColoredManaSymbol {
W("W"), U("U"), B("B"), R("R"), G("G"); W("W"), U("U"), B("B"), R("R"), G("G");

View file

@ -169,6 +169,11 @@ public interface Game extends MageItem, Serializable {
void addEmblem(Emblem emblem, Ability source); void addEmblem(Emblem emblem, Ability source);
void addPermanent(Permanent permanent); void addPermanent(Permanent permanent);
// priority methods
void passPriorityUntilNextYourTurn(UUID userId);
void passTurnPriority(UUID userId);
void restorePriority(UUID userId);
/** /**
* This version supports copying of copies of any depth. * This version supports copying of copies of any depth.
* *

View file

@ -28,6 +28,7 @@
package mage.game; package mage.game;
import mage.Constants;
import mage.Constants.*; import mage.Constants.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -458,6 +459,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
this.gameOptions = options; this.gameOptions = options;
scorePlayer = state.getPlayers().values().iterator().next(); scorePlayer = state.getPlayers().values().iterator().next();
init(choosingPlayerId, options); init(choosingPlayerId, options);
informPlayers(Constants.MSG_TIP_HOT_KEYS_CODE);
play(startingPlayerId); play(startingPlayerId);
//saveState(); //saveState();
} }
@ -719,6 +721,30 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
} }
} }
@Override
public synchronized void passPriorityUntilNextYourTurn(UUID playerId) {
Player player = state.getPlayer(playerId);
if (player != null) {
player.passPriorityUntilNextYourTurn(this);
}
}
@Override
public synchronized void passTurnPriority(UUID playerId) {
Player player = state.getPlayer(playerId);
if (player != null) {
player.passTurnPriority(this);
}
}
@Override
public synchronized void restorePriority(UUID playerId) {
Player player = state.getPlayer(playerId);
if (player != null) {
player.restorePriority(this);
}
}
@Override @Override
public void playPriority(UUID activePlayerId, boolean resuming) { public void playPriority(UUID activePlayerId, boolean resuming) {
int bookmark = 0; int bookmark = 0;

View file

@ -34,9 +34,6 @@ import mage.MageItem;
import mage.MageObject; import mage.MageObject;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.effects.ReplacementEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
@ -56,11 +53,7 @@ import mage.target.common.TargetCardInLibrary;
import mage.util.Copyable; import mage.util.Copyable;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/** /**
* *
@ -203,6 +196,12 @@ public interface Player extends MageItem, Copyable<Player> {
void leave(); void leave();
void concede(Game game); void concede(Game game);
void abort(); void abort();
void skip();
//priority methods
void passPriorityUntilNextYourTurn(Game game);
void passTurnPriority(Game game);
void restorePriority(Game game);
void revealCards(String name, Cards cards, Game game); void revealCards(String name, Cards cards, Game game);
void lookAtCards(String name, Cards cards, Game game); void lookAtCards(String name, Cards cards, Game game);

View file

@ -28,8 +28,6 @@
package mage.players; package mage.players;
import java.io.Serializable;
import java.util.*;
import mage.Constants.AsThoughEffectType; import mage.Constants.AsThoughEffectType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
@ -73,6 +71,9 @@ import mage.target.common.TargetDiscard;
import mage.watchers.common.BloodthirstWatcher; import mage.watchers.common.BloodthirstWatcher;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable { public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
@ -1080,6 +1081,28 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
game.leave(playerId); game.leave(playerId);
} }
@Override
public void passPriorityUntilNextYourTurn(Game game) {
passedTurn = true;
passedAllTurns = true;
this.skip();
log.debug("Passed priority for turns");
}
@Override
public void passTurnPriority(Game game) {
passedTurn = true;
this.skip();
log.debug("Passed priority for turn");
}
@Override
public void restorePriority(Game game) {
passedAllTurns = false;
passedTurn = false;
log.debug("Restore priority");
}
@Override @Override
public void leave() { public void leave() {
this.passed = true; this.passed = true;