mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
Merge pull request #3231 from spjspj/master
Add in /card command for chat to get back card's: cost, type, text.
This commit is contained in:
commit
be92bf9e41
1 changed files with 22 additions and 0 deletions
|
@ -181,11 +181,14 @@ public enum ChatManager {
|
|||
+ "<br/>\\me - shows the history of the current player"
|
||||
+ "<br/>\\list or \\l - Show a list of commands"
|
||||
+ "<br/>\\whisper or \\w [player name] [text] - whisper to the player with the given name"
|
||||
+ "<br/>\\card Card Name - Print oracle text for card"
|
||||
+ "<br/>[Card Name] - Show a highlighted card name"
|
||||
+ "<br/>\\ignore - shows current ignore list on this server."
|
||||
+ "<br/>\\ignore [username] - add a username to your ignore list on this server."
|
||||
+ "<br/>\\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 = "<font color=orange>" + cardInfo.getName() + "</font>: 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(' ');
|
||||
|
|
Loading…
Reference in a new issue