#include "ObjectFactory.h" #include "ArmorObject.h" #include "ConsumableObject.h" #include "GoldObject.h" #include "WeaponObject.h" #include "RNG.h" Object * ObjectFactory::create_object(const UniversalObject & data) { switch (data.type) { case ARMOR: { ArmorObject * object = new ArmorObject(data.name, data.description); object->set_protection(data.protection); return object; } case CONSUMABLE: { ConsumableObject * object = new ConsumableObject(data.name, data.description); // TODO: read database item explanation return object; } case GOLD: { GoldObject * object = new GoldObject(data.name, data.description); object->set_count(RNG::get().rand_int(data.min_value, data.max_value)); return object; } case WEAPON: { WeaponObject * object = new WeaponObject(data.name, data.description); object->set_damage_min(data.min_value); object->set_damage_max(data.max_value); return object; } default: break; } return ObjectFactory::create_object(data.name, data.description); } Object * ObjectFactory::create_object(const String & name, const String & description) { return new Object(name, description); }