miduo_client/Assets/ManagedResources/~Lua/Modules/Gem/GiftManager.lua

493 lines
15 KiB
Lua
Raw Normal View History

2023-09-13 14:57:48 +08:00
--新的命格管理
GiftManager = {}
local this = GiftManager
local giftConfig=ConfigManager.GetConfig(ConfigName.GiftConfig)
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
function this.Initialize()
this.allHeroGifts={}
this.playerGifts={}
end
--初始化命石
function this.InitGemsInfo(msg)
end
--初始化英雄礼物
function this.InitHeroGift(id,list)
this.allHeroGifts[id]=list
end
--初始化主角礼物
function this.InitPlayerGift(list)
this.playerGifts=list
end
--获取收取等级和最大数量
function this.GetCollectLvAndNum()
local lv=0
local maxNum=0
local collect=0
local curNum=0
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] then
collect=collect+equipConfig[id].Gift
end
end
2023-11-28 21:31:01 +08:00
if CheckFunctionOpen(FUNCTION_OPEN_TYPE.Train) then
collect=collect+HeroManager.ReturnGiftCount()
end
2023-09-13 14:57:48 +08:00
for k, v in ConfigPairs(giftConfig) do
if collect>=v.Gift then
lv=v.Id
curNum=v.Box
else
maxNum=v.Box
break
end
end
2023-11-28 21:31:01 +08:00
2023-09-21 15:18:13 +08:00
if maxNum==0 then
maxNum=curNum
end
2023-09-13 14:57:48 +08:00
return lv,curNum,maxNum
end
--设置英雄礼物 type 1穿 2
function this.SetHeroGift(id,list,type)
if this.allHeroGifts[id]==nil then
this.allHeroGifts[id]={}
end
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])
end
end
2023-09-20 11:52:31 +08:00
HeroManager.ChangeHeroGift(id,this.allHeroGifts[id])
2023-09-13 14:57:48 +08:00
end
--设置主角礼物
function this.SetPlayerGift(list)
for i=1,#list do
table.insert(this.playerGifts,list[i])
end
end
2024-01-10 18:12:31 +08:00
--移除主角礼物
function this.RemovePlayerGift(list)
for i=1,#list do
table.removebyvalue(this.playerGifts,list[i])
end
end
2023-09-13 14:57:48 +08:00
function this.GetHeroGifts(_id)
if this.allHeroGifts[_id] then
return this.allHeroGifts[_id]
end
return {}
end
function this.GetPlayerGifts()
return this.playerGifts
end
function this.changeGiftsByType(_type,_list)
end
2023-09-15 14:11:14 +08:00
--获取英雄礼物增加的属性
function this.GetHeroGiftAddPro(_id)
local data={}
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
2023-09-15 14:11:14 +08:00
return data
end
2023-11-13 15:34:29 +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
end
end
end
--HeroGitUp
local list=this.allHeroGifts[_id]
for i=1,#list do
local id=list[i]
2023-09-15 14:11:14 +08:00
local pro = equipConfig[id].Property
if pro and #pro>0 then
for k = 1, #pro do
local key=pro[k][1]
local value=pro[k][2]
if tonumber(key)~=0 and tonumber(key)~=nil then
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
end
end
end
2024-01-02 18:16:56 +08:00
2023-09-15 14:11:14 +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
2024-01-02 18:16:56 +08:00
local trainAdd=0
if CheckFunctionOpen(FUNCTION_OPEN_TYPE.Train) then
trainAdd=HeroManager.ReturnGiftAtt()
-- for k, v in ipairs(data) do
-- data[k]=data[k]*(1+t)
-- end
end
2023-11-24 16:32:35 +08:00
if addPro>0 then
for k, v in pairs(data) do
2024-01-02 18:16:56 +08:00
data[k]=math.floor(v*(1+addPro/10000+trainAdd)+0.5)
2023-11-24 16:32:35 +08:00
end
end
2023-09-15 14:11:14 +08:00
return data
end
2024-01-02 18:16:56 +08:00
--获取英雄礼物增加的白板属性属性(表里配置的属性)
function this.GetHeroGiftAddOriginalPro(_id)
local data={}
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
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
end
end
end
--HeroGitUp
local list=this.allHeroGifts[_id]
for i=1,#list do
local id=list[i]
local pro = equipConfig[id].Property
if pro and #pro>0 then
for k = 1, #pro do
local key=pro[k][1]
local value=pro[k][2]
if tonumber(key)~=0 and tonumber(key)~=nil then
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
end
end
end
--英雄礼物不会加成主角属性
-- 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
2024-01-10 18:12:31 +08:00
--检测英雄礼物合成红点
function this.CheckHeroGiftComRed()
local giftList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",8)
if giftList then
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
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
local curBagSoulPrintDatas = {}
local maxNum=0
for i = 1, #datas do
if curequipSign.Star>0 then
if datas[i].id == key then
for j=1,datas[i].num do
if maxNum==value then
break
end
maxNum=maxNum+1
end
end
else
if equipConfig[datas[i].id].Quality == key then
for j=1,datas[i].num do
if maxNum==value then
break
end
maxNum=maxNum+1
end
end
end
end
if maxNum>=value then
isMatEnough=true
end
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
end
end
end
if isMatEnough and isGoldEough then
return true
end
end
end
end
return false
end
2024-01-02 18:16:56 +08:00
2024-01-10 18:12:31 +08:00
--检测主角礼物合成红点
function this.CheckPlayerGiftComRed()
local giftList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",7)
if giftList then
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
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
local curBagSoulPrintDatas = {}
local maxNum=0
for i = 1, #datas do
if curequipSign.Star>0 then
if datas[i].id == key then
for j=1,datas[i].num do
if maxNum==value then
break
end
maxNum=maxNum+1
end
end
else
if equipConfig[datas[i].id].Quality == key then
for j=1,datas[i].num do
if maxNum==value then
break
end
maxNum=maxNum+1
end
end
end
end
if maxNum>=value then
isMatEnough=true
end
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
end
end
end
if isMatEnough and isGoldEough then
return true
end
end
end
end
return false
end
2023-09-20 11:28:57 +08:00
--检测英雄红点
function this.CheckRoleRedPointById(_id)
local isOpen=CheckFunctionOpen(FUNCTION_OPEN_TYPE.Gift)
if isOpen==false then
return false
end
local lv,cur,max=this.GetCollectLvAndNum()
if this.allHeroGifts[_id] then
local list=this.allHeroGifts[_id]
if #list>=cur then
return false
end
2024-01-10 18:12:31 +08:00
local suitIds={}
for i=1,#list do
table.insert(suitIds,equipConfig[list[i]].SuiteID)
end
2023-09-20 11:28:57 +08:00
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
for i=1,#allEquip do
2024-01-10 18:12:31 +08:00
if CheckListIsContainValue1(list,allEquip[i].id)==false and CheckListIsContainValue1(suitIds,equipConfig[allEquip[i].id].SuiteID)==false then
2023-09-20 11:28:57 +08:00
return true
end
end
else
return false
end
return false
end
--检测主角红点
function this.CheckPlayerRedPoint()
local isOpen=CheckFunctionOpen(FUNCTION_OPEN_TYPE.Gift)
if isOpen==false then
return false
end
2024-01-10 18:12:31 +08:00
local suitIds={}
for i=1,#this.playerGifts do
table.insert(suitIds,equipConfig[this.playerGifts[i]].SuiteID)
end
2023-09-20 11:28:57 +08:00
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
for i=1,#allEquip do
2024-01-10 18:12:31 +08:00
if CheckListIsContainValue1(this.playerGifts,allEquip[i].id)==false and CheckListIsContainValue1(suitIds,equipConfig[allEquip[i].id].SuiteID)==false then
2023-09-20 11:28:57 +08:00
return true
end
end
return false
end
2023-10-16 15:12:47 +08:00
--获取英雄潜能等级
function this.GetHeroPotencyLvById(did)
local lv=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
2023-12-14 17:21:02 +08:00
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
2023-10-16 15:12:47 +08:00
lv=lv+equipConfig[id].PotentialNew[2]
end
end
end
if this.allHeroGifts and this.allHeroGifts[did] then
local list=this.allHeroGifts[did]
for i=1,#list do
local id=list[i]
2023-12-14 17:21:02 +08:00
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
2023-10-16 15:12:47 +08:00
lv=lv+equipConfig[id].PotentialNew[2]
end
end
end
--LogError("礼物增加 潜能 lv====================================="..lv)
return lv
end
2024-01-02 18:16:56 +08:00
--获取主角礼物添加的潜能等级
function this.GetPlayerGiftAddPotencyLv()
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]
end
end
end
return lv
end
2023-10-16 15:12:47 +08:00
2024-01-02 18:16:56 +08:00
--获取英雄礼物添加的潜能等级
function this.GetHeroGiftAddPotencyLv(did)
local lv=0
if this.allHeroGifts and this.allHeroGifts[did] then
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]
end
end
end
return lv
end
2023-10-16 15:12:47 +08:00
2023-09-13 14:57:48 +08:00
2023-09-15 14:11:14 +08:00
--获取主角礼物增加的属性
function this.GetPlayerGiftAddPro()
local data={}
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
local pro = equipConfig[id].PlayerProperty
if pro and #pro>0 then
for k = 1, #pro do
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
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
end
end
end
end
2023-09-15 14:11:14 +08:00
local pro2 = equipConfig[id].Property
if pro2 and #pro2>0 and pro2[1][1]~=0 and pro2[1][1]~=nil then
for k = 1, #pro2 do
local key=pro2[k][1]
local value=pro2[k][2]
if tonumber(key) ~=nil and tonumber(key)~=0 then
if not data[key] then
data[key] = 0
end
if value and value~=0 then
LogError("pro2[k][1]==="..key.." value=="..value)
data[key] = data[key] + value
end
end
2023-09-15 14:11:14 +08:00
end
end
2023-09-15 14:11:14 +08:00
end
2023-09-15 14:11:14 +08:00
return data
end
2023-09-13 14:57:48 +08:00
function this.CheckGemRed()
return false
end
function this.CheckSuperGemRed()
return false
end
2024-01-02 18:16:56 +08:00
function this.GetPlayerGiftAdd()
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
end
end
end
return addPro/100
end
2023-09-13 14:57:48 +08:00
return this