EQUIP_TDCLS = tdcls(DBASE_TDCLS, RID_TDCLS, PROPERTY_TDCLS, ATTRIB_TDCLS)
EQUIP_TDCLS.name = "EQUIP_TDCLS"
function EQUIP_TDCLS:create(value)
assert(type(value) == "table", "equip::create para not corret")
assert(is_int(value["class_id"]))
value["amount"] = nil
self:replace_dbase(value)
end
function EQUIP_TDCLS:destruct()
end
function EQUIP_TDCLS:get_ob_id()
return (string.format("EQUIP_TDCLS:%s:%s", save_string(self:query("rid")),
save_string(self:query("class_id"))))
end
function EQUIP_TDCLS:basic_object()
local class_id = self.dbase["class_id"]
return (find_basic_object_by_class_id(class_id))
end
function EQUIP_TDCLS:can_combine(ob)
return false
end
function EQUIP_TDCLS:cost_amount()
local owner = get_owner(self)
if owner then
owner:get_container():drop(self)
return true
end
end
function EQUIP_TDCLS:get_save_oper()
local oper = self:query_temp("not_in_db") and "insert" or "update"
return "equip", self:query("rid"), oper
end
function EQUIP_TDCLS:is_equip()
return true
end
function EQUIP_TDCLS:notify_fields_updated(field_names)
local owner = get_owner(self)
if not owner then
return
end
owner:notify_property_updated(get_ob_rid(self), field_names)
end
function EQUIP_TDCLS:save_to_mapping()
if self:query_temp("not_in_db") then
return (self:query())
end
local change_list = self:get_change_list()
local data = {}
for key,_ in pairs(change_list) do
if DATA_D.is_field_exist("equip", key) then
data[key] = self:query(key)
else
return (self:query())
end
end
if sizeof(data) == 0 then
return
end
return data, 1
end
function EQUIP_TDCLS:restore_from_mapping(data, freeze)
self:absorb_dbase(data)
if freeze then
self:freeze_dbase()
end
end