Verb.h
musicmud-2.1.6/include/Verb.h · 1.1 KB
From the archive musicmud2.1.6.tar.gz
Download the archive « Back to the archive contents
#ifndef VERB_H
#define VERB_H
#include "pflags.h"
enum VFlag {
VFL_NONE = 0,
VFL_DENYEXISTS = 1,
VFL_MAGICSPACE = 2,
VFL_OKNOOWNER = 4,
};
inline VFlag operator|(VFlag a, VFlag b) {
return VFlag(int(a)|int(b));
}
//! a verb - a command that can be executed by a mudobject and cause some code to run
class Verb : public Object {
public :
unsigned int minlen;
int privneeded;
PFlag pflag;
bool disabled;
int vflags;
Verb(const char *_id, int _minlen, int _privneeded, PFlag _pflag, VFlag vflag=VFL_NONE);
virtual bool invoke(MudObject *invoker, int argc, const char*argv[]) = 0;
bool matches(const char *what) const;
bool has_privs(MudObject *) const;
virtual Verb *drill() { return this; };
};
//! a verb which acts as an alias for another verb.
class AliasVerb : public Verb {
public:
Verb *aliasof;
Verb *drill() { return aliasof; }
bool invoke(MudObject *invoker, int argc, const char **argv) {
return aliasof->invoke(invoker, argc, argv);
}
AliasVerb(const char *_id, Verb *_what)
: Verb(_id, strlen(_id), 10000, PFL_NONE) {
aliasof = _what;
};
};
#endif