mud++0.35/etc/
mud++0.35/etc/guilds/
mud++0.35/help/propert/
mud++0.35/mudC/
mud++0.35/player/
mud++0.35/src/interface/
mud++0.35/src/os/cygwin32/
mud++0.35/src/os/win32/
mud++0.35/src/os/win32/bcppbuilder/
mud++0.35/src/osaddon/
mud++0.35/src/util/
/*
....[@@@..[@@@..............[@.................. 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
------------------------------------------------------------------------------
spell.h
*/

#ifndef _SPELL_H
#define _SPELL_H

#include "action.h"
#include "bit.h"
#include "thing.h"

// Target bits
const int TAR_NONE		= 0;
const int TAR_ANY		= 1;
const int TAR_SELF		= 2;
const int TAR_CHAR		= 3;
const int TAR_OBJECT		= 4;
const int TAR_ROOM		= 5;
const int TAR_AREA		= 6;

//const int MAX_TARGET_BIT_FIELDS = 1;

#define SPELL( xxx ) void xxx( Thing *, MudObject *, const String &,int ) const

// This defines the actual spell info
struct SpellType
{
	const char * name;
	void (SpellType::*spell_func)( Thing *, MudObject *, const String &, int )
			const;
	unsigned long target_bits;
	bool target_in_room;
	bool obj_can_cast;
	int timer;
	int funID;


	const char * getName() const { return name; }
	void cast( Thing *, MudObject *, const String &, int ) const;

	SPELL( spell_none );
	SPELL( spell_giant_form );
	SPELL( spell_lightning_bolt );
	SPELL( spell_sanctuary );
	SPELL( spell_detect_invis );
};


struct GuildSpell
{
	const SpellType * spell;
	int level;
	int cost;
	// etc ...
};

// This is an instance of the spell info.  It is used for learned
// spells which need an associated level 
class Spell
{
	private:
		const SpellType *	spell;
		int					level;
		Spell() {} // can't create without initializing

	public:
		Spell( const SpellType * x, int lev )
		:	spell(x), level(lev)
		{
		}

		const char * getName() const { return spell->getName(); }
		bool objCanCast() const { return spell->obj_can_cast; }
		int getLevel( void ) const { return level; }
		const SpellType *getSpellType( void ) const { return spell; }
		void cast( Thing * x, MudObject  * y ) const
			{ spell->cast( x, y, 0, level ); } 
		void cast( Thing * x, MudObject * y, const String & z ) const
			{ spell->cast( x, y, z, level ); }
};

// A spell is a form of an action with a little more functionality
// This is the cast action.  da_func is not called, rather Spell::cast
// is
class Spell_Action : public Action
{
	private:
		const SpellType * spell;
		String args;
		
		Spell_Action() {}

	public:
		Spell_Action( const SpellType * x )
		:	spell(x)
		{
		}

		void callDaFunc( void ); 
		void setSpell( const SpellType * s ) { spell = s; }
		const SpellType * getSpell( void ) const { return spell; }
		void update( void );
		void setArgs( const String & x ) { args = x; }
};

inline void Spell_Action::callDaFunc( void )
{
	spell->cast( ( Thing * )owner, target, args, 0 );
}

extern const SpellType * spellTypeNone;
extern Spell spellNone;

const SpellType * lookupSpell( const char *, char * );
const SpellType * lookupSpell( const char * );
inline const SpellType * lookupSpell( char * x )
	{       return lookupSpell( (const char *) x ); }

#endif