#ifndef SHARED_H #define SHARED_H //! describe the liquid contained in /what/ to /player/ void describe_liquid_to(MudObject *player, const MudObject *what); //! obtain the substance short of /sub/ const char *subshort(const MudObject *sub); //! has /o/ got eyes that work and isn't blindfolded? bool can_see(const MudObject *o); //! filter ftor, returns true if candidate can see class canseec : public showto { public: bool operator()(const MudObject *who) const { return can_see(who); } }; class alwaysc : public showto { public: bool operator()(const MudObject *who) const { return 1; } }; #define always alwaysc() //! filter ftor, returns true if candidate can hear class canhearc : public showto { public: bool operator()(const MudObject *who) const { if (who->get_flag(FL_DEAF) || who->get_flag(FL_SLEEPING)) return 0; return 1; } }; //! filter ftor, returns true if candidate isn't the person who was specified in the constructor class avoid : public showto { const MudObject *a; public: avoid(const MudObject *a) : a(a) { } bool operator()(const MudObject *who) const { return who != a; } }; //! filter ftor, returns true if candidate isn't in the room specified in the constructor class notinroom : public showto { const MudObject *avoid; public: notinroom(const MudObject *a) : avoid(a) { } bool operator()(const MudObject *who) const { return (who->owner != avoid); } }; //! filter ftor, return true if the candidate isn't ignoring the person specified in the constructor class filter : public showto { string igstr; public: filter(const MudObject *who) : igstr((string)"ignore."+who->id) { } bool operator()(const MudObject *o) const { if (is_player(o) && o->get(igstr.c_str())) return 0; return 1; } }; //! filter ftor, return true if the person specified in the constructor is visible to the candidate class secret : public showto { int vislevel; public: secret(const MudObject *player) : vislevel(invis(player)) { } bool operator()(const MudObject *o) const { if (privs_of(o) < vislevel) return 0; return 1; } }; //! filter ftor, return true if the candidate has the specified flag set class getflag : public showto { Flag i; public: getflag(Flag f) : i(f) { } bool operator()(const MudObject *o) const { return o->get_flag(i); } }; //! filter ftor, return true if the candidate is >= given level class minlev : public showto { int i; public: minlev(int f) : i(f) { } bool operator()(const MudObject *o) const { return privs_of(o) >= i; } }; //! filter ftor, return true if the candidate is < given level class maxlev : public showto { int i; public: maxlev(int f) : i(f) { } bool operator()(const MudObject *o) const { return privs_of(o) < i; } }; //! filter ftor, return true if the chained ftor returns false class invert : public showto { const showto &cs; public: invert(const showto &s) : cs(s) { } bool operator()(const MudObject *who) const { return !cs(who); } }; //! filter ftor, return true if either of the chained ftors return true class either : public showto { const showto &a; const showto &b; public: either(const showto &aa, const showto &bb) : a(aa), b(bb) { } bool operator()(const MudObject *who) const { return a(who) || b(who); } }; //! filter ftor, return true if both of the chained ftors return true class both : public showto { const showto &a; const showto &b; public: both(const showto &aa, const showto &bb) : a(aa), b(bb) { } bool operator()(const MudObject *who) const { return a(who) && b(who); } }; //! construct an invert filter inline invert operator!(const showto &s) { return invert(s); } //! construct an either filter inline either operator||(const showto &a, const showto &b) { return either(a, b); } //! construct a both filter inline both operator&&(const showto &a, const showto &b) { return both(a, b); } #define canhear canhearc() #define cansee canseec() #endif