mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* UI: added turn number and step info in game logs
This commit is contained in:
parent
190c3ecc00
commit
2e73f9d1c5
21 changed files with 546 additions and 529 deletions
|
@ -1,424 +1,420 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ChatPanel.java
|
* ChatPanel.java
|
||||||
*
|
*
|
||||||
* Created on 15-Dec-2009, 11:04:31 PM
|
* Created on 15-Dec-2009, 11:04:31 PM
|
||||||
*/
|
*/
|
||||||
package mage.client.chat;
|
package mage.client.chat;
|
||||||
|
|
||||||
import java.awt.Color;
|
import mage.client.MageFrame;
|
||||||
import java.awt.Dimension;
|
import mage.client.SessionHandler;
|
||||||
import java.awt.Font;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import java.awt.event.KeyEvent;
|
import mage.client.util.GUISizeHelper;
|
||||||
import java.text.DateFormat;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import java.util.Date;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import java.util.Locale;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.client.SessionHandler;
|
|
||||||
import mage.client.dialog.PreferencesDialog;
|
|
||||||
import mage.client.util.GUISizeHelper;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
|
||||||
import mage.view.ChatMessage.MessageType;
|
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
|
||||||
|
|
||||||
/**
|
import javax.swing.*;
|
||||||
*
|
import java.awt.*;
|
||||||
* @author BetaSteward_at_googlemail.com, nantuko
|
import java.awt.event.KeyEvent;
|
||||||
*/
|
import java.text.DateFormat;
|
||||||
public class ChatPanelBasic extends javax.swing.JPanel {
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time formatter
|
* @author BetaSteward_at_googlemail.com, nantuko
|
||||||
*/
|
*/
|
||||||
protected final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
|
public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
|
|
||||||
protected UUID chatId;
|
/**
|
||||||
/**
|
* Time formatter
|
||||||
* Chat message color for opponents.
|
*/
|
||||||
*/
|
protected final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||||
protected static final String OPPONENT_COLOR = "#FF7F50";
|
|
||||||
/**
|
|
||||||
* Chat message color for client player.
|
|
||||||
*/
|
|
||||||
protected static final String MY_COLOR = "#7FFFD4";
|
|
||||||
/**
|
|
||||||
* Chat message color for timestamps.
|
|
||||||
*/
|
|
||||||
protected static final String TIMESTAMP_COLOR = "#CCCC33";
|
|
||||||
/**
|
|
||||||
* Chat message color for messages.
|
|
||||||
*/
|
|
||||||
protected static final String MESSAGE_COLOR = "White";
|
|
||||||
/**
|
|
||||||
* Chat message color for personal infos.
|
|
||||||
*/
|
|
||||||
protected static final String USER_INFO_COLOR = "Yellow";
|
|
||||||
/**
|
|
||||||
* Chat message color for status infos.
|
|
||||||
*/
|
|
||||||
protected static final String STATUS_COLOR = "#FFCC33";
|
|
||||||
/**
|
|
||||||
* Alpha value for transparency (255 = not transparent)
|
|
||||||
*/
|
|
||||||
public static final int CHAT_ALPHA = 80;
|
|
||||||
/**
|
|
||||||
* This will be a chat that will be connected to {this} and will handle
|
|
||||||
* redirected messages; Mostly used to redirect user messages to another
|
|
||||||
* window.
|
|
||||||
*/
|
|
||||||
protected ChatPanelBasic connectedChat;
|
|
||||||
/**
|
|
||||||
* Parent chat this chat connected to. Used to send messages using parent
|
|
||||||
* chat as it is the only one connected to server.
|
|
||||||
*/
|
|
||||||
protected ChatPanelBasic parentChatRef;
|
|
||||||
/**
|
|
||||||
* Selected extended view mode.
|
|
||||||
*/
|
|
||||||
protected VIEW_MODE extendedViewMode = VIEW_MODE.NONE;
|
|
||||||
|
|
||||||
public enum VIEW_MODE {
|
protected UUID chatId;
|
||||||
|
/**
|
||||||
|
* Chat message color for opponents.
|
||||||
|
*/
|
||||||
|
protected static final String OPPONENT_COLOR = "#FF7F50";
|
||||||
|
/**
|
||||||
|
* Chat message color for client player.
|
||||||
|
*/
|
||||||
|
protected static final String MY_COLOR = "#7FFFD4";
|
||||||
|
/**
|
||||||
|
* Chat message color for timestamps.
|
||||||
|
*/
|
||||||
|
protected static final String TIMESTAMP_COLOR = "#CCCC33";
|
||||||
|
/**
|
||||||
|
* Chat message color for messages.
|
||||||
|
*/
|
||||||
|
protected static final String MESSAGE_COLOR = "White";
|
||||||
|
/**
|
||||||
|
* Chat message color for personal infos.
|
||||||
|
*/
|
||||||
|
protected static final String USER_INFO_COLOR = "Yellow";
|
||||||
|
/**
|
||||||
|
* Chat message color for status infos.
|
||||||
|
*/
|
||||||
|
protected static final String STATUS_COLOR = "#FFCC33";
|
||||||
|
/**
|
||||||
|
* Alpha value for transparency (255 = not transparent)
|
||||||
|
*/
|
||||||
|
public static final int CHAT_ALPHA = 80;
|
||||||
|
/**
|
||||||
|
* This will be a chat that will be connected to {this} and will handle
|
||||||
|
* redirected messages; Mostly used to redirect user messages to another
|
||||||
|
* window.
|
||||||
|
*/
|
||||||
|
protected ChatPanelBasic connectedChat;
|
||||||
|
/**
|
||||||
|
* Parent chat this chat connected to. Used to send messages using parent
|
||||||
|
* chat as it is the only one connected to server.
|
||||||
|
*/
|
||||||
|
protected ChatPanelBasic parentChatRef;
|
||||||
|
/**
|
||||||
|
* Selected extended view mode.
|
||||||
|
*/
|
||||||
|
protected VIEW_MODE extendedViewMode = VIEW_MODE.NONE;
|
||||||
|
|
||||||
NONE, GAME, CHAT
|
public enum VIEW_MODE {
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Controls the output start messages as the chat panel is created
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected ChatType chatType = ChatType.DEFAULT;
|
|
||||||
|
|
||||||
public enum ChatType {
|
NONE, GAME, CHAT
|
||||||
|
}
|
||||||
|
|
||||||
DEFAULT, GAME, TABLES, TOURNAMENT
|
/**
|
||||||
}
|
* Controls the output start messages as the chat panel is created
|
||||||
protected boolean startMessageDone = false;
|
*/
|
||||||
|
protected ChatType chatType = ChatType.DEFAULT;
|
||||||
|
|
||||||
/**
|
public enum ChatType {
|
||||||
*
|
|
||||||
* Creates new form ChatPanel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public ChatPanelBasic() {
|
|
||||||
initComponents();
|
|
||||||
setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
|
||||||
changeGUISize(GUISizeHelper.chatFont);
|
|
||||||
if (jScrollPaneTxt != null) {
|
|
||||||
jScrollPaneTxt.setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
|
||||||
jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
|
||||||
jScrollPaneTxt.setViewportBorder(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanUp() {
|
DEFAULT, GAME, TABLES, TOURNAMENT
|
||||||
|
}
|
||||||
|
|
||||||
}
|
protected boolean startMessageDone = false;
|
||||||
|
|
||||||
public void changeGUISize(Font font) {
|
/**
|
||||||
txtConversation.setFont(font);
|
* Creates new form ChatPanel
|
||||||
txtMessage.setFont(font);
|
*/
|
||||||
if (jScrollPaneTxt != null) {
|
public ChatPanelBasic() {
|
||||||
jScrollPaneTxt.setFont(font);
|
initComponents();
|
||||||
jScrollPaneTxt.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
||||||
jScrollPaneTxt.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
changeGUISize(GUISizeHelper.chatFont);
|
||||||
}
|
if (jScrollPaneTxt != null) {
|
||||||
int height = 30;
|
jScrollPaneTxt.setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
||||||
if (font.getSize() > 20) {
|
jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, CHAT_ALPHA));
|
||||||
height = 30 + Math.min(font.getSize() - 10, 30);
|
jScrollPaneTxt.setViewportBorder(null);
|
||||||
}
|
}
|
||||||
txtMessage.setMinimumSize(new Dimension(20, height));
|
}
|
||||||
txtMessage.setMaximumSize(new Dimension(txtMessage.getWidth(), height));
|
|
||||||
txtMessage.setPreferredSize(new Dimension(txtMessage.getWidth(), height));
|
|
||||||
txtMessage.setSize(new Dimension(txtMessage.getWidth(), height));
|
|
||||||
if (connectedChat != null) {
|
|
||||||
connectedChat.changeGUISize(font);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatType getChatType() {
|
public void cleanUp() {
|
||||||
return chatType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChatType(ChatType chatType) {
|
}
|
||||||
this.chatType = chatType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStartMessageDone() {
|
public void changeGUISize(Font font) {
|
||||||
return startMessageDone;
|
txtConversation.setFont(font);
|
||||||
}
|
txtMessage.setFont(font);
|
||||||
|
if (jScrollPaneTxt != null) {
|
||||||
|
jScrollPaneTxt.setFont(font);
|
||||||
|
jScrollPaneTxt.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||||
|
jScrollPaneTxt.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||||
|
}
|
||||||
|
int height = 30;
|
||||||
|
if (font.getSize() > 20) {
|
||||||
|
height = 30 + Math.min(font.getSize() - 10, 30);
|
||||||
|
}
|
||||||
|
txtMessage.setMinimumSize(new Dimension(20, height));
|
||||||
|
txtMessage.setMaximumSize(new Dimension(txtMessage.getWidth(), height));
|
||||||
|
txtMessage.setPreferredSize(new Dimension(txtMessage.getWidth(), height));
|
||||||
|
txtMessage.setSize(new Dimension(txtMessage.getWidth(), height));
|
||||||
|
if (connectedChat != null) {
|
||||||
|
connectedChat.changeGUISize(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setStartMessageDone(boolean startMessageDone) {
|
public ChatType getChatType() {
|
||||||
this.startMessageDone = startMessageDone;
|
return chatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(UUID chatId) {
|
public void setChatType(ChatType chatType) {
|
||||||
this.chatId = chatId;
|
this.chatType = chatType;
|
||||||
if (SessionHandler.joinChat(chatId)) {
|
}
|
||||||
MageFrame.addChat(chatId, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disconnect() {
|
public boolean isStartMessageDone() {
|
||||||
if (SessionHandler.getSession() != null) {
|
return startMessageDone;
|
||||||
SessionHandler.leaveChat(chatId);
|
}
|
||||||
MageFrame.removeChat(chatId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pattern profanityPattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp33|\\Wpoo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dumas|dum|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gok|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ger|n1ga|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
|
public void setStartMessageDone(boolean startMessageDone) {
|
||||||
Pattern profanity2Pattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp3|\\Wpo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dum|dumas|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ga|n1ger|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|porno|porn|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
|
this.startMessageDone = startMessageDone;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean containsSwearing(String message, String level) {
|
public void connect(UUID chatId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
if (SessionHandler.joinChat(chatId)) {
|
||||||
|
MageFrame.addChat(chatId, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (level.equals("0")) {
|
public void disconnect() {
|
||||||
return false;
|
if (SessionHandler.getSession() != null) {
|
||||||
}
|
SessionHandler.leaveChat(chatId);
|
||||||
message = '.' + message + '.';
|
MageFrame.removeChat(chatId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
message = message.toLowerCase(Locale.ENGLISH);
|
Pattern profanityPattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp33|\\Wpoo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dumas|dum|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gok|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ger|n1ga|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
|
||||||
message = message.replaceAll("[a@]([s5][s5]+)", "axyx");
|
Pattern profanity2Pattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp3|\\Wpo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dum|dumas|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ga|n1ger|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|porno|porn|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
|
||||||
message = message.replaceAll("b.([t\\+][t\\+]+)", "buxyx");
|
|
||||||
message = message.replaceAll("(.)(\\1{1,})", "$1");
|
|
||||||
message = message.replaceAll("[@]", "a");
|
|
||||||
message = message.replaceAll("[il]", "1");
|
|
||||||
message = message.replaceAll("[e]", "3");
|
|
||||||
message = message.replaceAll("[0]", "o");
|
|
||||||
message = message.replaceAll("[5z]", "s");
|
|
||||||
message = message.replaceAll("\\W", ".");
|
|
||||||
message = message.replaceAll("(.)(\\1{1,})", "$1");
|
|
||||||
message = message.replaceAll("\\.", "");
|
|
||||||
|
|
||||||
Matcher matchPattern = profanityPattern.matcher(message);
|
private boolean containsSwearing(String message, String level) {
|
||||||
if (matchPattern.find()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level.equals("2")) {
|
if (level.equals("0")) {
|
||||||
message = message.replaceAll("\\.", "");
|
return false;
|
||||||
message = '.' + message + '.';
|
}
|
||||||
matchPattern = profanity2Pattern.matcher(message);
|
message = '.' + message + '.';
|
||||||
if (matchPattern.find()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
message = message.toLowerCase(Locale.ENGLISH);
|
||||||
* Display message in the chat. Use different colors for timestamp, username
|
message = message.replaceAll("[a@]([s5][s5]+)", "axyx");
|
||||||
* and message.
|
message = message.replaceAll("b.([t\\+][t\\+]+)", "buxyx");
|
||||||
*
|
message = message.replaceAll("(.)(\\1{1,})", "$1");
|
||||||
* @param username message sender
|
message = message.replaceAll("[@]", "a");
|
||||||
* @param message message itself
|
message = message.replaceAll("[il]", "1");
|
||||||
* @param time timestamp
|
message = message.replaceAll("[e]", "3");
|
||||||
* @param messageType
|
message = message.replaceAll("[0]", "o");
|
||||||
* @param color Preferred color. Not used.
|
message = message.replaceAll("[5z]", "s");
|
||||||
*/
|
message = message.replaceAll("\\W", ".");
|
||||||
Pattern cardNamePattern = Pattern.compile(".*<font bgcolor=orange.*?</font>.*");
|
message = message.replaceAll("(.)(\\1{1,})", "$1");
|
||||||
|
message = message.replaceAll("\\.", "");
|
||||||
|
|
||||||
public void receiveMessage(String username, String message, Date time, MessageType messageType, MessageColor color) {
|
Matcher matchPattern = profanityPattern.matcher(message);
|
||||||
StringBuilder text = new StringBuilder();
|
if (matchPattern.find()) {
|
||||||
if (time != null) {
|
return true;
|
||||||
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": "));
|
}
|
||||||
}
|
|
||||||
String userColor;
|
|
||||||
String textColor;
|
|
||||||
String userSeparator = " ";
|
|
||||||
switch (messageType) {
|
|
||||||
case STATUS: // a message to all chat user
|
|
||||||
textColor = STATUS_COLOR;
|
|
||||||
userColor = STATUS_COLOR;
|
|
||||||
break;
|
|
||||||
case USER_INFO: // a personal message
|
|
||||||
textColor = USER_INFO_COLOR;
|
|
||||||
userColor = USER_INFO_COLOR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
|
||||||
textColor = MESSAGE_COLOR;
|
|
||||||
userSeparator = ": ";
|
|
||||||
}
|
|
||||||
if (color == MessageColor.ORANGE) {
|
|
||||||
textColor = "Orange";
|
|
||||||
}
|
|
||||||
if (color == MessageColor.YELLOW) {
|
|
||||||
textColor = "Yellow";
|
|
||||||
}
|
|
||||||
if (messageType == MessageType.WHISPER_FROM) {
|
|
||||||
if (username.equalsIgnoreCase(SessionHandler.getUserName())) {
|
|
||||||
if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 0")) {
|
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0");
|
|
||||||
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 1")) {
|
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "1");
|
|
||||||
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 2")) {
|
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
username = "Whisper from " + username;
|
|
||||||
}
|
|
||||||
if (messageType == MessageType.WHISPER_TO) {
|
|
||||||
username = "Whisper to " + username;
|
|
||||||
}
|
|
||||||
|
|
||||||
Matcher matchPattern = cardNamePattern.matcher(message);
|
if (level.equals("2")) {
|
||||||
String messageToTest = message;
|
message = message.replaceAll("\\.", "");
|
||||||
while (matchPattern.find()) {
|
message = '.' + message + '.';
|
||||||
messageToTest = message.replaceFirst("<font bgcolor=orange.*?</font>", "");
|
matchPattern = profanity2Pattern.matcher(message);
|
||||||
}
|
return matchPattern.find();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (messageType == MessageType.USER_INFO || messageType == MessageType.GAME || messageType == MessageType.STATUS
|
Pattern cardNamePattern = Pattern.compile(".*<font bgcolor=orange.*?</font>.*");
|
||||||
|| PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("0")
|
|
||||||
|| !PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("0") && !containsSwearing(messageToTest, PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0"))) {
|
|
||||||
if (username != null && !username.isEmpty()) {
|
|
||||||
text.append(getColoredText(userColor, username + userSeparator));
|
|
||||||
}
|
|
||||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.CHAT)));
|
|
||||||
this.txtConversation.append(text.toString());
|
|
||||||
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("1")) {
|
|
||||||
if (username != null && !username.isEmpty()) {
|
|
||||||
text.append(getColoredText("black", username + userSeparator));
|
|
||||||
}
|
|
||||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML("<font color=black size=-2>" + message + "</font> <font size=-2>Profanity detected. Type: <font color=green>/w " + SessionHandler.getUserName() + " profanity 0</font>' to turn the filter off</font></font>", ManaSymbols.Type.CHAT)));
|
|
||||||
this.txtConversation.append(text.toString());
|
|
||||||
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("2")) {
|
|
||||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML("<font color=black size=-2>" + username + ": Profanity detected. To make it less strict, type: </font> <font color=green size=-2>/w " + SessionHandler.getUserName() + " profanity 1</font>", ManaSymbols.Type.CHAT)));
|
|
||||||
this.txtConversation.append(text.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getColoredText(String color, String text) {
|
/**
|
||||||
return "<font color='" + color + "'>" + text + "</font>";
|
* Display message in the chat. Use different colors for timestamp, username
|
||||||
}
|
* and message.
|
||||||
|
*
|
||||||
|
* @param username message sender
|
||||||
|
* @param message message itself
|
||||||
|
* @param time timestamp
|
||||||
|
* @param turnInfo game turn info, can be null for non game messages
|
||||||
|
* @param messageType
|
||||||
|
* @param color Preferred color. Not used.
|
||||||
|
*/
|
||||||
|
public void receiveMessage(String username, String message, Date time, String turnInfo, MessageType messageType, MessageColor color) {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
if (time != null) {
|
||||||
|
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + (turnInfo == null ? "" : ", " + turnInfo) + ": "));
|
||||||
|
}
|
||||||
|
String userColor;
|
||||||
|
String textColor;
|
||||||
|
String userSeparator = " ";
|
||||||
|
switch (messageType) {
|
||||||
|
case STATUS: // a message to all chat user
|
||||||
|
textColor = STATUS_COLOR;
|
||||||
|
userColor = STATUS_COLOR;
|
||||||
|
break;
|
||||||
|
case USER_INFO: // a personal message
|
||||||
|
textColor = USER_INFO_COLOR;
|
||||||
|
userColor = USER_INFO_COLOR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
|
textColor = MESSAGE_COLOR;
|
||||||
|
userSeparator = ": ";
|
||||||
|
}
|
||||||
|
if (color == MessageColor.ORANGE) {
|
||||||
|
textColor = "Orange";
|
||||||
|
}
|
||||||
|
if (color == MessageColor.YELLOW) {
|
||||||
|
textColor = "Yellow";
|
||||||
|
}
|
||||||
|
if (messageType == MessageType.WHISPER_FROM) {
|
||||||
|
if (username.equalsIgnoreCase(SessionHandler.getUserName())) {
|
||||||
|
if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 0")) {
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0");
|
||||||
|
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 1")) {
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "1");
|
||||||
|
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 2")) {
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
username = "Whisper from " + username;
|
||||||
|
}
|
||||||
|
if (messageType == MessageType.WHISPER_TO) {
|
||||||
|
username = "Whisper to " + username;
|
||||||
|
}
|
||||||
|
|
||||||
public String getText() {
|
Matcher matchPattern = cardNamePattern.matcher(message);
|
||||||
return txtConversation.getText();
|
String messageToTest = message;
|
||||||
}
|
while (matchPattern.find()) {
|
||||||
|
messageToTest = message.replaceFirst("<font bgcolor=orange.*?</font>", "");
|
||||||
|
}
|
||||||
|
|
||||||
public ChatPanelBasic getConnectedChat() {
|
if (messageType == MessageType.USER_INFO || messageType == MessageType.GAME || messageType == MessageType.STATUS
|
||||||
return connectedChat;
|
|| PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("0")
|
||||||
}
|
|| !PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("0") && !containsSwearing(messageToTest, PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0"))) {
|
||||||
|
if (username != null && !username.isEmpty()) {
|
||||||
|
text.append(getColoredText(userColor, username + userSeparator));
|
||||||
|
}
|
||||||
|
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.CHAT)));
|
||||||
|
this.txtConversation.append(text.toString());
|
||||||
|
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("1")) {
|
||||||
|
if (username != null && !username.isEmpty()) {
|
||||||
|
text.append(getColoredText("black", username + userSeparator));
|
||||||
|
}
|
||||||
|
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML("<font color=black size=-2>" + message + "</font> <font size=-2>Profanity detected. Type: <font color=green>/w " + SessionHandler.getUserName() + " profanity 0</font>' to turn the filter off</font></font>", ManaSymbols.Type.CHAT)));
|
||||||
|
this.txtConversation.append(text.toString());
|
||||||
|
} else if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0").equals("2")) {
|
||||||
|
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML("<font color=black size=-2>" + username + ": Profanity detected. To make it less strict, type: </font> <font color=green size=-2>/w " + SessionHandler.getUserName() + " profanity 1</font>", ManaSymbols.Type.CHAT)));
|
||||||
|
this.txtConversation.append(text.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setConnectedChat(ChatPanelBasic connectedChat) {
|
protected String getColoredText(String color, String text) {
|
||||||
this.connectedChat = connectedChat;
|
return "<font color='" + color + "'>" + text + "</font>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentChat(ChatPanelBasic parentChatRef) {
|
public String getText() {
|
||||||
this.parentChatRef = parentChatRef;
|
return txtConversation.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatPanelBasic getParentChatRef() {
|
public ChatPanelBasic getConnectedChat() {
|
||||||
return parentChatRef;
|
return connectedChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentChatRef(ChatPanelBasic parentChatRef) {
|
public void setConnectedChat(ChatPanelBasic connectedChat) {
|
||||||
this.parentChatRef = parentChatRef;
|
this.connectedChat = connectedChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableInput() {
|
public void setParentChat(ChatPanelBasic parentChatRef) {
|
||||||
this.txtMessage.setVisible(false);
|
this.parentChatRef = parentChatRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JTextField getTxtMessageInputComponent() {
|
public ChatPanelBasic getParentChatRef() {
|
||||||
return this.txtMessage;
|
return parentChatRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useExtendedView(VIEW_MODE extendedViewMode) {
|
public void setParentChatRef(ChatPanelBasic parentChatRef) {
|
||||||
this.extendedViewMode = extendedViewMode;
|
this.parentChatRef = parentChatRef;
|
||||||
int alpha = 255;
|
}
|
||||||
switch (chatType) {
|
|
||||||
case GAME:
|
|
||||||
case TABLES:
|
|
||||||
case DEFAULT:
|
|
||||||
alpha = CHAT_ALPHA;
|
|
||||||
}
|
|
||||||
this.txtConversation.setExtBackgroundColor(new Color(0, 0, 0, alpha)); // Alpha = 255 not transparent
|
|
||||||
this.txtConversation.setSelectionColor(Color.LIGHT_GRAY);
|
|
||||||
this.jScrollPaneTxt.setOpaque(alpha == 255);
|
|
||||||
this.jScrollPaneTxt.getViewport().setOpaque(chatType != ChatType.TABLES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
public void disableInput() {
|
||||||
this.txtConversation.setText("");
|
this.txtMessage.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public JTextField getTxtMessageInputComponent() {
|
||||||
* This method is called from within the constructor to initialize the form.
|
return this.txtMessage;
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
}
|
||||||
* regenerated by the Form Editor.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents() {
|
|
||||||
|
|
||||||
jScrollPaneTxt = new javax.swing.JScrollPane();
|
public void useExtendedView(VIEW_MODE extendedViewMode) {
|
||||||
txtConversation = new mage.client.components.ColorPane();
|
this.extendedViewMode = extendedViewMode;
|
||||||
txtMessage = new javax.swing.JTextField();
|
int alpha = 255;
|
||||||
|
switch (chatType) {
|
||||||
|
case GAME:
|
||||||
|
case TABLES:
|
||||||
|
case DEFAULT:
|
||||||
|
alpha = CHAT_ALPHA;
|
||||||
|
}
|
||||||
|
this.txtConversation.setExtBackgroundColor(new Color(0, 0, 0, alpha)); // Alpha = 255 not transparent
|
||||||
|
this.txtConversation.setSelectionColor(Color.LIGHT_GRAY);
|
||||||
|
this.jScrollPaneTxt.setOpaque(alpha == 255);
|
||||||
|
this.jScrollPaneTxt.getViewport().setOpaque(chatType != ChatType.TABLES);
|
||||||
|
}
|
||||||
|
|
||||||
jScrollPaneTxt.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
public void clear() {
|
||||||
jScrollPaneTxt.setPreferredSize(new java.awt.Dimension(32767, 32767));
|
this.txtConversation.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
txtConversation.setEditable(false);
|
/**
|
||||||
txtConversation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
* This method is called from within the constructor to initialize the form.
|
||||||
txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
txtConversation.setFocusCycleRoot(false);
|
* regenerated by the Form Editor.
|
||||||
txtConversation.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
*/
|
||||||
txtConversation.setOpaque(false);
|
@SuppressWarnings("unchecked")
|
||||||
jScrollPaneTxt.setViewportView(txtConversation);
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
txtMessage.setMaximumSize(new java.awt.Dimension(5000, 70));
|
jScrollPaneTxt = new javax.swing.JScrollPane();
|
||||||
txtMessage.setMinimumSize(new java.awt.Dimension(6, 70));
|
txtConversation = new mage.client.components.ColorPane();
|
||||||
txtMessage.setName(""); // NOI18N
|
txtMessage = new javax.swing.JTextField();
|
||||||
txtMessage.setPreferredSize(new java.awt.Dimension(6, 70));
|
|
||||||
txtMessage.addKeyListener(new java.awt.event.KeyAdapter() {
|
|
||||||
@Override
|
|
||||||
public void keyTyped(java.awt.event.KeyEvent evt) {
|
|
||||||
txtMessageKeyTyped(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
jScrollPaneTxt.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
||||||
this.setLayout(layout);
|
jScrollPaneTxt.setPreferredSize(new java.awt.Dimension(32767, 32767));
|
||||||
layout.setHorizontalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
|
||||||
.addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
|
|
||||||
.addGap(0, 0, 0)
|
|
||||||
.addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
||||||
);
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
public void handleKeyTyped(java.awt.event.KeyEvent evt) {
|
txtConversation.setEditable(false);
|
||||||
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
txtConversation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
||||||
if (parentChatRef != null) {
|
txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||||
SessionHandler.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
txtConversation.setFocusCycleRoot(false);
|
||||||
} else {
|
txtConversation.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||||
SessionHandler.sendChatMessage(chatId, this.txtMessage.getText());
|
txtConversation.setOpaque(false);
|
||||||
}
|
jScrollPaneTxt.setViewportView(txtConversation);
|
||||||
this.txtMessage.setText("");
|
|
||||||
this.txtMessage.repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableHyperlinks() {
|
txtMessage.setMaximumSize(new java.awt.Dimension(5000, 70));
|
||||||
txtConversation.enableHyperlinks();
|
txtMessage.setMinimumSize(new java.awt.Dimension(6, 70));
|
||||||
}
|
txtMessage.setName(""); // NOI18N
|
||||||
|
txtMessage.setPreferredSize(new java.awt.Dimension(6, 70));
|
||||||
|
txtMessage.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||||
|
@Override
|
||||||
|
public void keyTyped(java.awt.event.KeyEvent evt) {
|
||||||
|
txtMessageKeyTyped(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
handleKeyTyped(evt);
|
this.setLayout(layout);
|
||||||
}//GEN-LAST:event_txtMessageKeyTyped
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||||
|
.addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
|
||||||
|
.addGap(0, 0, 0)
|
||||||
|
.addComponent(txtMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
public void handleKeyTyped(java.awt.event.KeyEvent evt) {
|
||||||
private javax.swing.JScrollPane jScrollPaneTxt;
|
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||||
private mage.client.components.ColorPane txtConversation;
|
if (parentChatRef != null) {
|
||||||
private javax.swing.JTextField txtMessage;
|
SessionHandler.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||||
// End of variables declaration//GEN-END:variables
|
} else {
|
||||||
}
|
SessionHandler.sendChatMessage(chatId, this.txtMessage.getText());
|
||||||
|
}
|
||||||
|
this.txtMessage.setText("");
|
||||||
|
this.txtMessage.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableHyperlinks() {
|
||||||
|
txtConversation.enableHyperlinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
||||||
|
handleKeyTyped(evt);
|
||||||
|
}//GEN-LAST:event_txtMessageKeyTyped
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JScrollPane jScrollPaneTxt;
|
||||||
|
private mage.client.components.ColorPane txtConversation;
|
||||||
|
private javax.swing.JTextField txtMessage;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
|
|
||||||
package mage.client.chat;
|
package mage.client.chat;
|
||||||
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.ColorPane;
|
import mage.client.components.ColorPane;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class ChatPanelSeparated extends ChatPanelBasic {
|
public class ChatPanelSeparated extends ChatPanelBasic {
|
||||||
|
@ -22,42 +20,42 @@ public class ChatPanelSeparated extends ChatPanelBasic {
|
||||||
* Display message in the chat. Use different colors for timestamp, username
|
* Display message in the chat. Use different colors for timestamp, username
|
||||||
* and message.
|
* and message.
|
||||||
*
|
*
|
||||||
* @param username message sender
|
* @param username message sender
|
||||||
* @param message message itself
|
* @param message message itself
|
||||||
* @param time timestamp
|
* @param time timestamp
|
||||||
|
* @param turnInfo game turn info, can be null for non game messages
|
||||||
* @param messageType
|
* @param messageType
|
||||||
* @param color Preferred color. Not used.
|
* @param color Preferred color. Not used.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receiveMessage(String username, String message, Date time, ChatMessage.MessageType messageType, ChatMessage.MessageColor color) {
|
public void receiveMessage(String username, String message, Date time, String turnInfo, ChatMessage.MessageType messageType, ChatMessage.MessageColor color) {
|
||||||
|
String userColor;
|
||||||
|
String textColor;
|
||||||
|
String userSeparator = " ";
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
switch (messageType) {
|
switch (messageType) {
|
||||||
case TALK:
|
case TALK:
|
||||||
case WHISPER_TO:
|
case WHISPER_TO:
|
||||||
case WHISPER_FROM:
|
case WHISPER_FROM:
|
||||||
case USER_INFO:
|
case USER_INFO:
|
||||||
super.receiveMessage(username, message, time, messageType, color);
|
// message in main chat
|
||||||
|
super.receiveMessage(username, message, time, turnInfo, messageType, color);
|
||||||
return;
|
return;
|
||||||
}
|
case STATUS:
|
||||||
StringBuilder text = new StringBuilder();
|
|
||||||
if (time != null) {
|
|
||||||
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": "));
|
|
||||||
}
|
|
||||||
String userColor;
|
|
||||||
String textColor;
|
|
||||||
String userSeparator = " ";
|
|
||||||
switch (messageType) {
|
|
||||||
case STATUS: // a message to all chat user
|
|
||||||
textColor = STATUS_COLOR;
|
textColor = STATUS_COLOR;
|
||||||
userColor = STATUS_COLOR;
|
userColor = STATUS_COLOR;
|
||||||
break;
|
break;
|
||||||
case USER_INFO: // a personal message
|
|
||||||
textColor = USER_INFO_COLOR;
|
|
||||||
userColor = USER_INFO_COLOR;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
case GAME:
|
||||||
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
textColor = MESSAGE_COLOR;
|
textColor = MESSAGE_COLOR;
|
||||||
userSeparator = ": ";
|
userSeparator = ": ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// message in game log
|
||||||
|
if (time != null) {
|
||||||
|
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + (turnInfo == null ? "" : ", " + turnInfo) + ": "));
|
||||||
}
|
}
|
||||||
if (color == ChatMessage.MessageColor.ORANGE) {
|
if (color == ChatMessage.MessageColor.ORANGE) {
|
||||||
textColor = "Orange";
|
textColor = "Orange";
|
||||||
|
|
|
@ -68,7 +68,7 @@ public final class LocalCommands {
|
||||||
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
||||||
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
||||||
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage("", text, new Date(), ChatMessage.MessageColor.BLUE));
|
new ChatMessage("", text, new Date(), null, ChatMessage.MessageColor.BLUE));
|
||||||
MageFrame.getInstance().processCallback(chatMessage);
|
MageFrame.getInstance().processCallback(chatMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3826,7 +3826,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
addAvatar(jPanel32, 32, false, false);
|
addAvatar(jPanel32, 32, false, false);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e, e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,9 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
// send the message to subchat if exists and it's not a game message
|
// send the message to subchat if exists and it's not a game message
|
||||||
if (message.getMessageType() != MessageType.GAME && panel.getConnectedChat() != null) {
|
if (message.getMessageType() != MessageType.GAME && panel.getConnectedChat() != null) {
|
||||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
|
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getTurnInfo(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
|
||||||
} else {
|
} else {
|
||||||
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
|
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getTurnInfo(), message.getMessageType(), message.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -444,11 +444,11 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
.append("<br/>").append("<b>/pings</b> - show players and watchers ping")
|
.append("<br/>").append("<b>/pings</b> - show players and watchers ping")
|
||||||
.append("<br/>").append("<b>/fix</b> - fix freezed game")
|
.append("<br/>").append("<b>/fix</b> - fix freezed game")
|
||||||
.toString(),
|
.toString(),
|
||||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
null, null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||||
break;
|
break;
|
||||||
case TOURNAMENT:
|
case TOURNAMENT:
|
||||||
usedPanel.receiveMessage("", "On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.",
|
usedPanel.receiveMessage("", "On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.",
|
||||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
null, null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||||
break;
|
break;
|
||||||
case TABLES:
|
case TABLES:
|
||||||
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
|
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
|
||||||
|
@ -457,7 +457,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
.append("<br/>\\list - show a list of available chat commands.")
|
.append("<br/>\\list - show a list of available chat commands.")
|
||||||
.append("<br/>").append(IgnoreList.usage(serverAddress))
|
.append("<br/>").append(IgnoreList.usage(serverAddress))
|
||||||
.append("<br/>Type <font color=green>\\w yourUserName profanity 0 (or 1 or 2)</font> to turn off/on the profanity filter").toString(),
|
.append("<br/>Type <font color=green>\\w yourUserName profanity 0 (or 1 or 2)</font> to turn off/on the profanity filter").toString(),
|
||||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
null, null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -470,7 +470,7 @@ public final class ImageCache {
|
||||||
image = ImageIO.read(inputStream);
|
image = ImageIO.read(inputStream);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(e, e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
@ -488,7 +488,7 @@ public final class ImageCache {
|
||||||
ImageIO.write(image, format, outputStream);
|
ImageIO.write(image, format, outputStream);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error(e, e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
imageFile.delete();
|
imageFile.delete();
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ChatMessage implements Serializable {
|
public class ChatMessage implements Serializable {
|
||||||
|
@ -14,6 +13,7 @@ public class ChatMessage implements Serializable {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
private Date time;
|
private Date time;
|
||||||
|
private String turnInfo;
|
||||||
private String message;
|
private String message;
|
||||||
private MessageColor color;
|
private MessageColor color;
|
||||||
private SoundToPlay soundToPlay;
|
private SoundToPlay soundToPlay;
|
||||||
|
@ -31,23 +31,39 @@ public class ChatMessage implements Serializable {
|
||||||
PlayerLeft, PlayerQuitTournament, PlayerSubmittedDeck, PlayerWhispered
|
PlayerLeft, PlayerQuitTournament, PlayerSubmittedDeck, PlayerWhispered
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatMessage(String username, String message, Date time, MessageColor color) {
|
public ChatMessage(String username, String message, Date time, Game game, MessageColor color) {
|
||||||
this(username, message, time, color, null);
|
this(username, message, time, game, color, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatMessage(String username, String message, Date time, MessageColor color, SoundToPlay soundToPlay) {
|
public ChatMessage(String username, String message, Date time, Game game, MessageColor color, SoundToPlay soundToPlay) {
|
||||||
this(username, message, time, color, MessageType.TALK, soundToPlay);
|
this(username, message, time, null, color, MessageType.TALK, soundToPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatMessage(String username, String message, Date time, MessageColor color, MessageType messageType, SoundToPlay soundToPlay) {
|
public ChatMessage(String username, String message, Date time, Game game, MessageColor color, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
|
this.turnInfo = prepareTurnInfo(game);
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.messageType = messageType;
|
this.messageType = messageType;
|
||||||
this.soundToPlay = soundToPlay;
|
this.soundToPlay = soundToPlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String prepareTurnInfo(Game game) {
|
||||||
|
// no turn info
|
||||||
|
if (game == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not started game
|
||||||
|
if (game.getStep() == null) {
|
||||||
|
return "T0";
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal game
|
||||||
|
return "T" + game.getTurnNum() + "." + game.getStep().getType().getStepShortText();
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -57,11 +73,11 @@ public class ChatMessage implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUserMessage() {
|
public boolean isUserMessage() {
|
||||||
return color != null && (color==MessageColor.BLUE || color==MessageColor.YELLOW);
|
return color != null && (color == MessageColor.BLUE || color == MessageColor.YELLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatusMessage() {
|
public boolean isStatusMessage() {
|
||||||
return color != null && color== MessageColor.ORANGE;
|
return color != null && color == MessageColor.ORANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
@ -72,6 +88,10 @@ public class ChatMessage implements Serializable {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTurnInfo() {
|
||||||
|
return turnInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public SoundToPlay getSoundToPlay() {
|
public SoundToPlay getSoundToPlay() {
|
||||||
return soundToPlay;
|
return soundToPlay;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package mage.server;
|
||||||
|
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
|
import mage.game.Game;
|
||||||
import mage.server.exceptions.UserNotFoundException;
|
import mage.server.exceptions.UserNotFoundException;
|
||||||
import mage.server.game.GameController;
|
import mage.server.game.GameController;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
|
@ -81,17 +82,9 @@ public enum ChatManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime) {
|
|
||||||
this.broadcast(chatId, userName, message, color, withTime, MessageType.TALK);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime, MessageType messageType) {
|
|
||||||
this.broadcast(chatId, userName, message, color, withTime, messageType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Pattern cardNamePattern = Pattern.compile("\\[(.*?)\\]");
|
final Pattern cardNamePattern = Pattern.compile("\\[(.*?)\\]");
|
||||||
|
|
||||||
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime, Game game, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
ChatSession chatSession = chatSessions.get(chatId);
|
ChatSession chatSession = chatSessions.get(chatId);
|
||||||
if (chatSession != null) {
|
if (chatSession != null) {
|
||||||
if (message.startsWith("\\") || message.startsWith("/")) {
|
if (message.startsWith("\\") || message.startsWith("/")) {
|
||||||
|
@ -163,7 +156,7 @@ public enum ChatManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
|
chatSession.broadcast(userName, message, color, withTime, game, messageType, soundToPlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +317,7 @@ public enum ChatManager {
|
||||||
getChatSessions()
|
getChatSessions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(chat -> chat.hasUser(userId))
|
.filter(chat -> chat.hasUser(userId))
|
||||||
.forEach(session -> session.broadcast(user.getName(), message, color, true, MessageType.TALK, null));
|
.forEach(session -> session.broadcast(user.getName(), message, color, true, null, MessageType.TALK, null));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -334,7 +327,7 @@ public enum ChatManager {
|
||||||
-> getChatSessions()
|
-> getChatSessions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(chat -> chat.hasUser(userId))
|
.filter(chat -> chat.hasUser(userId))
|
||||||
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null)));
|
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, null, MessageType.STATUS, null)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +350,7 @@ public enum ChatManager {
|
||||||
|
|
||||||
if (chatSessions.size() > 0) {
|
if (chatSessions.size() > 0) {
|
||||||
logger.info("INFORM OPPONENTS by " + user.getName() + ": " + message);
|
logger.info("INFORM OPPONENTS by " + user.getName() + ": " + message);
|
||||||
chatSessions.forEach(chatSession -> chatSession.broadcast(null, message, MessageColor.BLUE, true, MessageType.STATUS, null));
|
chatSessions.forEach(chatSession -> chatSession.broadcast(null, message, MessageColor.BLUE, true, null, MessageType.STATUS, null));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
|
import mage.view.ChatMessage;
|
||||||
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
import mage.view.ChatMessage.MessageType;
|
||||||
|
import mage.view.ChatMessage.SoundToPlay;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -8,13 +16,6 @@ import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
|
||||||
import mage.interfaces.callback.ClientCallbackMethod;
|
|
||||||
import mage.view.ChatMessage;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
|
||||||
import mage.view.ChatMessage.MessageType;
|
|
||||||
import mage.view.ChatMessage.SoundToPlay;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -48,7 +49,7 @@ public class ChatSession {
|
||||||
} finally {
|
} finally {
|
||||||
w.unlock();
|
w.unlock();
|
||||||
}
|
}
|
||||||
broadcast(null, userName + " has joined (" + user.getClientVersion() + ')', MessageColor.BLUE, true, MessageType.STATUS, null);
|
broadcast(null, userName + " has joined (" + user.getClientVersion() + ')', MessageColor.BLUE, true, null, MessageType.STATUS, null);
|
||||||
logger.trace(userName + " joined chat " + chatId);
|
logger.trace(userName + " joined chat " + chatId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -76,7 +77,7 @@ public class ChatSession {
|
||||||
String message = reason.getMessage();
|
String message = reason.getMessage();
|
||||||
|
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
broadcast(null, userName + message, MessageColor.BLUE, true, null, MessageType.STATUS, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -86,7 +87,8 @@ public class ChatSession {
|
||||||
|
|
||||||
public boolean broadcastInfoToUser(User toUser, String message) {
|
public boolean broadcastInfoToUser(User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(null, message, new Date(), MessageColor.BLUE, MessageType.USER_INFO, null)));
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
|
new ChatMessage(null, message, new Date(), null, MessageColor.BLUE, MessageType.USER_INFO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,20 +97,21 @@ public class ChatSession {
|
||||||
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(fromUser.getName(), message, new Date(), MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
new ChatMessage(fromUser.getName(), message, new Date(), null, MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
||||||
if (clients.containsKey(fromUser.getId())) {
|
if (clients.containsKey(fromUser.getId())) {
|
||||||
fromUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
fromUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(toUser.getName(), message, new Date(), MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
new ChatMessage(toUser.getName(), message, new Date(), null, MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
public void broadcast(String userName, String message, MessageColor color, boolean withTime, Game game, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
Set<UUID> clientsToRemove = new HashSet<>();
|
Set<UUID> clientsToRemove = new HashSet<>();
|
||||||
ClientCallback clientCallback = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(userName, message, (withTime ? new Date() : null), color, messageType, soundToPlay));
|
ClientCallback clientCallback = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
|
new ChatMessage(userName, message, (withTime ? new Date() : null), game, color, messageType, soundToPlay));
|
||||||
List<UUID> chatUserIds = new ArrayList<>();
|
List<UUID> chatUserIds = new ArrayList<>();
|
||||||
final Lock r = lock.readLock();
|
final Lock r = lock.readLock();
|
||||||
r.lock();
|
r.lock();
|
||||||
|
|
|
@ -10,7 +10,6 @@ import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
import mage.game.GameException;
|
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
@ -494,7 +493,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
() -> ChatManager.instance.broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE, true, ChatMessage.MessageType.TALK, null)
|
() -> ChatManager.instance.broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null)
|
||||||
);
|
);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
@ -1129,9 +1128,9 @@ public class MageServerImpl implements MageServer {
|
||||||
execute("sendBroadcastMessage", sessionId, () -> {
|
execute("sendBroadcastMessage", sessionId, () -> {
|
||||||
for (User user : UserManager.instance.getUsers()) {
|
for (User user : UserManager.instance.getUsers()) {
|
||||||
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
||||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, null, MessageColor.RED)));
|
||||||
} else {
|
} else {
|
||||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, null, MessageColor.BLUE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
@ -545,7 +545,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
ChatManager.instance.broadcast(chatId, user.get().getName(), "has left the table", ChatMessage.MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, ChatMessage.SoundToPlay.PlayerLeft);
|
ChatManager.instance.broadcast(chatId, user.get().getName(), "has left the table", ChatMessage.MessageColor.BLUE, true, null, ChatMessage.MessageType.STATUS, ChatMessage.SoundToPlay.PlayerLeft);
|
||||||
if (!table.isTournamentSubTable()) {
|
if (!table.isTournamentSubTable()) {
|
||||||
user.get().removeTable(playerId);
|
user.get().removeTable(playerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,11 +120,11 @@ public class GameController implements GameCallback {
|
||||||
updateGame();
|
updateGame();
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, MessageType.GAME, null);
|
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, event.getGame(), MessageType.GAME, null);
|
||||||
logger.trace(game.getId() + " " + event.getMessage());
|
logger.trace(game.getId() + " " + event.getMessage());
|
||||||
break;
|
break;
|
||||||
case STATUS:
|
case STATUS:
|
||||||
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime(), MessageType.GAME, null);
|
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime(), event.getWithTurnInfo() ? event.getGame() : null, MessageType.GAME, null);
|
||||||
logger.trace(game.getId() + " " + event.getMessage());
|
logger.trace(game.getId() + " " + event.getMessage());
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
|
@ -300,7 +300,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
user.get().addGame(playerId, gameSession);
|
user.get().addGame(playerId, gameSession);
|
||||||
logger.debug("Player " + player.getName() + ' ' + playerId + " has " + joinType + " gameId: " + game.getId());
|
logger.debug("Player " + player.getName() + ' ' + playerId + " has " + joinType + " gameId: " + game.getId());
|
||||||
ChatManager.instance.broadcast(chatId, "", game.getPlayer(playerId).getLogName() + " has " + joinType + " the game", MessageColor.ORANGE, true, MessageType.GAME, null);
|
ChatManager.instance.broadcast(chatId, "", game.getPlayer(playerId).getLogName() + " has " + joinType + " the game", MessageColor.ORANGE, true, game, MessageType.GAME, null);
|
||||||
checkStart();
|
checkStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ public class GameController implements GameCallback {
|
||||||
+ " is forced to join the game (waiting ends after "
|
+ " is forced to join the game (waiting ends after "
|
||||||
+ GAME_TIMEOUTS_CANCEL_PLAYER_GAME_JOINING_AFTER_INACTIVE_SECS
|
+ GAME_TIMEOUTS_CANCEL_PLAYER_GAME_JOINING_AFTER_INACTIVE_SECS
|
||||||
+ " secs, applied fixes: " + problemPlayerFixes + ")",
|
+ " secs, applied fixes: " + problemPlayerFixes + ")",
|
||||||
MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, null);
|
MessageColor.BLUE, true, game, ChatMessage.MessageType.STATUS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.isConnected() && user.getSecondsDisconnected() > GAME_TIMEOUTS_CANCEL_PLAYER_GAME_JOINING_AFTER_INACTIVE_SECS) {
|
if (!user.isConnected() && user.getSecondsDisconnected() > GAME_TIMEOUTS_CANCEL_PLAYER_GAME_JOINING_AFTER_INACTIVE_SECS) {
|
||||||
|
@ -425,7 +425,7 @@ public class GameController implements GameCallback {
|
||||||
// Dont want people on our ignore list to stalk us
|
// Dont want people on our ignore list to stalk us
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.showUserMessage("Not allowed", "You are banned from watching this game");
|
user.showUserMessage("Not allowed", "You are banned from watching this game");
|
||||||
ChatManager.instance.broadcast(chatId, user.getName(), " tried to join, but is banned", MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, user.getName(), " tried to join, but is banned", MessageColor.BLUE, true, game, ChatMessage.MessageType.STATUS, null);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
gameWatcher.init();
|
gameWatcher.init();
|
||||||
user.addGameWatchInfo(game.getId());
|
user.addGameWatchInfo(game.getId());
|
||||||
ChatManager.instance.broadcast(chatId, user.getName(), " has started watching", MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, user.getName(), " has started watching", MessageColor.BLUE, true, game, ChatMessage.MessageType.STATUS, null);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,7 @@ public class GameController implements GameCallback {
|
||||||
w.unlock();
|
w.unlock();
|
||||||
}
|
}
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
ChatManager.instance.broadcast(chatId, user.getName(), " has stopped watching", MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, user.getName(), " has stopped watching", MessageColor.BLUE, true, game, ChatMessage.MessageType.STATUS, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ public class GameController implements GameCallback {
|
||||||
String sb = player.getLogName()
|
String sb = player.getLogName()
|
||||||
+ " has timed out (player had priority and was not active for "
|
+ " has timed out (player had priority and was not active for "
|
||||||
+ ConfigSettings.instance.getMaxSecondsIdle() + " seconds ) - Auto concede.";
|
+ ConfigSettings.instance.getMaxSecondsIdle() + " seconds ) - Auto concede.";
|
||||||
ChatManager.instance.broadcast(chatId, "", sb, MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", sb, MessageColor.BLACK, true, game, MessageType.STATUS, null);
|
||||||
game.idleTimeout(playerId);
|
game.idleTimeout(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
|
|
||||||
package mage.server.tournament;
|
package mage.server.tournament;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -38,6 +31,12 @@ import mage.view.ChatMessage.SoundToPlay;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -68,7 +67,7 @@ public class TournamentController {
|
||||||
checkPlayersState();
|
checkPlayersState();
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, null, MessageType.STATUS, null);
|
||||||
logger.debug(tournament.getId() + " " + event.getMessage());
|
logger.debug(tournament.getId() + " " + event.getMessage());
|
||||||
break;
|
break;
|
||||||
case START_DRAFT:
|
case START_DRAFT:
|
||||||
|
@ -123,7 +122,7 @@ public class TournamentController {
|
||||||
if (!player.getPlayer().isHuman()) {
|
if (!player.getPlayer().isHuman()) {
|
||||||
player.setJoined();
|
player.setJoined();
|
||||||
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
||||||
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, null, MessageType.STATUS, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkStart();
|
checkStart();
|
||||||
|
@ -140,7 +139,7 @@ public class TournamentController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tournamentSessions.containsKey(playerId)) {
|
if (tournamentSessions.containsKey(playerId)) {
|
||||||
logger.debug("player reopened tournament panel userId: " + userId + " tournamentId: " + tournament.getId());
|
logger.debug("player reopened tournament panel userId: " + userId + " tournamentId: " + tournament.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// first join of player
|
// first join of player
|
||||||
|
@ -153,7 +152,7 @@ public class TournamentController {
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
player.setJoined();
|
player.setJoined();
|
||||||
logger.debug("player " + player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
|
logger.debug("player " + player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
|
||||||
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, null, MessageType.STATUS, null);
|
||||||
checkStart();
|
checkStart();
|
||||||
} else {
|
} else {
|
||||||
logger.error("User not found userId: " + userId + " tournamentId: " + tournament.getId());
|
logger.error("User not found userId: " + userId + " tournamentId: " + tournament.getId());
|
||||||
|
@ -320,7 +319,7 @@ public class TournamentController {
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
if (player != null && !player.hasQuit()) {
|
if (player != null && !player.hasQuit()) {
|
||||||
tournamentSessions.get(playerId).submitDeck(deck);
|
tournamentSessions.get(playerId).submitDeck(deck);
|
||||||
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has submitted their tournament deck", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerSubmittedDeck);
|
ChatManager.instance.broadcast(chatId, "", player.getPlayer().getLogName() + " has submitted their tournament deck", MessageColor.BLACK, true, null, MessageType.STATUS, SoundToPlay.PlayerSubmittedDeck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,12 +404,11 @@ public class TournamentController {
|
||||||
tournamentPlayer.setQuit(info, status);
|
tournamentPlayer.setQuit(info, status);
|
||||||
tournament.quit(playerId);
|
tournament.quit(playerId);
|
||||||
tournamentSession.quit();
|
tournamentSession.quit();
|
||||||
ChatManager.instance.broadcast(chatId, "", tournamentPlayer.getPlayer().getLogName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
ChatManager.instance.broadcast(chatId, "", tournamentPlayer.getPlayer().getLogName() + " has quit the tournament", MessageColor.BLACK, true, null, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkToReplaceDraftPlayerByAi(UUID userId, TournamentPlayer leavingPlayer) {
|
private boolean checkToReplaceDraftPlayerByAi(UUID userId, TournamentPlayer leavingPlayer) {
|
||||||
|
|
||||||
int humans = 0;
|
int humans = 0;
|
||||||
for (TournamentPlayer tPlayer : tournament.getPlayers()) {
|
for (TournamentPlayer tPlayer : tournament.getPlayers()) {
|
||||||
if (tPlayer.getPlayer().isHuman()) {
|
if (tPlayer.getPlayer().isHuman()) {
|
||||||
|
@ -432,7 +430,7 @@ public class TournamentController {
|
||||||
user.get().removeTable(leavingPlayer.getPlayer().getId());
|
user.get().removeTable(leavingPlayer.getPlayer().getId());
|
||||||
user.get().removeTournament(leavingPlayer.getPlayer().getId());
|
user.get().removeTournament(leavingPlayer.getPlayer().getId());
|
||||||
}
|
}
|
||||||
ChatManager.instance.broadcast(chatId, "", leavingPlayer.getPlayer().getLogName() + " was replaced by draftbot", MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", leavingPlayer.getPlayer().getLogName() + " was replaced by draftbot", MessageColor.BLACK, true, null, MessageType.STATUS, null);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.server.util;
|
package mage.server.util;
|
||||||
|
|
||||||
import mage.utils.StreamUtils;
|
import mage.utils.StreamUtils;
|
||||||
|
@ -122,7 +121,7 @@ public enum ServerMessagesUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> newMessages = new ArrayList<>();
|
List<String> newMessages = new ArrayList<>();
|
||||||
try(Scanner scanner = new Scanner(is)) {
|
try (Scanner scanner = new Scanner(is)) {
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String message = scanner.nextLine();
|
String message = scanner.nextLine();
|
||||||
if (!message.trim().isEmpty()) {
|
if (!message.trim().isEmpty()) {
|
||||||
|
@ -130,7 +129,7 @@ public enum ServerMessagesUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
StreamUtils.closeQuietly(is);
|
StreamUtils.closeQuietly(is);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class MulliganTestBase {
|
||||||
Mulligan mulligan = mulliganType.getMulligan(freeMulligans);
|
Mulligan mulligan = mulliganType.getMulligan(freeMulligans);
|
||||||
Game game = new TwoPlayerDuel(LEFT, ONE, mulligan, 20) {
|
Game game = new TwoPlayerDuel(LEFT, ONE, mulligan, 20) {
|
||||||
@Override
|
@Override
|
||||||
public void fireStatusEvent(String message, boolean withTime) {
|
public void fireStatusEvent(String message, boolean withTime, boolean withTurnInfo) {
|
||||||
super.fireStatusEvent(message, withTime);
|
super.fireStatusEvent(message, withTime, withTurnInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,44 +1,45 @@
|
||||||
package mage.constants;
|
package mage.constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public enum PhaseStep {
|
public enum PhaseStep {
|
||||||
UNTAP ("Untap", 0, "untap step"),
|
UNTAP("Untap", 0, "untap step", "UN"),
|
||||||
UPKEEP ("Upkeep", 1, "upkeep"), // card texts don't use the word "step" for this phase step
|
UPKEEP("Upkeep", 1, "upkeep", "UP"), // card texts don't use the word "step" for this phase step
|
||||||
DRAW ("Draw", 2, "draw step"),
|
DRAW("Draw", 2, "draw step", "DR"),
|
||||||
PRECOMBAT_MAIN ("Precombat Main", 3,"precombat main step"),
|
PRECOMBAT_MAIN("Precombat Main", 3, "precombat main step", "PM"),
|
||||||
BEGIN_COMBAT ("Begin Combat", 4, "begin combat step"),
|
BEGIN_COMBAT("Begin Combat", 4, "begin combat step", "BC"),
|
||||||
DECLARE_ATTACKERS ("Declare Attackers", 5, "declare attackers step"),
|
DECLARE_ATTACKERS("Declare Attackers", 5, "declare attackers step", "DA"),
|
||||||
DECLARE_BLOCKERS ("Declare Blockers", 6, "declare blockers step"),
|
DECLARE_BLOCKERS("Declare Blockers", 6, "declare blockers step", "DB"),
|
||||||
FIRST_COMBAT_DAMAGE ("First Combat Damage", 7, "first combat damage"),
|
FIRST_COMBAT_DAMAGE("First Combat Damage", 7, "first combat damage", "FCD"),
|
||||||
COMBAT_DAMAGE ("Combat Damage", 8, "combat damage step"),
|
COMBAT_DAMAGE("Combat Damage", 8, "combat damage step", "CD"),
|
||||||
END_COMBAT ("End Combat", 9, "end combat step"),
|
END_COMBAT("End Combat", 9, "end combat step", "EC"),
|
||||||
POSTCOMBAT_MAIN ("Postcombat Main", 10, "postcombat main step"),
|
POSTCOMBAT_MAIN("Postcombat Main", 10, "postcombat main step", "PM"),
|
||||||
END_TURN ("End Turn", 11, "end turn step"),
|
END_TURN("End Turn", 11, "end turn step", "ET"),
|
||||||
CLEANUP ("Cleanup", 12, "cleanup step");
|
CLEANUP("Cleanup", 12, "cleanup step", "CL");
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
private final String stepText;
|
private final String stepText;
|
||||||
|
private final String stepShortText; // for chats/logs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index is used for game state scoring system.
|
* Index is used for game state scoring system.
|
||||||
*/
|
*/
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
PhaseStep(String text, int index, String stepText) {
|
PhaseStep(String text, int index, String stepText, String stepShortText) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.stepText = stepText;
|
this.stepText = stepText;
|
||||||
|
this.stepShortText = stepShortText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBefore(PhaseStep other){
|
public boolean isBefore(PhaseStep other) {
|
||||||
return this.getIndex()<other.getIndex();
|
return this.getIndex() < other.getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAfter(PhaseStep other){
|
public boolean isAfter(PhaseStep other) {
|
||||||
return this.getIndex()>other.getIndex();
|
return this.getIndex() > other.getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
|
@ -54,4 +55,7 @@ public enum PhaseStep {
|
||||||
return stepText;
|
return stepText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStepShortText() {
|
||||||
|
return stepShortText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import mage.MageItem;
|
import mage.MageItem;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -44,6 +41,10 @@ import mage.players.Players;
|
||||||
import mage.util.MessageToClient;
|
import mage.util.MessageToClient;
|
||||||
import mage.util.functions.ApplyToPermanent;
|
import mage.util.functions.ApplyToPermanent;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface Game extends MageItem, Serializable {
|
public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
MatchType getGameType();
|
MatchType getGameType();
|
||||||
|
@ -266,7 +267,7 @@ public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
void fireInformEvent(String message);
|
void fireInformEvent(String message);
|
||||||
|
|
||||||
void fireStatusEvent(String message, boolean withTime);
|
void fireStatusEvent(String message, boolean withTime, boolean withTurnInfo);
|
||||||
|
|
||||||
void fireUpdatePlayersEvent();
|
void fireUpdatePlayersEvent();
|
||||||
|
|
||||||
|
@ -299,9 +300,9 @@ public interface Game extends MageItem, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates and fires an damage prevention event
|
* Creates and fires an damage prevention event
|
||||||
*
|
*
|
||||||
* @param damageEvent damage event that will be replaced (instanceof check
|
* @param damageEvent damage event that will be replaced (instanceof check
|
||||||
* will be done)
|
* will be done)
|
||||||
* @param source ability that's the source of the prevention effect
|
* @param source ability that's the source of the prevention effect
|
||||||
* @param game
|
* @param game
|
||||||
* @param amountToPrevent max preventable amount
|
* @param amountToPrevent max preventable amount
|
||||||
* @return true prevention was successfull / false prevention was replaced
|
* @return true prevention was successfull / false prevention was replaced
|
||||||
|
@ -311,12 +312,12 @@ public interface Game extends MageItem, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates and fires an damage prevention event
|
* Creates and fires an damage prevention event
|
||||||
*
|
*
|
||||||
* @param event damage event that will be replaced (instanceof check will be
|
* @param event damage event that will be replaced (instanceof check will be
|
||||||
* done)
|
* done)
|
||||||
* @param source ability that's the source of the prevention effect
|
* @param source ability that's the source of the prevention effect
|
||||||
* @param game
|
* @param game
|
||||||
* @param preventAllDamage true if there is no limit to the damage that can
|
* @param preventAllDamage true if there is no limit to the damage that can
|
||||||
* be prevented
|
* be prevented
|
||||||
* @return true prevention was successfull / false prevention was replaced
|
* @return true prevention was successfull / false prevention was replaced
|
||||||
*/
|
*/
|
||||||
PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, boolean preventAllDamage);
|
PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, boolean preventAllDamage);
|
||||||
|
|
|
@ -921,7 +921,7 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
if (startMessage == null || startMessage.isEmpty()) {
|
if (startMessage == null || startMessage.isEmpty()) {
|
||||||
startMessage = "Game has started";
|
startMessage = "Game has started";
|
||||||
}
|
}
|
||||||
fireStatusEvent(startMessage, false);
|
fireStatusEvent(startMessage, false, false);
|
||||||
|
|
||||||
saveState(false);
|
saveState(false);
|
||||||
|
|
||||||
|
@ -2369,11 +2369,11 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireStatusEvent(String message, boolean withTime) {
|
public void fireStatusEvent(String message, boolean withTime, boolean withTurnInfo) {
|
||||||
if (simulation) {
|
if (simulation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tableEventSource.fireTableEvent(EventType.STATUS, message, withTime, this);
|
tableEventSource.fireTableEvent(EventType.STATUS, message, withTime, withTurnInfo, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.EventObject;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -13,8 +8,11 @@ import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.MultiplayerRound;
|
import mage.game.tournament.MultiplayerRound;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TableEvent extends EventObject implements ExternalEvent, Serializable {
|
public class TableEvent extends EventObject implements ExternalEvent, Serializable {
|
||||||
|
@ -37,6 +35,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
private MatchOptions options;
|
private MatchOptions options;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
private boolean withTime;
|
private boolean withTime;
|
||||||
|
private boolean withTurnInfo;
|
||||||
|
|
||||||
public TableEvent(EventType eventType) {
|
public TableEvent(EventType eventType) {
|
||||||
super(eventType);
|
super(eventType);
|
||||||
|
@ -48,11 +47,16 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableEvent(EventType eventType, String message, boolean withTime, Game game) {
|
public TableEvent(EventType eventType, String message, boolean withTime, Game game) {
|
||||||
|
this(eventType, message, withTime, withTime, game); // turn info with time always (exception: start turn message)
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableEvent(EventType eventType, String message, boolean withTime, boolean withTurnInfo, Game game) {
|
||||||
super(game);
|
super(game);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
this.withTime = withTime;
|
this.withTime = withTime;
|
||||||
|
this.withTurnInfo = withTurnInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableEvent(EventType eventType, String message, Cards cards, Game game) {
|
public TableEvent(EventType eventType, String message, Cards cards, Game game) {
|
||||||
|
@ -91,7 +95,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableEvent(EventType eventType, MultiplayerRound round, MatchOptions options) {
|
public TableEvent(EventType eventType, MultiplayerRound round, MatchOptions options) {
|
||||||
super(options);
|
super(options);
|
||||||
this.round = round;
|
this.round = round;
|
||||||
|
@ -134,7 +138,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
public TournamentPairing getPair() {
|
public TournamentPairing getPair() {
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiplayerRound getMultiplayerRound() {
|
public MultiplayerRound getMultiplayerRound() {
|
||||||
return round;
|
return round;
|
||||||
}
|
}
|
||||||
|
@ -150,4 +154,8 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
public boolean getWithTime() {
|
public boolean getWithTime() {
|
||||||
return withTime;
|
return withTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getWithTurnInfo() {
|
||||||
|
return withTurnInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
|
@ -8,19 +6,19 @@ import mage.game.Game;
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
import mage.game.events.TableEvent.EventType;
|
import mage.game.events.TableEvent.EventType;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
|
import mage.game.tournament.MultiplayerRound;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.game.tournament.MultiplayerRound;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
||||||
|
|
||||||
protected final EventDispatcher<TableEvent> dispatcher = new EventDispatcher<TableEvent>() {};
|
protected final EventDispatcher<TableEvent> dispatcher = new EventDispatcher<TableEvent>() {
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(Listener<TableEvent> listener) {
|
public void addListener(Listener<TableEvent> listener) {
|
||||||
|
@ -31,7 +29,7 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
||||||
public void removeAllListener() {
|
public void removeAllListener() {
|
||||||
dispatcher.removeAllListener();
|
dispatcher.removeAllListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void fireTableEvent(EventType eventType) {
|
public void fireTableEvent(EventType eventType) {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType));
|
dispatcher.fireEvent(new TableEvent(eventType));
|
||||||
|
@ -41,8 +39,8 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, message, game));
|
dispatcher.fireEvent(new TableEvent(eventType, message, game));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireTableEvent(EventType eventType, String message, boolean withTime, Game game) {
|
public void fireTableEvent(EventType eventType, String message, boolean withTime, boolean withTurnInfo, Game game) {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, message, withTime, game));
|
dispatcher.fireEvent(new TableEvent(eventType, message, withTime, withTurnInfo, game));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireTableEvent(EventType eventType, UUID playerId, String message, Game game) {
|
public void fireTableEvent(EventType eventType, UUID playerId, String message, Game game) {
|
||||||
|
@ -68,7 +66,7 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
||||||
public void fireTableEvent(EventType eventType, TournamentPairing pair, MatchOptions options) {
|
public void fireTableEvent(EventType eventType, TournamentPairing pair, MatchOptions options) {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, pair, options));
|
dispatcher.fireEvent(new TableEvent(eventType, pair, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireTableEvent(EventType eventType, MultiplayerRound round, MatchOptions options) {
|
public void fireTableEvent(EventType eventType, MultiplayerRound round, MatchOptions options) {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, round, options));
|
dispatcher.fireEvent(new TableEvent(eventType, round, options));
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,6 +333,6 @@ public class Turn implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append(')');
|
sb.append(')');
|
||||||
game.fireStatusEvent(sb.toString(), true);
|
game.fireStatusEvent(sb.toString(), true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue