#include #include #include "exception.h" #include "object_s.h" #include "parse.h" #include "weapon_s.h" using namespace JFK::server; using std::string; weapon::weapon(int itype) : JFK::weapon(itype) { } void weapon::assign(const object* o) { *this = *dynamic_cast(o); } string weapon::diffstring(const object*) const { return ""; // Weapons stay at their position till they are killed... } /* overwrite from JFK::weapon to accept "reappear" too */ 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 if (id == "reappear") reappear = strtoint(value(arg)); // else throw exception("wrong string"); irgnore better... index++; arg = argument(index, s); } } void weapon::delegate_collision(object* obj) const { obj->collide_with_weapon(this); } void weapon::collide_with_person(const person*) { suicide = true; }