///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
///////////////////// A MUD Server ////////////////////
///////////////////// By: Jared Devall ////////////////////
///////////////////// Thanks: ////////////////////
///////////////////// DIKU/Merc/ROM ////////////////////
///////////////////// Aetas/Deus Gang ////////////////////
///////////////////// Beej ////////////////////
///////////////////////////////////////////////////////////
#ifndef __COMMANDS_H_
#define __COMMANDS_H_
#include <list>
#include "avatar.h"
// The base command class
class Command {
public:
std::string _name;
std::string _shortcut;
std::string _group;
bool _enabled;
virtual ~Command() {};
virtual bool Execute( Avatar *, const std::string &args ) {return true;};
};
// Our command class macro
// defines an avatar command class and
// inlines the setname and setshortcut
// Less work for defining each command
#define DEF_COMMAND(CommandName) \
class CommandName: public Command { \
public: \
std::string _name; \
std::string _shortcut; \
std::string _group; \
bool _enabled; \
void SetShortcut( const std::string & ); \
void SetName( const std::string & ); \
void SetGroup( const std::string & ); \
void SetEnabled( bool vlaue ); \
CommandName(); \
bool Execute( Avatar *, const std::string &args ); \
}; \
\
inline void CommandName::SetName( const std::string &name ) { \
_name = name; \
Command::_name = name; \
} \
\
inline void CommandName::SetGroup( const std::string &group ) { \
_group = group; \
Command::_group = group; \
} \
\
inline void CommandName::SetEnabled( bool value ) { \
_enabled = value; \
Command::_enabled = value; \
} \
\
inline void CommandName::SetShortcut( const std::string &shortcut ) { \
_shortcut = shortcut; \
Command::_shortcut = shortcut; \
}
// Our command definitions!
DEF_COMMAND(CmdSay);
DEF_COMMAND(CmdWho);
DEF_COMMAND(CmdQuit);
DEF_COMMAND(CmdEdit);
DEF_COMMAND(CmdEmote);
DEF_COMMAND(CmdShutdown);
DEF_COMMAND(CmdReboot);
DEF_COMMAND(CmdDisable);
DEF_COMMAND(CmdCommands);
DEF_COMMAND(CmdTell);
DEF_COMMAND(CmdReply);
DEF_COMMAND(CmdSockets);
DEF_COMMAND(CmdDisconnect);
DEF_COMMAND(CmdTitle);
DEF_COMMAND(CmdDelete);
DEF_COMMAND(CmdSave);
DEF_COMMAND(CmdBuzz);
DEF_COMMAND(CmdPassword);
DEF_COMMAND(CmdPrompt);
#endif // commands.h