Changed color of frame of avatar for active player to green again. Checked that a player of a game can't also watch his own game. Added a match score to the start of the game log. Changed the color of the Turn [X] message. Tips and join messages during a game are displayed in the chat panel instead the game log panel. Display of the player name when hovering over the avatar is more vertical centered.

This commit is contained in:
LevelX2 2013-04-07 21:29:27 +02:00
parent 20a99ed894
commit f644ffe041
16 changed files with 100 additions and 22 deletions

View file

@ -71,6 +71,10 @@ public class ChatManager {
chatSessions.get(chatId).broadcast(userName, message, color);
}
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime) {
chatSessions.get(chatId).broadcast(userName, message, color, withTime);
}
/**
*
* use mainly for announcing that a user connection was lost or that a user has reconnected

View file

@ -59,7 +59,7 @@ public class ChatSession {
if (user != null && !clients.containsKey(userId)) {
String userName = user.getName();
clients.put(userId, userName);
broadcast(userName, " has joined", MessageColor.BLACK);
broadcast(userName, " has joined", MessageColor.BLUE);
logger.info(userName + " joined chat " + chatId);
}
}
@ -68,16 +68,20 @@ public class ChatSession {
if (userId != null && clients.containsKey(userId)) {
String userName = clients.get(userId);
clients.remove(userId);
broadcast(userName, " has left", MessageColor.BLACK);
broadcast(userName, " has left", MessageColor.BLUE);
logger.info(userName + " has left chat " + chatId);
}
}
public void broadcast(String userName, String message, MessageColor color) {
broadcast(userName, message, color, true);
}
public void broadcast(String userName, String message, MessageColor color, boolean withTime) {
if (!message.isEmpty()) {
Calendar cal = new GregorianCalendar();
final String msg = message;
final String time = timeFormatter.format(cal.getTime());
final String time = (withTime ? timeFormatter.format(cal.getTime()):"");
final String username = userName;
logger.debug("Broadcasting '" + msg + "' for " + chatId);
for (UUID userId: clients.keySet()) {

View file

@ -40,6 +40,7 @@ import mage.MageException;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException;
import mage.game.Game;
import mage.game.GameException;
import mage.game.GameOptions;
import mage.game.Seat;
@ -63,6 +64,7 @@ import mage.server.tournament.TournamentFactory;
import mage.server.tournament.TournamentManager;
import mage.server.util.ServerMessagesUtil;
import mage.server.util.ThreadExecutor;
import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
@ -248,6 +250,10 @@ public class TableController {
if (table.getState() != TableState.DUELING) {
return false;
}
// you can't watch your own game
if (userPlayerMap.get(userId) != null) {
return false;
}
UserManager.getInstance().getUser(userId).watchGame(match.getGame().getId());
return true;
}

View file

@ -114,6 +114,10 @@ public class GameController implements GameCallback {
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
logger.debug(game.getId() + " " + event.getMessage());
break;
case STATUS:
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime());
logger.debug(game.getId() + " " + event.getMessage());
break;
case REVEAL:
revealCards(event.getMessage(), event.getCards());
break;
@ -180,11 +184,7 @@ public class GameController implements GameCallback {
}
}
);
for (Player player: game.getPlayers().values()) {
if (!player.isHuman()) {
ChatManager.getInstance().broadcast(chatId, "", player.getName() + " has joined the game", MessageColor.BLACK);
}
}
checkStart();
}
@ -240,15 +240,21 @@ public class GameController implements GameCallback {
}
public void watch(UUID userId) {
GameWatcher gameWatcher = new GameWatcher(userId, game);
watchers.put(userId, gameWatcher);
gameWatcher.init();
ChatManager.getInstance().broadcast(chatId, "", " has started watching", MessageColor.BLACK);
User user = UserManager.getInstance().getUser(userId);
if (user != null) {
GameWatcher gameWatcher = new GameWatcher(userId, game);
watchers.put(userId, gameWatcher);
gameWatcher.init();
ChatManager.getInstance().broadcast(chatId, user.getName(), " has started watching", MessageColor.BLUE);
}
}
public void stopWatching(UUID userId) {
watchers.remove(userId);
ChatManager.getInstance().broadcast(chatId, "", " has stopped watching", MessageColor.BLACK);
User user = UserManager.getInstance().getUser(userId);
if (user != null) {
ChatManager.getInstance().broadcast(chatId, user.getName(), " has stopped watching", MessageColor.BLUE);
}
}
public void concede(UUID userId) {