100 lines
1.8 KiB
Lua
100 lines
1.8 KiB
Lua
local ItemEntity = class("ItemEntity", BaseData)
|
|
|
|
function ItemEntity:ctor(id, bigNum)
|
|
self.data.id = id
|
|
self.data.bigNum = bigNum
|
|
self.data.isDirty = false
|
|
self.config = nil
|
|
|
|
self:_loadConfig(id)
|
|
end
|
|
|
|
function ItemEntity:getConfig(id)
|
|
local ItemCfg = ConfigManager:getConfig("item")
|
|
local config = ItemCfg[id]
|
|
return config
|
|
end
|
|
|
|
function ItemEntity:_loadConfig(id)
|
|
local config = self:getConfig(id)
|
|
self.config = config
|
|
end
|
|
|
|
function ItemEntity:setDirty()
|
|
self.data.isDirty = not self.data.isDirty
|
|
end
|
|
|
|
-- id
|
|
function ItemEntity:getId()
|
|
return self.data.id
|
|
end
|
|
|
|
-- 道具数量
|
|
function ItemEntity:getBigNum()
|
|
return self.data.bigNum
|
|
end
|
|
|
|
function ItemEntity:getBigNumStr()
|
|
return BigNumOpt.bigNum2Str(self.data.bigNum)
|
|
end
|
|
|
|
-- 加减道具数量
|
|
function ItemEntity:addBigNum(bigNum)
|
|
self.data.bigNum = BigNumOpt.bigNumAdd(self.data.bigNum, bigNum)
|
|
self:setDirty()
|
|
end
|
|
|
|
-- 设置数量
|
|
function ItemEntity:setNum(bigNum)
|
|
self.data.bigNum = bigNum
|
|
self:setDirty()
|
|
end
|
|
|
|
-- 道具类型
|
|
function ItemEntity:getItemType()
|
|
return self.config.type
|
|
end
|
|
|
|
-- 品质
|
|
function ItemEntity:getQuality()
|
|
return self.config.qlt
|
|
end
|
|
|
|
-- 稀有度
|
|
function ItemEntity:getRarity()
|
|
return self.config.rarity
|
|
end
|
|
|
|
function ItemEntity:getFrameRes()
|
|
return GConst.ATLAS_PATH.ICON_ITEM, "frame_" .. self.config.qlt
|
|
end
|
|
|
|
function ItemEntity:getIconRes()
|
|
return GConst.ATLAS_PATH.ICON_ITEM, tostring(self.config.icon)
|
|
end
|
|
|
|
-- 类型
|
|
function ItemEntity:getType()
|
|
return GConst.ENTITY_TYPE.ITEM
|
|
end
|
|
|
|
-- 其他参数
|
|
function ItemEntity:getParam()
|
|
return self.config.parameter
|
|
end
|
|
|
|
-- 道具描述
|
|
function ItemEntity:getName()
|
|
return I18N:getText("item", self.data.id, "name")
|
|
end
|
|
|
|
-- 道具描述
|
|
function ItemEntity:getDesc()
|
|
return I18N:getText("item", self.data.id, "desc")
|
|
end
|
|
|
|
function ItemEntity:getEntityType()
|
|
return GConst.ENTITY_TYPE.ITEM_ENTITY
|
|
end
|
|
|
|
return ItemEntity |