|
@@ -5,6 +5,8 @@
|
|
|
basketItemArr = nil, --篮子里的道具idx列表
|
|
basketItemArr = nil, --篮子里的道具idx列表
|
|
|
|
|
|
|
|
lotteryTimes = nil, -- 抽奖次数
|
|
lotteryTimes = nil, -- 抽奖次数
|
|
|
|
|
+
|
|
|
|
|
+ nowStage = 0, -- 当前阶段, 0-未开始阶段, 1-抽奖阶段
|
|
|
}
|
|
}
|
|
|
]=]--
|
|
]=]--
|
|
|
|
|
|
|
@@ -21,7 +23,7 @@ local AbsActExcel = require("excel.absAct")
|
|
|
|
|
|
|
|
local LOGTYPE = "CommonActMoneyTree" -- 日志标识
|
|
local LOGTYPE = "CommonActMoneyTree" -- 日志标识
|
|
|
local COMMONACT_MONEYTREE_ID = 7506 -- 活动Id
|
|
local COMMONACT_MONEYTREE_ID = 7506 -- 活动Id
|
|
|
-local BASKET_WEIGHT = 100 -- 篮子可承受的总重量
|
|
|
|
|
|
|
+local BASKET_WEIGHT_MAX = 100 -- 篮子可承受的总重量
|
|
|
|
|
|
|
|
|
|
|
|
|
local function getData(human)
|
|
local function getData(human)
|
|
@@ -49,6 +51,12 @@ local function resetBasketArr(human)
|
|
|
actData.basketItemArr = nil
|
|
actData.basketItemArr = nil
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+local function updateStage(human, newStage)
|
|
|
|
|
+ local actData = getData(human)
|
|
|
|
|
+ actData.nowStage = newStage
|
|
|
|
|
+end
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
local function isOpenAct(human, funcID)
|
|
local function isOpenAct(human, funcID)
|
|
@@ -118,6 +126,10 @@ function isRed(human, YYInfo, funcConfig)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
local actData = getData(human)
|
|
local actData = getData(human)
|
|
|
|
|
+ if (actData.nowStage or 0) == 1 then
|
|
|
|
|
+ return true
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
if (actData.lotteryTimes or 0) > 0 then
|
|
if (actData.lotteryTimes or 0) > 0 then
|
|
|
return true
|
|
return true
|
|
|
end
|
|
end
|
|
@@ -169,11 +181,12 @@ end
|
|
|
function CommonActMoneyTree_Query(human)
|
|
function CommonActMoneyTree_Query(human)
|
|
|
local msgRet = Msg.gc.GC_ABS_COMONACT_MONEYTREE_QUERY
|
|
local msgRet = Msg.gc.GC_ABS_COMONACT_MONEYTREE_QUERY
|
|
|
msgRet.rewardBasket[0] = 0
|
|
msgRet.rewardBasket[0] = 0
|
|
|
- msgRet.weighMax = BASKET_WEIGHT
|
|
|
|
|
|
|
+ msgRet.weighMax = BASKET_WEIGHT_MAX
|
|
|
msgRet.weighNow = 0
|
|
msgRet.weighNow = 0
|
|
|
msgRet.lotteryTimes = 0
|
|
msgRet.lotteryTimes = 0
|
|
|
msgRet.isStart = 1
|
|
msgRet.isStart = 1
|
|
|
msgRet.isEnd = 0
|
|
msgRet.isEnd = 0
|
|
|
|
|
+ msgRet.nowStage = 0
|
|
|
|
|
|
|
|
local actData = getData(human)
|
|
local actData = getData(human)
|
|
|
|
|
|
|
@@ -185,6 +198,10 @@ function CommonActMoneyTree_Query(human)
|
|
|
msgRet.weighNow = calcBasketWeight(actData.basketItemArr)
|
|
msgRet.weighNow = calcBasketWeight(actData.basketItemArr)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ if actData.nowStage then
|
|
|
|
|
+ msgRet.nowStage = actData.nowStage
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
local itemNum = actData.basketItemArr and #actData.basketItemArr or 0
|
|
local itemNum = actData.basketItemArr and #actData.basketItemArr or 0
|
|
|
if itemNum == 0 then
|
|
if itemNum == 0 then
|
|
|
msgRet.isEnd = 1
|
|
msgRet.isEnd = 1
|
|
@@ -219,8 +236,8 @@ function CommonActMoneyTree_Query(human)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
--- 抽奖
|
|
|
|
|
-function CommonActMoneyTree_Lottery(human)
|
|
|
|
|
|
|
+-- 进入抽奖阶段
|
|
|
|
|
+function CommonActMoneyTree_EnterLotteryStage(human)
|
|
|
if not isOpenAct(human, COMMONACT_MONEYTREE_ID) then
|
|
if not isOpenAct(human, COMMONACT_MONEYTREE_ID) then
|
|
|
return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
|
|
return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
|
|
|
end
|
|
end
|
|
@@ -230,25 +247,48 @@ function CommonActMoneyTree_Lottery(human)
|
|
|
return Broadcast.sendErr(human, Lang.JINBI_EXCHANGE_ERR_CNT)
|
|
return Broadcast.sendErr(human, Lang.JINBI_EXCHANGE_ERR_CNT)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ -- 扣除次数
|
|
|
|
|
+ updateLotteryTimes(human, -1)
|
|
|
|
|
+
|
|
|
|
|
+ -- 更新阶段
|
|
|
|
|
+ updateStage(human, 1)
|
|
|
|
|
+
|
|
|
|
|
+ -- 推送最新数据给客户端
|
|
|
|
|
+ CommonActMoneyTree_Query(human)
|
|
|
|
|
+end
|
|
|
|
|
+
|
|
|
|
|
+-- 抽一次奖
|
|
|
|
|
+function CommonActMoneyTree_Lottery(human)
|
|
|
|
|
+ if not isOpenAct(human, COMMONACT_MONEYTREE_ID) then
|
|
|
|
|
+ return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ local actData = getData(human)
|
|
|
|
|
+ if (actData.nowStage or 0) ~= 1 then
|
|
|
|
|
+ return Broadcast.sendErr(human, Lang.MONEYTREE_START)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
if actData.basketItemArr then
|
|
if actData.basketItemArr then
|
|
|
local weightNow = calcBasketWeight(actData.basketItemArr)
|
|
local weightNow = calcBasketWeight(actData.basketItemArr)
|
|
|
- if weightNow > BASKET_WEIGHT then
|
|
|
|
|
|
|
+ if weightNow > BASKET_WEIGHT_MAX then
|
|
|
return Broadcast.sendErr(human, Lang.MONEYTREE_IS_MAX)
|
|
return Broadcast.sendErr(human, Lang.MONEYTREE_IS_MAX)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-- 扣除次数
|
|
-- 扣除次数
|
|
|
- updateLotteryTimes(human, -1)
|
|
|
|
|
|
|
+ -- updateLotteryTimes(human, -1)
|
|
|
|
|
|
|
|
local finalIdx = lottery()
|
|
local finalIdx = lottery()
|
|
|
if finalIdx == 0 then
|
|
if finalIdx == 0 then
|
|
|
return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
|
|
return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- -- 检查当前篮子中道具重量是否超过限定重量, 如果超过则当前篮子中每个道具都有50%几率失去
|
|
|
|
|
|
|
+ -- 把道具加入篮子
|
|
|
insertBasketItemArr(human, finalIdx)
|
|
insertBasketItemArr(human, finalIdx)
|
|
|
|
|
+
|
|
|
|
|
+ -- 检查当前篮子中道具重量是否超过限定重量, 如果超过则当前篮子中每个道具都有50%几率失去
|
|
|
local weightNow = calcBasketWeight(actData.basketItemArr)
|
|
local weightNow = calcBasketWeight(actData.basketItemArr)
|
|
|
- if weightNow > BASKET_WEIGHT then
|
|
|
|
|
|
|
+ if weightNow > BASKET_WEIGHT_MAX then
|
|
|
local newBasketItemArr = randBasketItem(actData.basketItemArr)
|
|
local newBasketItemArr = randBasketItem(actData.basketItemArr)
|
|
|
updateBasketItemArr(human, newBasketItemArr)
|
|
updateBasketItemArr(human, newBasketItemArr)
|
|
|
CommonActMoneyTree_Query(human)
|
|
CommonActMoneyTree_Query(human)
|
|
@@ -268,6 +308,10 @@ function CommonActMoneyTree_GetReward(human)
|
|
|
|
|
|
|
|
local actData = getData(human)
|
|
local actData = getData(human)
|
|
|
|
|
|
|
|
|
|
+ if (actData.nowStage or 0) ~= 1 then
|
|
|
|
|
+ return Broadcast.sendErr(human, Lang.MONEYTREE_START)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
if not actData.basketItemArr or not next(actData.basketItemArr) then
|
|
if not actData.basketItemArr or not next(actData.basketItemArr) then
|
|
|
return Broadcast.sendErr(human, Lang.SHARE_GROUP_GET_ERR_CNT)
|
|
return Broadcast.sendErr(human, Lang.SHARE_GROUP_GET_ERR_CNT)
|
|
|
end
|
|
end
|
|
@@ -282,8 +326,15 @@ function CommonActMoneyTree_GetReward(human)
|
|
|
-- 重置篮子中道具数据
|
|
-- 重置篮子中道具数据
|
|
|
resetBasketArr(human)
|
|
resetBasketArr(human)
|
|
|
|
|
|
|
|
|
|
+ -- 更新阶段
|
|
|
|
|
+ updateStage(human, 0)
|
|
|
|
|
+
|
|
|
-- 发放道具
|
|
-- 发放道具
|
|
|
BagLogic.addItemList(human, itemList, LOGTYPE)
|
|
BagLogic.addItemList(human, itemList, LOGTYPE)
|
|
|
|
|
|
|
|
|
|
+ -- 推送最新数据给客户端
|
|
|
CommonActMoneyTree_Query(human)
|
|
CommonActMoneyTree_Query(human)
|
|
|
|
|
+
|
|
|
|
|
+ -- 刷新红点
|
|
|
|
|
+ updateRedDot(human)
|
|
|
end
|
|
end
|