function C:WeaponQualityUpToID(w) --同ID升品是否满足 local allweapon = self:Get("weaponList") local qualityCfg = DATA.GetData("WeaponQuality") local cfg =qualityCfg[w.quality] local stuff = {} --材料 local needStuffCnt = cfg.UpNeedCount for _, weapon in pairs(allweapon) do local isUse = HeroHelper:PairsWearWeapon(function (wearWeapon) --装备中的武器 if (weapon.guid ~= wearWeapon.guid and weapon.cfgid == wearWeapon.cfgid and wearWeapon.quality == cfg.UpNeedQuality) or cfg.UpNeedQuality ==0 then return true end end) if (not isUse) and weapon.guid ~= w.guid and weapon.cfgid == w.cfgid and ((weapon.quality == cfg.UpNeedQuality)or cfg.UpNeedQuality == 0 ) then if needStuffCnt > 0 then needStuffCnt = needStuffCnt -1 table.insert( stuff, weapon) end end end return needStuffCnt == 0,stuff end 在此方法中增加:当武器被当做素材时,标记此武器且指向把此武器作为素材的武器guid
时间: 2024-04-22 22:22:52 浏览: 132
好的,您的要求是在上述代码中增加一个标记,用于标记被当做素材的武器,并将其指向把它作为素材的武器guid。我可以为您提供以下代码实现:
function C:WeaponQualityUpToID(w)
local allweapon = self:Get("weaponList")
local qualityCfg = DATA.GetData("WeaponQuality")
local cfg = qualityCfg[w.quality]
local stuff = {} --材料
local needStuffCnt = cfg.UpNeedCount
for _, weapon in pairs(allweapon) do
local isUse = HeroHelper:PairsWearWeapon(function (wearWeapon) --装备中的武器
if (weapon.guid ~= wearWeapon.guid and weapon.cfgid == wearWeapon.cfgid and wearWeapon.quality == cfg.UpNeedQuality) or cfg.UpNeedQuality == 0 then
return true
end
end)
if (not isUse) and weapon.guid ~= w.guid and weapon.cfgid == w.cfgid and ((weapon.quality == cfg.UpNeedQuality) or cfg.UpNeedQuality == 0) then
if needStuffCnt > 0 then
needStuffCnt = needStuffCnt - 1
table.insert(stuff, weapon)
weapon.isMaterial = true --标记为素材
weapon.materialGuid = w.guid --指向把它作为素材的武器guid
end
end
end
return needStuffCnt == 0, stuff
end
在这个修改后的代码中,我们添加了两个属性"isMaterial"和"materialGuid"来标记武器是否被用作素材以及它被用作素材的武器guid。当武器被用作素材时,我们将"isMaterial"属性设置为true,并将"materialGuid"属性设置为把它作为素材的武器guid。这将帮助您更好地跟踪武器的使用情况。
阅读全文