/*
....[@@@..[@@@..............[@.................. 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@falcon.mercer.peachnet.edu 
MUD++ development mailing list    mudpp-list@spice.com
------------------------------------------------------------------------------
spell.h
*/

#ifndef _SPELL_H
#define _SPELL_H

#include "thing.h"

// This may not even be used when I finally figure out how I want
// to implement spell casting.
#define TAR_ANY				1
#define TAR_SELF			2
#define TAR_CHAR_ANY		3
#define TAR_CHAR_OTHER		4
#define TAR_OBJECT_ANY		5
#define TAR_OBJECT_OTHER	6
#define TAR_ROOM			7


#define SPELL( fun ) void fun( Thing *, Thing * )

// Would be nice to inherit skill but gcc hasn't implemented initializer
// for objects with base classes as of 2.7.0
// Fairly simple class anyway.
class Spell
{
	public:
		const char * name;
		void (Spell::*fun)( Thing *caster, Thing *target );
		int target;
		void cast( Thing *, Thing * ) const;
		const char * getName() const { return name; }	

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

inline void Spell::cast( Thing * caster, Thing * target ) const
{
	// Pass the non-member function a pointer to the spell
	// that is calling it

	fun( caster, target );
}

// I code a spell as a class with a general function so objects, chars
// and rooms can cast a spell using the same function.

extern const Spell * spellNone;

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

#endif