【命格】提交
parent
98308fe892
commit
bf46f1a6f6
|
@ -121,10 +121,10 @@ function BagPanel:BindEvent()
|
|||
end)
|
||||
Util.AddClick(this.oneKey, function()
|
||||
local list,num = GemManager.OneKeyConpound()
|
||||
LogGreen("====================金币:"..tostring(num).."=============")
|
||||
for key, value in pairs(list) do
|
||||
LogPink("key:"..tostring(key).." Value:"..tostring(value))
|
||||
end
|
||||
-- LogGreen("====================金币:"..tostring(num).."=============")
|
||||
-- for key, value in pairs(list) do
|
||||
-- LogPink("key:"..tostring(key).." Value:"..tostring(value))
|
||||
-- end
|
||||
if num <= 0 then
|
||||
PopupTipPanel.ShowTip("无可合成的命石或金币不足!")
|
||||
return
|
||||
|
|
|
@ -116,15 +116,13 @@ function this.OneKeyConpound()
|
|||
local totalMoney = 0
|
||||
local finalList = {}
|
||||
local configMap = this.GetMapOfBagData()
|
||||
local curMoney = BagManager.GetTotalItemNum(14)--当前金币数量
|
||||
--1-8的外部循环
|
||||
for i = 1, #configMap do
|
||||
local bool,money = this.DoCircle1(finalList,configMap[i])
|
||||
local money = this.DoCircle1(finalList,configMap[i],curMoney)
|
||||
totalMoney = totalMoney + money
|
||||
curMoney = curMoney - totalMoney
|
||||
-- LogGreen("money:"..tostring(totalMoney))
|
||||
if not bool then
|
||||
-- LogError("合成结束")
|
||||
break
|
||||
end
|
||||
end
|
||||
local tempList = {}
|
||||
for key, value in pairs(finalList) do--存在数据为0的情况,剔除
|
||||
|
@ -136,7 +134,7 @@ function this.OneKeyConpound()
|
|||
end
|
||||
|
||||
--一键合成循环
|
||||
function this.DoCircle1(finalList,data)
|
||||
function this.DoCircle1(finalList,data,money)
|
||||
local totalMoney = 0
|
||||
local lastGNum = 0--上一次合成出来的数量
|
||||
for i = 1, #data do
|
||||
|
@ -169,7 +167,7 @@ function this.DoCircle1(finalList,data)
|
|||
end
|
||||
if curGemNum > 0 then
|
||||
local needMoneyNum = curGemNum/tempData.UpgradeNum * tempData.UpgradeCost[2]--按照命石可合成的数量,要花费的金币
|
||||
local curMoneyNum = BagManager.GetTotalItemNum(tempData.UpgradeCost[1])--当前金币数量
|
||||
local curMoneyNum = money--BagManager.GetTotalItemNum(tempData.UpgradeCost[1])--当前金币数量
|
||||
-- LogYellow("needMoneyNum:"..tostring(needMoneyNum).." totalMoney:"..tostring(totalMoney))
|
||||
if needMoneyNum + totalMoney > curMoneyNum then--如果当前金币不足要花费的数量,计算可以合成几个
|
||||
local upNum = math.floor((curMoneyNum - totalMoney)/tempData.UpgradeCost[2])--实际真的合成了几个
|
||||
|
@ -182,7 +180,7 @@ function this.DoCircle1(finalList,data)
|
|||
finalList[tempData.NextGem] = upNum
|
||||
-- LogPurple("3:ID:"..tostring(tempData.NextGem).." num:"..tostring(upNum))
|
||||
-- LogRed("Bool:"..tostring(false).." totalMoney:"..tostring(totalMoney))
|
||||
return false,totalMoney
|
||||
return totalMoney
|
||||
else--如果金币足额
|
||||
totalMoney = totalMoney + needMoneyNum--金币计入总数
|
||||
if remainNum > 0 then
|
||||
|
@ -199,7 +197,7 @@ function this.DoCircle1(finalList,data)
|
|||
end
|
||||
end
|
||||
-- LogRed("Bool:"..tostring(true).." totalMoney:"..tostring(totalMoney))
|
||||
return true,totalMoney
|
||||
return totalMoney
|
||||
end
|
||||
|
||||
--=========================快速合成================================
|
||||
|
|
Loading…
Reference in New Issue