|
|
@@ -8,6 +8,9 @@ local Broadcast = require("broadcast.Broadcast")
|
|
|
local DrillLogic = require("drill.DrillLogic")
|
|
|
local ZhuanpanExcel = require("excel.zhuanpan")
|
|
|
local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
|
|
|
+local CommonDefine = require("common.CommonDefine")
|
|
|
+local Grid = require("bag.Grid")
|
|
|
+local BagLogic = require("bag.BagLogic")
|
|
|
|
|
|
DOUBLE_NEED_LV = 10 -- 福利双倍 开启等级
|
|
|
|
|
|
@@ -22,6 +25,35 @@ local function initDB(human)
|
|
|
human.db.roleSys = human.db.roleSys or {}
|
|
|
end
|
|
|
|
|
|
+local function RoleSystem_InitPrizeDB(human)
|
|
|
+ human.db.roleSystemPrize = {}
|
|
|
+ for id, conf in pairs(RoleSystemExcel.roleSystem) do
|
|
|
+ if conf.isdisplay == 1 then
|
|
|
+ human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+local function RoleSystem_CheckPrize(human)
|
|
|
+ if not human.db.roleSystemPrize then
|
|
|
+ RoleSystem_InitPrizeDB(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ for id, conf in pairs(RoleSystemExcel.roleSystem) do
|
|
|
+ if conf.isdisplay == 1 then
|
|
|
+ if not human.db.roleSystemPrize[id] then
|
|
|
+ human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
|
|
|
+ end
|
|
|
+
|
|
|
+ if true == isOpen(human,conf.id) then
|
|
|
+ local nState = human.db.roleSystemPrize[id]
|
|
|
+ if CommonDefine.COMMON_PRIZE_STATE_NOGET == nState then
|
|
|
+ human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_CANGET
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
|
|
|
function initAfterHot()
|
|
|
for id, conf in pairs(RoleSystemExcel.roleSystem) do
|
|
|
@@ -253,10 +285,12 @@ function onLogin(human)
|
|
|
human.roleSystem = human.roleSystem or {}
|
|
|
sendSystemAll(human)
|
|
|
senddSysemOpen(human)
|
|
|
+ RoleSystem_CheckPrize(human)
|
|
|
end
|
|
|
|
|
|
function onLvUp(human)
|
|
|
sendSystemAll(human)
|
|
|
+ RoleSystem_CheckPrize(human)
|
|
|
end
|
|
|
|
|
|
function onDotByUuid(uuid, id)
|
|
|
@@ -312,3 +346,63 @@ function checkMailTips(human)
|
|
|
DrillLogic.sendDrillTip(human)
|
|
|
end
|
|
|
|
|
|
+function RoleSystem_QueryPrize(human)
|
|
|
+ if not human.db.roleSystemPrize then
|
|
|
+ RoleSystem_InitPrizeDB(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ local tMsgData = Msg.gc.GC_ROLESYSTEM_PRIZE_QUERY
|
|
|
+ tMsgData.tList[0] = 0
|
|
|
+ local nLen = 0
|
|
|
+ for id, conf in pairs(RoleSystemExcel.roleSystem) do
|
|
|
+ if conf.isdisplay == 1 then
|
|
|
+ nLen = nLen + 1
|
|
|
+ local tData = tMsgData.tList[nLen]
|
|
|
+ tData.nID = id
|
|
|
+ if not human.db.roleSystemPrize[id] then
|
|
|
+ human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
|
|
|
+ end
|
|
|
+ tData.nStatus = human.db.roleSystemPrize[id]
|
|
|
+
|
|
|
+ tData.tItemList[0] = #conf.reward
|
|
|
+ for i, value in ipairs(conf.reward) do
|
|
|
+ local tItemData = tData.tItemList[i]
|
|
|
+ Grid.makeItem(tItemData, value[1], value[2])
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ tMsgData.tList[0] = nLen
|
|
|
+
|
|
|
+ Msg.send(tMsgData, human.fd)
|
|
|
+ print("[RoleSystem_QueryPrize] 下发活动预告奖励结束")
|
|
|
+end
|
|
|
+
|
|
|
+function RoleSystem_GetPrize(human)
|
|
|
+ local tItem = {}
|
|
|
+ for id, conf in pairs(RoleSystemExcel.roleSystem) do
|
|
|
+ if conf.isdisplay == 1 then
|
|
|
+ local nStatus = human.db.roleSystemPrize[id] or CommonDefine.COMMON_PRIZE_STATE_NOGET
|
|
|
+ if CommonDefine.COMMON_PRIZE_STATE_CANGET == nStatus then
|
|
|
+ for _, v in ipairs(conf.reward) do
|
|
|
+ if not tItem[v[1]] then
|
|
|
+ tItem[v[1]] = 0
|
|
|
+ end
|
|
|
+
|
|
|
+ tItem[v[1]] = tItem[v[1]] + v[2]
|
|
|
+ end
|
|
|
+
|
|
|
+ human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_GET
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if nil ~= _G.next(tItem) then
|
|
|
+ local tGoods = {}
|
|
|
+ for nID, nNum in pairs(tItem) do
|
|
|
+ table.insert(tGoods, {nID, nNum})
|
|
|
+ end
|
|
|
+
|
|
|
+ BagLogic.addItemList(human, tItem, "rolesystemprize")
|
|
|
+ RoleSystem_QueryPrize(human)
|
|
|
+ end
|
|
|
+end
|