/*
....[@@@..[@@@..............[@.................. 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
------------------------------------------------------------------------------
affect.cc
*/
#include <string.h>
#include "config.h"
#include "affect.h"
#include "spell.h"
const bitType affect_type_list[] =
{
{ "invisibility", AFF_INVIS },
{ "blindness", AFF_BLIND },
{ "sanctuary", AFF_SANCTUARY },
{ "sleep", AFF_SLEEP },
{ "charm", AFF_CHARM },
{ "poison", AFF_POISON },
{ "curse", AFF_CURSE },
{ "giant", AFF_GIANT },
{ 0, -1 }
};
const bitType mod_type_list[] =
{
{ "strength", MOD_STR },
{ "dexterity", MOD_DEX },
{ "intelligence", MOD_INT },
{ "wisdom", MOD_WIS },
{ "constitution", MOD_CON },
{ "speed", MOD_SPEED },
{ "hp", MOD_HP },
{ "hitpoints", MOD_HP },
{ "mana", MOD_MANA },
{ "energy", MOD_ENERGY },
{ "age", MOD_AGE },
{ "weight", MOD_WEIGHT },
{ "alignment", MOD_ALIGN },
{ "armor", MOD_ARMOR },
{ "damroll", MOD_DAMROLL },
{ "hitroll", MOD_HITROLL },
{ 0, -1 }
};
int Affect::total_count = 0;
int Affect::writeTo( Output & out ) const
{
Modifier *mod;
out << '{' << lookupAffectName( type ) << ' ' << duration << ' ';
if( spell )
out << spell->getName() << "~ ";
else
out << spellTypeNone->getName() << "~ ";
out << level;
for_each( mod_list, mod )
out << "\nM{" << mod->getName() << ' ' << mod->getAmt() << "}";
out << "\n}\n";
return 0;
}
int Affect::readFrom( StaticInput & in )
{
char buf[ 256 ];
Modifier * mod;
int modAmt;
int modType;
in.getword( buf );
in.getword( buf );
type = lookupAffectType( buf );
duration = in.getnum();
in.getstring( buf ); // spell name if applies
level = in.getnum();
spell = lookupSpell( buf );
for( ; ; )
{
switch( *in.getword( buf ) )
{
default: return -1;
case '}': return 0;
case 'M': in.getword( buf );
in.getword( buf );
modAmt = in.getnum();
if( ( modType = lookupModType( buf ) ) != -1 )
{
mod = new Modifier( modType, modAmt );
if( mod )
mod_list.add( mod );
else
in.error( "allocationg new Modifier" );
}
in.getword( buf );
}
}
return 0;
}