diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index e7f921de2b..bc4bf425b0 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -181,11 +181,14 @@ public enum ChatManager { + "
\\me - shows the history of the current player" + "
\\list or \\l - Show a list of commands" + "
\\whisper or \\w [player name] [text] - whisper to the player with the given name" + + "
\\card Card Name - Print oracle text for card" + "
[Card Name] - Show a highlighted card name" + "
\\ignore - shows current ignore list on this server." + "
\\ignore [username] - add a username to your ignore list on this server." + "
\\unignore [username] - remove a username from your ignore list on this server."; + final Pattern getCardTextPattern = Pattern.compile("^.card *(.*)"); + private boolean performUserCommand(User user, String message, UUID chatId, boolean doError) { String command = message.substring(1).trim().toUpperCase(Locale.ENGLISH); if (doError) { @@ -205,6 +208,25 @@ public enum ChatManager { chatSessions.get(chatId).broadcastInfoToUser(user, message); return true; } + if (command.startsWith("CARD ")) { + Matcher matchPattern = getCardTextPattern.matcher(message.toLowerCase()); + if (matchPattern.find()) { + String cardName = matchPattern.group(1); + CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardName, true); + if (cardInfo != null) { + cardInfo.getRules(); + message = "" + cardInfo.getName() + ": Cost:" + cardInfo.getManaCosts().toString() + ", Types:" + cardInfo.getTypes().toString() + ", "; + for (String rule : cardInfo.getRules()) { + message = message + rule; + } + } else { + message = "Couldn't find: " + cardName; + + } + } + chatSessions.get(chatId).broadcastInfoToUser(user, message); + return true; + } if (command.startsWith("W ") || command.startsWith("WHISPER ")) { String rest = message.substring(command.startsWith("W ") ? 3 : 9); int first = rest.indexOf(' ');