diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-23 07:02:32 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-23 07:02:32 -0600 |
commit | 7c360d2887216099ca8cc767f15a34fcf302803b (patch) | |
tree | 308a8889e1173a27b4c20ef608c0749449c8aa04 /src/party.cpp | |
parent | d3f315b45bd9055ac7f61082f5af54b863410517 (diff) | |
download | mana-client-7c360d2887216099ca8cc767f15a34fcf302803b.tar.gz mana-client-7c360d2887216099ca8cc767f15a34fcf302803b.tar.bz2 mana-client-7c360d2887216099ca8cc767f15a34fcf302803b.tar.xz mana-client-7c360d2887216099ca8cc767f15a34fcf302803b.zip |
Merge eA's command handling into CommandHandler
Also drop Aethyra's custom magic code
Diffstat (limited to 'src/party.cpp')
-rw-r--r-- | src/party.cpp | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/src/party.cpp b/src/party.cpp index d22db55f..33336eb8 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -32,8 +32,7 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -Party::Party(ChatWindow *chat, Network *network) : - mChat(chat), +Party::Party(Network *network) : mNetwork(network), mInviteListener(network, &mInParty) { @@ -53,7 +52,7 @@ void Party::respond(const std::string &command, const std::string &args) } if (command == "settings") { - mChat->chatLog(_("Not yet implemented!"), BY_SERVER); + chatWindow->chatLog(_("Not yet implemented!"), BY_SERVER); return; /* MessageOut outMsg(mNetwork); @@ -62,14 +61,14 @@ void Party::respond(const std::string &command, const std::string &args) outMsg.writeInt16(0); // Item */ } - mChat->chatLog(_("Party command not known."), BY_SERVER); + chatWindow->chatLog(_("Party command not known."), BY_SERVER); } void Party::create(const std::string &party) { if (party.empty()) { - mChat->chatLog(_("Party name is missing."), BY_SERVER); + chatWindow->chatLog(_("Party name is missing."), BY_SERVER); return; } MessageOut outMsg(mNetwork); @@ -82,7 +81,7 @@ void Party::leave(const std::string &args) { MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_PARTY_LEAVE); - mChat->chatLog(_("Left party."), BY_SERVER); + chatWindow->chatLog(_("Left party."), BY_SERVER); mInParty = false; } @@ -90,12 +89,12 @@ void Party::createResponse(bool ok) { if (ok) { - mChat->chatLog(_("Party successfully created."), BY_SERVER); + chatWindow->chatLog(_("Party successfully created."), BY_SERVER); mInParty = true; } else { - mChat->chatLog(_("Could not create party."), BY_SERVER); + chatWindow->chatLog(_("Could not create party."), BY_SERVER); } } @@ -104,15 +103,15 @@ void Party::inviteResponse(const std::string &nick, int status) switch (status) { case 0: - mChat->chatLog(strprintf(_("%s is already a member of a party."), + chatWindow->chatLog(strprintf(_("%s is already a member of a party."), nick.c_str()), BY_SERVER); break; case 1: - mChat->chatLog(strprintf(_("%s refused your invitation."), + chatWindow->chatLog(strprintf(_("%s refused your invitation."), nick.c_str()), BY_SERVER); break; case 2: - mChat->chatLog(strprintf(_("%s is now a member of your party."), + chatWindow->chatLog(strprintf(_("%s is now a member of your party."), nick.c_str()), BY_SERVER); break; } @@ -124,7 +123,7 @@ void Party::invitedAsk(const std::string &nick, int gender, mPartyName = partyName; /* Quick and nasty - needs redoing */ if (nick.empty()) { - mChat->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); + chatWindow->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); return; } mCreating = false; @@ -147,7 +146,7 @@ void Party::InviteListener::action(const gcn::ActionEvent &event) void Party::leftResponse(const std::string &nick) { - mChat->chatLog(strprintf(_("%s has left your party."), nick.c_str()), + chatWindow->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); } @@ -159,47 +158,50 @@ void Party::receiveChat(Being *being, const std::string &msg) } if (being->getType() != Being::PLAYER) { - mChat->chatLog(_("Party chat received, but being is not a player"), + chatWindow->chatLog(_("Party chat received, but being is not a player"), BY_SERVER); return; } being->setSpeech(msg, SPEECH_TIME); - mChat->chatLog(being->getName() + " : " + msg, BY_PARTY); + chatWindow->chatLog(being->getName() + " : " + msg, BY_PARTY); } -void Party::help(const std::string &msg) +void Party::help(const std::string &args) { + // Strip "party " from the front + std::string msg = args.substr(6, args.length()); + if (msg.empty()) { - mChat->chatLog(_("Command: /party <command> <args>"), BY_SERVER); - mChat->chatLog(_("where <command> can be one of:"), BY_SERVER); - mChat->chatLog(_(" /new"), BY_SERVER); - mChat->chatLog(_(" /create"), BY_SERVER); - mChat->chatLog(_(" /prefix"), BY_SERVER); - mChat->chatLog(_(" /leave"), BY_SERVER); - mChat->chatLog(_("This command implements the partying function."), + chatWindow->chatLog(_("Command: /party <command> <args>"), BY_SERVER); + chatWindow->chatLog(_("where <command> can be one of:"), BY_SERVER); + chatWindow->chatLog(_(" /new"), BY_SERVER); + chatWindow->chatLog(_(" /create"), BY_SERVER); + chatWindow->chatLog(_(" /prefix"), BY_SERVER); + chatWindow->chatLog(_(" /leave"), BY_SERVER); + chatWindow->chatLog(_("This command implements the partying function."), BY_SERVER); - mChat->chatLog(_("Type /help party <command> for further help."), + chatWindow->chatLog(_("Type /help party <command> for further help."), BY_SERVER); return; } if (msg == "new" || msg == "create") { - mChat->chatLog(_("Command: /party new <party-name>"), BY_SERVER); - mChat->chatLog(_("Command: /party create <party-name>"), BY_SERVER); - mChat->chatLog(_("These commands create a new party <party-name."), + chatWindow->chatLog(_("Command: /party new <party-name>"), BY_SERVER); + chatWindow->chatLog(_("Command: /party create <party-name>"), BY_SERVER); + chatWindow->chatLog(_("These commands create a new party <party-name."), BY_SERVER); return; } if (msg == "prefix") { - mChat->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER); - mChat->chatLog(_("This command sets the party prefix character."), + chatWindow->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER); + chatWindow->chatLog(_("This command sets the party prefix character."), BY_SERVER); - mChat->chatLog(_("Any message preceded by <prefix-char> is sent to " + chatWindow->chatLog(_("Any message preceded by <prefix-char> is sent to " "the party instead of everyone."), BY_SERVER); - mChat->chatLog(_("Command: /party prefix"), BY_SERVER); - mChat->chatLog(_("This command reports the current party prefix " + chatWindow->chatLog(_("Command: /party prefix"), BY_SERVER); + chatWindow->chatLog(_("This command reports the current party prefix " "character."), BY_SERVER); return; } @@ -207,11 +209,11 @@ void Party::help(const std::string &msg) //if (msg == "info") if (msg == "leave") { - mChat->chatLog(_("Command: /party leave"), BY_SERVER); - mChat->chatLog(_("This command causes the player to leave the party."), + chatWindow->chatLog(_("Command: /party leave"), BY_SERVER); + chatWindow->chatLog(_("This command causes the player to leave the party."), BY_SERVER); return; } - mChat->chatLog(_("Unknown /party command."), BY_SERVER); - mChat->chatLog(_("Type /help party for a list of options."), BY_SERVER); + chatWindow->chatLog(_("Unknown /party command."), BY_SERVER); + chatWindow->chatLog(_("Type /help party for a list of options."), BY_SERVER); } |