mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 00:40:15 +00:00
Add /roll and friend management commands
Roll Command: - Add /roll, /random, /rnd commands for random number generation - Support multiple formats: /roll, /roll 100, /roll 1-100, /roll 10 50 - Broadcasts rolls to party/raid with "[Name] rolls X (min-max)" format - Cap max roll at 10,000 to prevent abuse - Use MSG_RANDOM_ROLL (0x1FB) bidirectional opcode Friend Commands: - Add /friend add <name>, /addfriend <name> to add friends - Add /friend remove <name>, /removefriend <name> to remove friends - Support aliases: /delfriend, /remfriend - Maintain local friends cache mapping names to GUIDs for lookups - Display status messages for all friend actions: - Friend added/removed confirmations - Friend online/offline notifications - Error messages (not found, already friends, list full, ignoring) Social Opcodes: - Add CMSG_ADD_FRIEND (0x69) and SMSG_FRIEND_STATUS (0x68) - Add CMSG_DEL_FRIEND (0x6A) for friend removal - Add CMSG_SET_CONTACT_NOTES (0x6B) for friend notes (future use) - Add CMSG_ADD_IGNORE (0x6C) and CMSG_DEL_IGNORE (0x6D) (future use) Implementation: - Add RandomRollPacket builder and RandomRollParser for roll data - Add AddFriendPacket and DelFriendPacket builders - Add FriendStatusParser to handle server friend status updates - Add friendsCache map to store friend name-to-GUID mappings - Add handleRandomRoll() and handleFriendStatus() packet handlers - Comprehensive slash command parsing with multiple formats and aliases
This commit is contained in:
parent
f9c4cbddee
commit
6f45c6ab69
6 changed files with 427 additions and 0 deletions
|
|
@ -988,6 +988,97 @@ void GameScreen::sendChatMessage(game::GameHandler& gameHandler) {
|
|||
return;
|
||||
}
|
||||
|
||||
// /roll command
|
||||
if (cmdLower == "roll" || cmdLower == "random" || cmdLower == "rnd") {
|
||||
uint32_t minRoll = 1;
|
||||
uint32_t maxRoll = 100;
|
||||
|
||||
if (spacePos != std::string::npos) {
|
||||
std::string args = command.substr(spacePos + 1);
|
||||
size_t dashPos = args.find('-');
|
||||
size_t spacePos2 = args.find(' ');
|
||||
|
||||
if (dashPos != std::string::npos) {
|
||||
// Format: /roll 1-100
|
||||
try {
|
||||
minRoll = std::stoul(args.substr(0, dashPos));
|
||||
maxRoll = std::stoul(args.substr(dashPos + 1));
|
||||
} catch (...) {}
|
||||
} else if (spacePos2 != std::string::npos) {
|
||||
// Format: /roll 1 100
|
||||
try {
|
||||
minRoll = std::stoul(args.substr(0, spacePos2));
|
||||
maxRoll = std::stoul(args.substr(spacePos2 + 1));
|
||||
} catch (...) {}
|
||||
} else {
|
||||
// Format: /roll 100 (means 1-100)
|
||||
try {
|
||||
maxRoll = std::stoul(args);
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
gameHandler.randomRoll(minRoll, maxRoll);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// /friend or /addfriend command
|
||||
if (cmdLower == "friend" || cmdLower == "addfriend") {
|
||||
if (spacePos != std::string::npos) {
|
||||
std::string args = command.substr(spacePos + 1);
|
||||
size_t subCmdSpace = args.find(' ');
|
||||
|
||||
if (cmdLower == "friend" && subCmdSpace != std::string::npos) {
|
||||
std::string subCmd = args.substr(0, subCmdSpace);
|
||||
std::transform(subCmd.begin(), subCmd.end(), subCmd.begin(), ::tolower);
|
||||
|
||||
if (subCmd == "add") {
|
||||
std::string playerName = args.substr(subCmdSpace + 1);
|
||||
gameHandler.addFriend(playerName);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
} else if (subCmd == "remove" || subCmd == "delete" || subCmd == "rem") {
|
||||
std::string playerName = args.substr(subCmdSpace + 1);
|
||||
gameHandler.removeFriend(playerName);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// /addfriend name or /friend name (assume add)
|
||||
gameHandler.addFriend(args);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
game::MessageChatData msg;
|
||||
msg.type = game::ChatType::SYSTEM;
|
||||
msg.language = game::ChatLanguage::UNIVERSAL;
|
||||
msg.message = "Usage: /friend add <name> or /friend remove <name>";
|
||||
gameHandler.addLocalChatMessage(msg);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// /removefriend or /delfriend command
|
||||
if (cmdLower == "removefriend" || cmdLower == "delfriend" || cmdLower == "remfriend") {
|
||||
if (spacePos != std::string::npos) {
|
||||
std::string playerName = command.substr(spacePos + 1);
|
||||
gameHandler.removeFriend(playerName);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
game::MessageChatData msg;
|
||||
msg.type = game::ChatType::SYSTEM;
|
||||
msg.language = game::ChatLanguage::UNIVERSAL;
|
||||
msg.message = "Usage: /removefriend <name>";
|
||||
gameHandler.addLocalChatMessage(msg);
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// Chat channel slash commands
|
||||
bool isChannelCommand = false;
|
||||
if (cmdLower == "s" || cmdLower == "say") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue