/* ....[@@@..[@@@..............[@.................. MUD++ is a written from ....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and ....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++. ....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing ....[@......[@..[@@@@@..[@@@@@.................. development project. All ................................................ contributions are welcome. ....Copyright(C).1995.Melvin.Smith.............. Enjoy. ------------------------------------------------------------------------------ Melvin Smith (aka Fusion) msmith@hom.net MUD++ development mailing list mudpp@van.ml.org ------------------------------------------------------------------------------ thing.h */ #ifndef _THING_H #define _THING_H #include "bit.h" #include "string.h" #include "nameable.h" #include "io.h" #include "mudobj.h" class Object; class Repop; class Char; class Room; class Affect; class MudObject; // Size on objects associated with the listed race const int SIZE_TINY = 1; // imps, fairies, brownies const int SIZE_SMALL = 2; // gnomes, goblins const int SIZE_MEDIUM = 3; // humans, elves, orcs, hobgoblins const int SIZE_LARGE = 4; // trolls, ogres, minotaurs, small dragons const int SIZE_HUGE = 5; // medium giants, medium dragons const int SIZE_GIGANTIC = 6; // largest giants, hydra, dragons, leviathans, etc. extern const bitType size_list[]; class Thing : virtual public Nameable, public MudObject { protected: String shortdesc; String longdesc; Room *in_room; short size; // Tiny, Small, Medium, etc. long weight; long volume; int invis; int timer; public: Thing() : in_room(0), size(SIZE_MEDIUM), weight(1), volume(1), invis(0), timer(-1) { } // Copy constructor Thing( const Thing & x ) : MudObject( x ), shortdesc( x.shortdesc ), longdesc( x.longdesc ), in_room( 0 ), size( x.size ), weight( x.weight ), volume( x.volume ), invis( x.invis ), timer( x.timer ) { setName( x.getName() ); } Thing( const String & x ) : in_room( 0 ), size(SIZE_MEDIUM), weight( 1 ), volume( 1 ), invis( 0 ), timer( -1 ) { setName( x ); } Thing( const String & n, const String & s, const String & l ) : shortdesc( s ), longdesc( l ), in_room( 0 ), size(SIZE_MEDIUM), weight( 1 ), volume( 1 ), invis( 0 ), timer( -1 ) { setName( n ); } virtual ~Thing() {} virtual vmtype getVMType() { return VMT_THING; } // Interface for all 'Things' // Child classes must implement all pure virtual // functions and fulfill the requirement of a 'Thing' // Replace casts with an interface, yech virtual Object * asObj() { return 0; } virtual Char * asChar() { return 0; } bool isThing() const { return true; } virtual void setRepop( Repop * ) = 0; virtual Repop * getRepop() { return 0; } void setTimer( int x ) { timer = x; } int getTimer() { return timer; } int tick() { timer--; return timer; } void setShort( const String & x ) { shortdesc = x; } const String & getShort() const { return shortdesc; } void setLong( const String & x ) { longdesc = x; } const String & getLong() const { return longdesc; } Room *inRoom() { return in_room; } int getSize() { return size; } void setSize( int x ) { size = x; } int getWeight() { return weight; } void setWeight( int lbs ) { weight = lbs; } int getVol() { return volume; } void setVol( int x ) { volume = x; } void setInvisLevel( int x ) { invis = x; } int getInvisLevel() const { return invis; } bool isInvis() const { return (bool)invis; } }; inline const char * lookupSizeName( int x ) { return lookupBitName( size_list, x ); } inline int lookupSize( const char * str ) { return lookupBit( size_list, str ); } class countedThing { public: int count; String name; countedThing() : count(0), name(0) { } countedThing( const String & arg ); ~countedThing() {} }; #endif