#include #include #include "exception.h" #include "parse.h" #include "weapon.h" using namespace JFK; using std::string; weapon::weapon(int itype) : type(itype) { r = 5.0; } string weapon::tostring() const { std::ostringstream oss; oss << "x=" << x << " y=" << y << " type=" << type; return oss.str(); } void weapon::fromstring(const string& s) { int index = 0; string arg = argument(0, s); while (arg.length() > 0) { string id = identifier(arg); if (id == "x") x = strtodbl(value(arg)); else if (id == "y") y = strtodbl(value(arg)); else if (id == "type") type = strtoint(value(arg)); // else throw exception("wrong string"); irgnore better... index++; arg = argument(index, s); } } string weapon::classname() const { return "weapon"; }