objtypes.cc
./mud++0.26/src/objtypes.cc · 4.4 KB
From the archive mud++0.26f.tar.gz
Download the archive « Back to the archive contents
/*
....[@@@..[@@@..............[@.................. 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-list@mailhost.net
------------------------------------------------------------------------------
objtypes.cc
*/
// Classes derived from Object class
#include "string.h"
#include "io.h"
#include "combat.h"
#include "object.h"
/*
// superclass call at end
int ObjTemplate::readFromTypeSpecific( InFile & in )
{
return Object::readFromTypeSpecific(in);
}
int ObjTemplate::writeToTypeSpecific( OutFile & outf ) const
{
return Object::writeToTypeSpecific(outf);
}
// superclass call at beginning
void ObjTemplate::reportVals( String & str ) const
{
Object::reportVals(str);
}
// superclass call at end
char * ObjTemplate::setVals( const String & arg )
{
Object::setVals(str);
}
*/
int ObjWeapon::readFromTypeSpecific( InFile & in )
{
char buf[BUF];
in.getword( buf );
dam_type = ::getDamType( buf );
if( dam_type == NONE )
{
Cout << "BUG: Invalid dam type " << buf << " for " << getShort() << endl;
}
min_dam = in.getnum();
max_dam = in.getnum();
return Object::readFromTypeSpecific(in);
}
int ObjWeapon::writeToTypeSpecific( OutFile & outf ) const
{
outf << getDamTypeName( dam_type ) << ' ' << min_dam << ' ' << max_dam << endl;
return Object::writeToTypeSpecific( outf );
}
void ObjWeapon::reportVals( String & str ) const
{
Object::reportVals(str);
str << "DamType: " << getDamTypeName( dam_type ) <<
"Min: " << min_dam << "Max: " << max_dam << endl;
}
char * ObjWeapon::setVals( const String & str )
{
String arg1;
String arg2;
int i;
str.startArgs();
arg1 = str.getArg();
arg2 = str.getArgRest();
if ( arg1 == "DamType" )
{
i = ::getDamType( arg2.chars() );
if ( i == NONE )
{
return "Wrong damage type.\n\r";
}
dam_type = i;
return "DamType set.\n\r";
}
else if ( arg1 == "Min" )
{
if ( !arg2.isNumber() )
return "Must be number.\n\r";
i = arg2.asInt();
if ( i < 0 )
return "Must be positive.\n\r";
min_dam = i;
return "Min damage set.\n\r";
}
else if ( arg1 == "Max" )
{
if ( !arg2.isNumber() )
return "Must be number.\n\r";
i = arg2.asInt();
if ( i < 0 )
return "Must be positive.\n\r";
max_dam = i;
return "Max damage set.\n\r";
}
return Object::setVals(str);
}
int ObjFood::readFromTypeSpecific( InFile & in )
{
food_worth = in.getnum();
return Object::readFromTypeSpecific(in);
}
int ObjFood::writeToTypeSpecific( OutFile & outf ) const
{
outf << food_worth << endl;
return Object::writeToTypeSpecific(outf);
}
void ObjFood::reportVals( String & str ) const
{
Object::reportVals(str);
str << "Worth (in food units): " << food_worth << endl;
}
char * ObjFood::setVals( const String & str )
{
String arg1;
String arg2;
int i;
str.startArgs();
arg1 = str.getArg();
arg2 = str.getArgRest();
if ( arg1 == "Worth" )
{
if ( !arg2.isNumber() )
return "This value must be a number.\n\r";
i = arg2.asInt();
if ( i < 0 )
return "Must be postive.\n\r";
food_worth = i;
return "Food worth set.\n\r";
}
return Object::setVals(str);
}
int ObjLiquidContainer::readFromTypeSpecific( InFile & in )
{
amount = in.getnum();
return Object::readFromTypeSpecific(in);
}
int ObjLiquidContainer::writeToTypeSpecific( OutFile & outf ) const
{
outf << amount << endl;
return Object::writeToTypeSpecific(outf);
}
void ObjLiquidContainer::reportVals( String & str ) const
{
Object::reportVals(str);
str << "Amount of liquid: " << amount << endl;
}
char * ObjLiquidContainer::setVals( const String & str )
{
String arg1;
String arg2;
int i;
str.startArgs();
arg1 = str.getArg();
arg2 = str.getArgRest();
if ( arg1 == "Amount" )
{
if ( !arg2.isNumber() )
return "This value must be a number.\n\r";
i = arg2.asInt();
if ( i < 0 )
return "Must be postive.\n\r";
amount = i;
return "Amount of liquid set.\n\r";
}
return Object::setVals(str);
}