This commit is contained in:
puxuan 2025-05-22 23:55:14 +08:00
parent ebfffa4f59
commit 41e1274309
3 changed files with 59 additions and 2 deletions

View File

@ -7,6 +7,7 @@ function ItemEntity:ctor(id, num)
self.config = nil self.config = nil
self:_loadConfig(id) self:_loadConfig(id)
self:checkForceLockAndAddNum(num)
end end
function ItemEntity:getConfig(id) function ItemEntity:getConfig(id)
@ -37,9 +38,32 @@ end
-- 加减道具数量 -- 加减道具数量
function ItemEntity:addNum(num) function ItemEntity:addNum(num)
self.data.num = self.data.num + num self.data.num = self.data.num + num
self:checkForceLockAndAddNum()
self:setDirty() self:setDirty()
end end
function ItemEntity:checkForceLockAndAddNum()
local type = self:getItemType()
if type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then
local isOwn = DataManager.HeroData:getHeroIsUnlock(self:getId())
local qlt = DataManager.HeroData:getHeroQlt(self:getId())
-- local fragmentId = DataManager.ForceData:getForceItemIdByQlt(self:getId())
local upCost = DataManager.HeroData:getHeroLevelCost(1, qlt)
if not isOwn and self.data.num >= upCost[1] then
-- self.data.num = self.data.num - upCost[1] 不消耗碎片了
-- DataManager.HeroData:onForceUnlock(self:getId(), true)
-- BIReport:postForceUnlock(self:getId())
end
-- 不转换万能碎片
-- local parameter = self:getParam()
-- if qlt >= 5 and parameter and parameter[3] then
-- DataManager.HeroData:addSummonUnlockItemCount(self.data.num * parameter[3])
-- -- DataManager.BagData.ItemData:addItemNumById(fragmentId, self.data.num * parameter[3], BIReport.ITEM_GET_TYPE.FORCE_SUMMON_EXCHANGE)
-- self.data.num = 0
-- end
end
end
-- 设置数量 -- 设置数量
function ItemEntity:setNum(num) function ItemEntity:setNum(num)
self.data.num = num self.data.num = num

View File

@ -345,4 +345,37 @@ function HeroData:getAllHeroesSort(formationType)
return result return result
end end
-- region
function HeroData:getHeroConfig(id)
if id then
return ConfigManager:getConfig("hero")[id]
else
return ConfigManager:getConfig("hero")
end
end
function HeroData:getHeroQlt(id)
local cfg = self:getHeroConfig(id)
if cfg then
return cfg.qlt
end
end
function HeroData:getHeroLevelConfig(lv)
if lv then
return ConfigManager:getConfig("hero_level")[lv]
else
return ConfigManager:getConfig("hero_level")
end
end
-- 升级目前跟质量无关
function HeroData:getHeroLevelCost(lv, qlt)
local cfg = self:getHeroLevelConfig(lv)
if cfg then
return cfg.cost
end
end
-- endregion
return HeroData return HeroData

View File

@ -460,8 +460,8 @@ function HeroEntity:getLvUpMaterials()
if not nextLvInfo then if not nextLvInfo then
return return
end end
local fieldName = "cost_" .. self:getQlt() -- local fieldName = "cost_" .. self:getQlt()
return nextLvInfo[fieldName] return nextLvInfo.cost
end end
function HeroEntity:getConfig() function HeroEntity:getConfig()