sk-client/Assets/ManagedResources/~Lua/Modules/Gem/GiftManager.lua

483 lines
16 KiB
Lua
Raw Normal View History

2025-08-21 19:26:08 +08:00
--新的命格管理
GiftManager = {}
local this = GiftManager
2025-11-19 17:03:47 +08:00
local giftConfig = ConfigManager.GetConfig(ConfigName.GiftConfig)
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
2025-08-21 19:26:08 +08:00
function this.Initialize()
2025-11-19 17:03:47 +08:00
this.allHeroGifts = {}
this.playerGifts = {}
2025-08-21 19:26:08 +08:00
end
--初始化命石
function this.InitGemsInfo(msg)
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
end
--初始化英雄礼物
2025-11-19 17:03:47 +08:00
function this.InitHeroGift(id, list)
this.allHeroGifts[id] = list
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--初始化主角礼物
2025-11-19 17:03:47 +08:00
function this.InitPlayerGift(list)
this.playerGifts = list
2025-08-21 19:26:08 +08:00
end
--获取收取等级和最大数量
function this.GetCollectLvAndNum()
2025-11-19 17:03:47 +08:00
local lv = 0
local maxNum = 0
local collect = 0
local curNum = 0
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
2025-08-21 19:26:08 +08:00
if equipConfig[id] then
2025-11-19 17:03:47 +08:00
collect = collect + equipConfig[id].Gift
2025-08-21 19:26:08 +08:00
end
end
for k, v in ConfigPairs(giftConfig) do
2025-11-19 17:03:47 +08:00
if collect >= v.Gift then
lv = v.Id
curNum = v.Box
2025-08-21 19:26:08 +08:00
else
2025-11-19 17:03:47 +08:00
maxNum = v.Box
2025-08-21 19:26:08 +08:00
break
end
end
2025-11-19 17:03:47 +08:00
if maxNum == 0 then
maxNum = curNum
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
return lv, curNum, maxNum
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
--获取收取等级和最大数量
function this.GetHeroGiftBoxNum(dynamicId)
2025-11-24 16:54:00 +08:00
LogError("ffffffffffffffff"..tostring(#HeroManager.GetAllHeroDatasByStar(13)))
local maxNum = 0
2025-11-19 17:03:47 +08:00
for k, v in ConfigPairs(giftConfig) do
2025-11-24 16:54:00 +08:00
if v.Harmony <= #HeroManager.GetAllHeroDatasByStar(13) and v.Box > maxNum then
2025-11-19 17:03:47 +08:00
maxNum = v.Box
end
end
return maxNum
end
2025-08-21 19:26:08 +08:00
--设置英雄礼物 type 1:穿 2:脱
2025-11-19 17:03:47 +08:00
function this.SetHeroGift(id, list, type)
if this.allHeroGifts[id] == nil then
this.allHeroGifts[id] = {}
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
for i = 1, #list do
if type == 1 then
table.insert(this.allHeroGifts[id], list[i])
elseif type == 2 then
table.removebyvalue(this.allHeroGifts[id], list[i])
2025-08-21 19:26:08 +08:00
end
end
2025-11-19 17:03:47 +08:00
HeroManager.ChangeHeroGift(id, this.allHeroGifts[id])
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--设置主角礼物
function this.SetPlayerGift(list)
2025-11-19 17:03:47 +08:00
for i = 1, #list do
table.insert(this.playerGifts, list[i])
2025-08-21 19:26:08 +08:00
end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--移除主角礼物
function this.RemovePlayerGift(list)
2025-11-19 17:03:47 +08:00
for i = 1, #list do
table.removebyvalue(this.playerGifts, list[i])
2025-08-21 19:26:08 +08:00
end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
function this.GetHeroGifts(_id)
if this.allHeroGifts[_id] then
return this.allHeroGifts[_id]
end
return {}
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
function this.GetPlayerGifts()
return this.playerGifts
end
2025-11-19 17:03:47 +08:00
function this.changeGiftsByType(_type, _list)
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--获取英雄礼物增加的属性
function this.GetHeroGiftAddPro(_id)
2025-11-19 17:03:47 +08:00
local data = {}
2025-08-21 19:26:08 +08:00
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
2025-11-19 17:03:47 +08:00
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
2025-08-21 19:26:08 +08:00
end
end
end
--HeroGitUp
2025-11-19 17:03:47 +08:00
local list = this.allHeroGifts[_id]
for i = 1, #list do
local id = list[i]
2025-08-21 19:26:08 +08:00
local pro = equipConfig[id].Property
2025-11-19 17:03:47 +08:00
if pro and #pro > 0 then
2025-08-21 19:26:08 +08:00
for k = 1, #pro do
2025-11-19 17:03:47 +08:00
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= 0 and tonumber(key) ~= nil then
2025-08-21 19:26:08 +08:00
if not data[key] then
data[key] = 0
end
2025-11-19 17:03:47 +08:00
data[key] = data[key] + value
2025-08-21 19:26:08 +08:00
end
end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--英雄礼物不会加成主角属性
-- local pro2 = equipConfig[id].PlayerProperty
-- if pro2 and #pro2>0 then
-- for k = 1, #pro2 do
-- if not data[pro2[k][1]] then
-- data[pro2[k][1]] = 0
-- end
-- data[pro2[k][1]] = data[pro2[k][1]] + pro2[k][2]
-- end
-- end
end
return data
end
--获取英雄礼物增加的白板属性属性(表里配置的属性)
function this.GetHeroGiftAddOriginalPro(_id)
2025-11-19 17:03:47 +08:00
local data = {}
2025-08-21 19:26:08 +08:00
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
2025-11-19 17:03:47 +08:00
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
2025-08-21 19:26:08 +08:00
end
end
end
--HeroGitUp
2025-11-19 17:03:47 +08:00
local list = this.allHeroGifts[_id]
for i = 1, #list do
local id = list[i]
2025-08-21 19:26:08 +08:00
local pro = equipConfig[id].Property
2025-11-19 17:03:47 +08:00
if pro and #pro > 0 then
2025-08-21 19:26:08 +08:00
for k = 1, #pro do
2025-11-19 17:03:47 +08:00
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= 0 and tonumber(key) ~= nil then
2025-08-21 19:26:08 +08:00
if not data[key] then
data[key] = 0
end
2025-11-19 17:03:47 +08:00
data[key] = data[key] + value
2025-08-21 19:26:08 +08:00
end
end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--英雄礼物不会加成主角属性
-- local pro2 = equipConfig[id].PlayerProperty
-- if pro2 and #pro2>0 then
-- for k = 1, #pro2 do
-- if not data[pro2[k][1]] then
-- data[pro2[k][1]] = 0
-- end
-- data[pro2[k][1]] = data[pro2[k][1]] + pro2[k][2]
-- end
-- end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
return data
end
--检测英雄礼物合成红点
function this.CheckHeroGiftComRed()
2025-11-19 17:03:47 +08:00
local giftList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig, "Position", 8)
2025-08-21 19:26:08 +08:00
if giftList then
2025-11-19 17:03:47 +08:00
for i = 1, #giftList do
local curequipSign = giftList[i]
if curequipSign.Formula and #curequipSign.Formula > 0 and type(curequipSign.Formula[1][1]) ~= "userdata" then
local key = curequipSign.Formula[1][1]
local value = curequipSign.Formula[1][2]
local isMatEnough = false
2025-08-21 19:26:08 +08:00
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
local curBagSoulPrintDatas = {}
2025-11-19 17:03:47 +08:00
local maxNum = 0
2025-08-21 19:26:08 +08:00
for i = 1, #datas do
2025-11-19 17:03:47 +08:00
if curequipSign.Star > 0 then
2025-08-21 19:26:08 +08:00
if datas[i].id == key then
2025-11-19 17:03:47 +08:00
for j = 1, datas[i].num do
if maxNum == value then
2025-08-21 19:26:08 +08:00
break
end
2025-11-19 17:03:47 +08:00
maxNum = maxNum + 1
2025-08-21 19:26:08 +08:00
end
end
else
if equipConfig[datas[i].id].Quality == key then
2025-11-19 17:03:47 +08:00
for j = 1, datas[i].num do
if maxNum == value then
2025-08-21 19:26:08 +08:00
break
end
2025-11-19 17:03:47 +08:00
maxNum = maxNum + 1
2025-08-21 19:26:08 +08:00
end
end
end
end
2025-11-19 17:03:47 +08:00
if maxNum >= value then
isMatEnough = true
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
local resource = curequipSign.Resource
local isGoldEough = true
if resource and #resource > 0 and type(resource[1][1]) ~= "userdata" then
for i = 1, #resource do
if BagManager.GetItemCountById(resource[i][1]) < resource[i][2] then
isGoldEough = false
2025-08-21 19:26:08 +08:00
end
end
end
if isMatEnough and isGoldEough then
return true
end
end
end
end
return false
end
--检测主角礼物合成红点
function this.CheckPlayerGiftComRed()
2025-11-19 17:03:47 +08:00
local giftList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig, "Position", 7)
2025-08-21 19:26:08 +08:00
if giftList then
2025-11-19 17:03:47 +08:00
for i = 1, #giftList do
local curequipSign = giftList[i]
if curequipSign.Formula and #curequipSign.Formula > 0 and type(curequipSign.Formula[1][1]) ~= "userdata" then
local key = curequipSign.Formula[1][1]
local value = curequipSign.Formula[1][2]
local isMatEnough = false
2025-08-21 19:26:08 +08:00
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
local curBagSoulPrintDatas = {}
2025-11-19 17:03:47 +08:00
local maxNum = 0
2025-08-21 19:26:08 +08:00
for i = 1, #datas do
2025-11-19 17:03:47 +08:00
if curequipSign.Star > 0 then
2025-08-21 19:26:08 +08:00
if datas[i].id == key then
2025-11-19 17:03:47 +08:00
for j = 1, datas[i].num do
if maxNum == value then
2025-08-21 19:26:08 +08:00
break
end
2025-11-19 17:03:47 +08:00
maxNum = maxNum + 1
2025-08-21 19:26:08 +08:00
end
end
else
if equipConfig[datas[i].id].Quality == key then
2025-11-19 17:03:47 +08:00
for j = 1, datas[i].num do
if maxNum == value then
2025-08-21 19:26:08 +08:00
break
end
2025-11-19 17:03:47 +08:00
maxNum = maxNum + 1
2025-08-21 19:26:08 +08:00
end
end
end
end
2025-11-19 17:03:47 +08:00
if maxNum >= value then
isMatEnough = true
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
local resource = curequipSign.Resource
local isGoldEough = true
if resource and #resource > 0 and type(resource[1][1]) ~= "userdata" then
for i = 1, #resource do
if BagManager.GetItemCountById(resource[i][1]) < resource[i][2] then
isGoldEough = false
2025-08-21 19:26:08 +08:00
end
end
end
if isMatEnough and isGoldEough then
return true
end
end
end
end
return false
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--检测英雄红点
function this.CheckRoleRedPointById(_id)
2025-11-19 17:03:47 +08:00
local lv, cur, max = this.GetCollectLvAndNum()
2025-08-21 19:26:08 +08:00
if this.allHeroGifts[_id] then
2025-11-19 17:03:47 +08:00
local list = this.allHeroGifts[_id]
if #list >= cur then
2025-08-21 19:26:08 +08:00
return false
end
2025-11-19 17:03:47 +08:00
local suitIds = {}
for i = 1, #list do
table.insert(suitIds, equipConfig[list[i]].SuiteID)
2025-08-21 19:26:08 +08:00
end
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
2025-11-19 17:03:47 +08:00
for i = 1, #allEquip do
if CheckListIsContainValue1(list, allEquip[i].id) == false and CheckListIsContainValue1(suitIds, equipConfig[allEquip[i].id].SuiteID) == false then
2025-08-21 19:26:08 +08:00
return true
end
end
else
return false
end
return false
end
2025-11-19 17:03:47 +08:00
2025-10-14 15:28:28 +08:00
--获取单个英雄装备数据
function this.GetSingleHeroSingleEquipData(_equipid, _heroDid)
--LogError("获取英雄礼物信息:"..tostring(_equipid).."/".._heroDid)
return equipConfig[_equipid]
end
2025-08-21 19:26:08 +08:00
--检测主角红点
function this.CheckPlayerRedPoint()
2025-11-19 17:03:47 +08:00
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.Gift)
if isOpen == false then
2025-08-21 19:26:08 +08:00
return false
end
2025-11-19 17:03:47 +08:00
local suitIds = {}
for i = 1, #this.playerGifts do
table.insert(suitIds, equipConfig[this.playerGifts[i]].SuiteID)
2025-08-21 19:26:08 +08:00
end
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
2025-11-19 17:03:47 +08:00
for i = 1, #allEquip do
if CheckListIsContainValue1(this.playerGifts, allEquip[i].id) == false and CheckListIsContainValue1(suitIds, equipConfig[allEquip[i].id].SuiteID) == false then
2025-08-21 19:26:08 +08:00
return true
end
end
return false
end
--获取英雄潜能等级
function this.GetHeroPotencyLvById(did)
2025-11-19 17:03:47 +08:00
local lv = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
2025-08-21 19:26:08 +08:00
end
end
end
if this.allHeroGifts and this.allHeroGifts[did] then
2025-11-19 17:03:47 +08:00
local list = this.allHeroGifts[did]
for i = 1, #list do
local id = list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
2025-08-21 19:26:08 +08:00
end
end
end
--LogError("礼物增加 潜能 lv====================================="..lv)
return lv
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
--获取主角礼物添加的潜能等级
function this.GetPlayerGiftAddPotencyLv()
2025-11-19 17:03:47 +08:00
local lv = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
2025-08-21 19:26:08 +08:00
end
end
end
return lv
end
--获取英雄礼物添加的潜能等级
function this.GetHeroGiftAddPotencyLv(did)
2025-11-19 17:03:47 +08:00
local lv = 0
2025-08-21 19:26:08 +08:00
if this.allHeroGifts and this.allHeroGifts[did] then
2025-11-19 17:03:47 +08:00
local list = this.allHeroGifts[did]
for i = 1, #list do
local id = list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
2025-08-21 19:26:08 +08:00
end
end
end
return lv
end
--获取主角礼物增加的属性
function this.GetPlayerGiftAddPro()
2025-11-19 17:03:47 +08:00
local data = {}
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
2025-08-21 19:26:08 +08:00
local pro = equipConfig[id].PlayerProperty
2025-11-19 17:03:47 +08:00
if pro and #pro > 0 then
2025-08-21 19:26:08 +08:00
for k = 1, #pro do
2025-11-19 17:03:47 +08:00
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= nil and tonumber(key) ~= 0 then
if key ~= 0 and key ~= nil then
2025-08-21 19:26:08 +08:00
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
end
end
end
end
2025-11-19 17:03:47 +08:00
2025-08-21 19:26:08 +08:00
local pro2 = equipConfig[id].Property
2025-11-19 17:03:47 +08:00
if pro2 and #pro2 > 0 and pro2[1][1] ~= 0 and pro2[1][1] ~= nil then
2025-08-21 19:26:08 +08:00
for k = 1, #pro2 do
2025-11-19 17:03:47 +08:00
local key = pro2[k][1]
local value = pro2[k][2]
if tonumber(key) ~= nil and tonumber(key) ~= 0 then
2025-08-21 19:26:08 +08:00
if not data[key] then
data[key] = 0
end
2025-11-19 17:03:47 +08:00
if value and value ~= 0 then
LogError("pro2[k][1]===" .. key .. " value==" .. value)
data[key] = data[key] + value
2025-08-21 19:26:08 +08:00
end
end
end
end
end
return data
end
function this.CheckGemRed()
return false
end
function this.CheckSuperGemRed()
return false
end
function this.GetPlayerGiftAdd()
2025-11-19 17:03:47 +08:00
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
2025-08-21 19:26:08 +08:00
end
end
end
2025-11-19 17:03:47 +08:00
return addPro / 100
2025-08-21 19:26:08 +08:00
end
2025-11-19 17:03:47 +08:00
return this