mirror of
https://github.com/correl/mage.git
synced 2024-12-01 03:00:09 +00:00
Add in /card command for chat to get back card's: cost, type, text.
This commit is contained in:
parent
4ed9419cbf
commit
1d46fec3ff
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/>\\me - shows the history of the current player"
|
||||||
+ "<br/>\\list or \\l - Show a list of commands"
|
+ "<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/>\\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/>[Card Name] - Show a highlighted card name"
|
||||||
+ "<br/>\\ignore - shows current ignore list on this server."
|
+ "<br/>\\ignore - shows current ignore list on this server."
|
||||||
+ "<br/>\\ignore [username] - add a username to your 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.";
|
+ "<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) {
|
private boolean performUserCommand(User user, String message, UUID chatId, boolean doError) {
|
||||||
String command = message.substring(1).trim().toUpperCase(Locale.ENGLISH);
|
String command = message.substring(1).trim().toUpperCase(Locale.ENGLISH);
|
||||||
if (doError) {
|
if (doError) {
|
||||||
|
@ -205,6 +208,25 @@ public enum ChatManager {
|
||||||
chatSessions.get(chatId).broadcastInfoToUser(user, message);
|
chatSessions.get(chatId).broadcastInfoToUser(user, message);
|
||||||
return true;
|
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 ")) {
|
if (command.startsWith("W ") || command.startsWith("WHISPER ")) {
|
||||||
String rest = message.substring(command.startsWith("W ") ? 3 : 9);
|
String rest = message.substring(command.startsWith("W ") ? 3 : 9);
|
||||||
int first = rest.indexOf(' ');
|
int first = rest.indexOf(' ');
|
||||||
|
|
Loading…
Reference in a new issue