Jelajahi Sumber

在线奖励处理和系统开放奖励

SCFC 10 bulan lalu
induk
melakukan
ca31ff7f72

+ 2 - 0
script/common/LogDefine.lua

@@ -250,6 +250,8 @@ DEFINE = {
 	servercommerce 			= 254,			 -- 跨服商业活动
 	honorjourney 			= 255,			 -- 荣耀历程
 	qqbigshot				= 256,			 -- qq大咖
+	darkforarea 			= 257,			 -- 幽暗禁地
+	rolesystemprize 		= 258,			 -- 系统开放奖励
 	
 	abs_totalReach          = 500,           -- 周期性活动累计
     abs_singleReach         = 501,           -- 周期性活动单次

+ 6 - 1
script/common/ProtoID.lua

@@ -1485,5 +1485,10 @@ _ENV[1535]="GC_BATTLE_TEAM_COUNT"
 -- _ENV[1537]="GC_DARK_FORBIDDEN_AREA_QUEY"
 -- _ENV[1538]="CG_DARK_FORBIDDEN_AREA_SAODANG"
 
+_ENV[1539]="CG_ROLESYSTEM_PRIZE_QUERY"
+_ENV[1540]="GC_ROLESYSTEM_PRIZE_QUERY"
+_ENV[1541]="CG_ROLESYSTEM_PRIZE_GET"
+
 -- _ENV[1544]="CG_ROLESTORAGEBOX_QUERY"
--- _ENV[1545]="GC_ROLESTORAGEBOX_QUERY"
+-- _ENV[1545]="GC_ROLESTORAGEBOX_QUERY"
+

+ 1 - 0
script/module/present/OnlineAwardLogic.lua

@@ -326,6 +326,7 @@ function Query(human)
     local msgRet = Msg.gc.GC_ONLINEAWARD_QUERY
     msgRet.leftTime = 0
     msgRet.needRecharge = targetCfg.needRecharge
+    msgRet.nowRecharge = human.db.topupAcountDaily or 0
 
     msgRet.isReach = 0
     local topupAcountDaily = human.db.topupAcountDaily

+ 1 - 0
script/module/present/Proto.lua

@@ -984,6 +984,7 @@ GC_ONLINEAWARD_QUERY = {
     {"awardVec",            12,  SINGLE_AWARD_INFO},   --当天所有的奖励数据
     {"leftTime",            1,  "int"},                --领取下一档奖励的倒计时
     {"needRecharge",        1,  "double"},             --当日领奖需要充值金额
+    {"nowRecharge",         1,  "double"},              --当前已充值金额
     {"isReach",             1,  "byte"},               --是否充值达标,0-未达标,1-达标
     {"remainingDays",       1,  "byte"},               --剩余天数
 }

+ 8 - 0
script/module/roleSystem/Handler.lua

@@ -23,3 +23,11 @@ end
 function CG_ROLE_REALM_UPGRADE(human, msg)
    RoleRealmLogic.realmUpgrade(human)
 end
+
+function CG_ROLESYSTEM_PRIZE_QUERY(human, msg)
+   RoleSystemLogic.RoleSystem_QueryPrize(human)
+end
+
+function CG_ROLESYSTEM_PRIZE_GET(human, msg)
+   RoleSystemLogic.RoleSystem_GetPrize(human)
+end

+ 22 - 0
script/module/roleSystem/Proto.lua

@@ -55,4 +55,26 @@ GC_ROLE_REALM_QUERY = {
 --提升境界
 CG_ROLE_REALM_UPGRADE = {
 
+}
+
+tRoleSystemPrize = 
+{
+    {"nID",			1,	"short"},
+    {"nStatus",     1,  "byte"},  -- 0 不可领取 1 可领取 2 已领取
+    {"tItemList",   5,  ItemData},
+}
+
+-- 请求功能开放奖励
+CG_ROLESYSTEM_PRIZE_QUERY = { 
+
+}
+
+-- 回复 请求功能开放奖励
+GC_ROLESYSTEM_PRIZE_QUERY = {
+    {"tList",       150,   tRoleSystemPrize}
+}
+
+-- 请求领取功能开发奖励配置
+CG_ROLESYSTEM_PRIZE_GET = {
+
 }

+ 94 - 0
script/module/roleSystem/RoleSystemLogic.lua

@@ -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