Просмотр исходного кода

提交一元秒杀和天梯赛修改

SCFC 9 месяцев назад
Родитель
Сommit
e29dfd729d

+ 1 - 0
script/common/LogDefine.lua

@@ -252,6 +252,7 @@ DEFINE = {
 	qqbigshot				= 256,			 -- qq大咖
 	darkforarea 			= 257,			 -- 幽暗禁地
 	rolesystemprize 		= 258,			 -- 系统开放奖励
+	onekillgift 			= 259,			 -- 一元秒杀礼包
 	
 	abs_totalReach          = 500,           -- 周期性活动累计
     abs_singleReach         = 501,           -- 周期性活动单次

+ 3 - 3
script/common/ProtoID.lua

@@ -1494,9 +1494,9 @@ _ENV[1544]="CG_DRILL_FIGHT_BY_DIAMON"
 _ENV[1545]="CG_ROLESTORAGEBOX_QUERY"
 _ENV[1546]="GC_ROLESTORAGEBOX_QUERY"
 
--- _ENV[1548]="CG_ONEKILLGIFT_QUERY"
--- _ENV[1549]="GC_ONEKILLGIFT_QUERY"
--- _ENV[1550]="GC_ONEKILLGIFT_CLOSE"
+_ENV[1548]="CG_ONEKILLGIFT_QUERY"
+_ENV[1549]="GC_ONEKILLGIFT_QUERY"
+_ENV[1550]="GC_ONEKILLGIFT_CLOSE"
 
 
 -- _ENV[1553]="CG_EQUIP_ATTR_LOCK"

+ 2 - 0
script/core/ObjHuman.lua

@@ -101,6 +101,7 @@ local RebateLogic = require("platform.RebateLogic")
 local HeroPubLogic = require("hero.HeroPubLogic")
 local JjcNewLadderLogic = require("jjcnewladder.jjcNewLadderLogic")
 local WinnerRelicLogic = require("winnerRelic.WinnerRelicLogic")
+local commonOperate = require("core.commonOperate")
 
 local Json = require("common.Json")
 
@@ -791,6 +792,7 @@ function onLogin(human, isNew)
 	QQBigShot.onLogin(human)
 	JjcNewLadderLogic.onLogin(human)
 	WinnerRelicLogic.onLogin(human)
+	commonOperate.onLogin(human)
 
     HeroLogLogic.finishTaskCB(human,HeroLogLogic.HERO_LOG_TYPE_1,1)
 	-- 红点 检测   需要放在通用的onLogin 后面  保持数据的正确性 再检测红点

+ 2 - 0
script/core/Timer.lua

@@ -46,6 +46,7 @@ local VoucherShopLogic = require("voucher.VoucherShopLogic")
 local ServerCommerceMiddle = require("serverCommerce.ServerCommerceMiddle")
 local JjcNewLadderLogic = require("jjcnewladder.jjcNewLadderLogic")
 local CycleActivityLogic = require("yunying.CycleActivity")
+local commonOperate = require("core.commonOperate")
 
 register_timer = {    
 	monitor = 60000,            -- 
@@ -123,6 +124,7 @@ function doZhengDian(hour)
 	    VoucherShopLogic.VoucherShop_OnZero()
         MainDianLogic.MaiDian_OnTime()
         ServerCommerceMiddle.CommerceMiddle_OnZero()
+        commonOperate.onZero()
     end       
     --if hour == 21 then
     --    if _G.is_middle ~= true then 

+ 10 - 0
script/core/commonOperate.lua

@@ -0,0 +1,10 @@
+local Util = require("common.Util")
+local OneKillGiftLogic = require("present.OneKillGift")
+
+function onZero()
+    OneKillGiftLogic.onZero()
+end
+
+function onLogin(human)
+    OneKillGiftLogic.onLogin(human)
+end

+ 3 - 1
script/module/jjc/JjcActLogic.lua

@@ -14,6 +14,7 @@ local Grid = require("bag.Grid")
 local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
 local JjcLogic = require("jjc.JjcLogic")
 local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
+local JjcNewLadderLogic = require("jjcnewladder.jjcNewLadderLogic")
 
 -- 活动状态
 STATE_NOOPEN = 0 	-- 未开启
@@ -172,7 +173,8 @@ function isDot(human)
 
     if JjcLogic.championChallengeDot(human) == 1 or 
        JjcLogic.championBillboardDot(human) == 1 or 
-       JjcLogic.championRecordDot(human) == 1 then
+       JjcLogic.championRecordDot(human) == 1 or
+	   JjcNewLadderLogic.MainJieMianDot(human) == 1 then
         return true
     end
 end

+ 10 - 3
script/module/jjcnewladder/jjcNewLadderDB.lua

@@ -178,7 +178,7 @@ local function JjcNewLadderDB_InitRobot()
         for i = 1, npcConfig.cnt do
             JjcNewLadderDB_AddNpc(npcConfig, nID)
             nID = nID + 1
-            if nID >= JjcNewLadderDefine.JJC_NEWLADDER_ROBOT_NUM then
+            if nID > JjcNewLadderDefine.JJC_NEWLADDER_ROBOT_NUM then
                 break
             end
         end
@@ -370,8 +370,15 @@ function JjcNewLadderDB_initAfterStart()
                 end
             end
         else
-            --JjcNewLadderDB_LoadData()
-            print("[JjcNewLadderDB_initAfterStart] 不在活动时间内不处理")
+            if true == JjcNewLadderDB_IsFirstServer(Config.SVR_INDEX) then
+                if true == JjcNewLadderDB_isEmpty() then
+                    JjcNewLadderDB_Init()
+                    print("[JjcNewLadderDB_initAfterStart] 不在活动时间内 DB数据为空进行初始化机器人数据")
+                else
+                    JjcNewLadderDB_LoadData()
+                    print("[JjcNewLadderDB_initAfterStart] 不在活动时间内,存在DB数据,只加载数据")
+                end
+            end
         end
 
     end

+ 29 - 1
script/module/jjcnewladder/jjcNewLadderLogic.lua

@@ -33,6 +33,8 @@ local Timer = require("core.Timer")
 local JjcActLogic = require("jjc.JjcActLogic")
 local CommonDefine = require("common.CommonDefine")
 local Log = require("common.Log")
+local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
+local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
 
 
 -- 请求加入天梯赛的玩家
@@ -1102,6 +1104,7 @@ function JjcNewLadderLogic_Query(human)
         JjcNewLadderLogic_CreatDB(human)
     end
 
+    print("[JjcNewLadderLogic_Query] 请求天梯赛信息")
     if false == JjcNewLadderLogic_GetJoin(human) then
         if true == JjcNewLadderLogic_CheckIsOpen() then
             local uuid = human.db._id
@@ -1116,6 +1119,8 @@ function JjcNewLadderLogic_Query(human)
                     return
                 end
             end
+        else
+            JjcNewLadder_GetInterfaceInfo(human)
         end
     else
         JjcNewLadder_GetInterfaceInfo(human)
@@ -1483,7 +1488,13 @@ function getCombatObjList(human, side, args)
         end
 
         print("[JjcNewLadderLogic_getCombatObjList] 进攻方 获取人物对战列表")
-        return CombatLogic.getHumanObjList(human, CombatDefine.COMBAT_TYPE1)
+        local objList, helpList, rolebase, formation,jiban = CombatLogic.getHumanObjList(human, CombatDefine.COMBAT_TYPE16)
+        if not objList or nil == _G.next(objList) then
+            print("[JjcNewLadderLogic_getCombatObjList] 没有获取到对应的天梯赛进攻方防守阵容,取默认对战阵容")
+            objList, helpList, rolebase, formation,jiban = CombatLogic.getHumanObjList(human, CombatDefine.COMBAT_TYPE1)
+        end
+
+        return objList, helpList, rolebase, formation,jiban
     elseif CombatDefine.DEFEND_SIDE == side then
         local uuid = args[1]
         if not uuid then
@@ -1601,6 +1612,8 @@ function onFightEnd(human, result, combatType, defUuid, combatInfo)
     -- 通知中心服对战结果
     print("[JjcNewLadderLogic_onFightEnd] 开始通知中心服对战结果")
     JjcNewLadderMiddle.JjcNewLadderMiddle_FightEndO2C(human.db._id, defUuid, result, tEnemyUuid, human.db.zhandouli)
+
+    RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_1300)
 end
 
 
@@ -1741,4 +1754,19 @@ end
 
 function Init()
     JjcNewLadderDB.JjcNewLadderDB_initAfterStart()
+end
+
+function isActRed(human)
+    if true == JjcNewLadderLogic_CheckIsOpen() then
+        local nFreeNum = JjcNewLadder_GetHumanFreeNum(human)
+        if 0 < nFreeNum then
+            return true
+        end
+    end
+
+    return false
+end
+
+function MainJieMianDot(human)
+    return true == isActRed(human) and 1 or 0
 end

+ 6 - 0
script/module/present/Handler.lua

@@ -37,6 +37,7 @@ local OpenServerActAddUpCharge = require("present.OpenServerActAddUpCharge")
 local OnlineAwardLogic = require("present.OnlineAwardLogic")
 local NewFirstCharge = require("present.NewFirstChargeLogic")
 local ActCycleRechargeLogic = require("present.ActCycleRechargeLogic")
+local OneKillGiftLogic = require("present.OneKillGift")
 
 -- 充值-特权商店
 function CG_TEQUANSHOP_QUERY(human)
@@ -394,3 +395,8 @@ end
 function CG_CYCLERECHARGE_GET_AWARD(human, msg)
     ActCycleRechargeLogic.GetAward(human)
 end
+
+----------------------------一元秒杀--------------------------------
+function CG_ONEKILLGIFT_QUERY(human, msg)
+    OneKillGiftLogic.OneKillGiftLogic_Query(human, msg.bOperate)
+end

+ 195 - 0
script/module/present/OneKillGift.lua

@@ -0,0 +1,195 @@
+-----------------------------------------------------------------
+-- 文件名       :  OneKillGift.lua
+-- 文件说明     :  一元礼包
+-- 创建时间     :   2025/07/22
+-- 创建人       :   FC
+-----------------------------------------------------------
+
+local Msg = require("core.Msg")
+local Util = require("common.Util")
+local Grid = require("bag.Grid")
+local OnekillConf = require("excel.OneKillGift")
+local BuyLogic = require("topup.BuyLogic")
+local BagLogic = require("bag.BagLogic")
+local Grid = require("bag.Grid")
+local ObjHuman = require("core.ObjHuman")
+
+
+local ONEKILLGIFT_MAXBUYNUM = 10        -- 最大购买次数
+local ONEKILLGIFT_NOJINGBI = 1          -- 金币不足
+local ONEKILLGIFT_SHOW = 2              -- 展示
+local ONEKILLGIFT_ONLOGIN = 3           -- 登录
+
+local ONEKILLGIFT_NOSEND = 1            -- 不发送
+
+local nDurationTime = 4 * 60 * 60       -- 4小时
+
+----------------------------------------- 内部处理开始 -------------------------------------
+local function OneKillGift_CreateDB(human)
+    human.db.OneKillGift = {
+        nBuyNum = 0,
+        nEndTime = 0,       -- 每轮结束时间
+        nNoShow = 0,
+        nBeginTime = os.time()
+    }
+end
+
+local function OneKillGift_CheckCreate(human)
+    if not human.db.OneKillGift then
+        OneKillGift_CreateDB(human)
+    end
+end
+
+local function OneKillGift_ResetDB(human)
+    OneKillGift_CreateDB(human)
+end
+
+-- 购买后操作
+local function OneKillGift_BuyGift(human)
+    human.db.OneKillGift.nBuyNum = human.db.OneKillGift.nBuyNum + 1
+    human.db.OneKillGift.nEndTime = 0
+    if human.db.OneKillGift.nBuyNum >= ONEKILLGIFT_MAXBUYNUM then
+        human.db.OneKillGift.nNoShow = 1
+    end
+end
+
+-- 获取购买次数
+local function OneKillGift_GetBuyNum(human)
+    return human.db.OneKillGift.nBuyNum
+end
+
+-- 获取结束时间
+local function OneKillGift_GetEndTime(human)
+    return human.db.OneKillGift.nEndTime
+end
+
+-- 获取是否显示
+local function OneKillGift_GetShow(human)
+    return human.db.OneKillGift.nNoShow
+end
+
+-- 获取开始时间
+local function OneKillGift_GetBeginTime(human)
+    return human.db.OneKillGift.nBeginTime
+end
+
+-- 设置结束时间
+local function OneKillGift_SetEndTime(human, nValue)
+    human.db.OneKillGift.nEndTime = nValue
+end
+
+-- 设置是否显示
+local function OneKillGift_SetShow(human, nValue)
+    human.db.OneKillGift.nNoShow = nValue
+end
+
+-- 发送数据
+function OneKillGift_SendMsg(human, bIsOpen)
+    local nNowTime = os.time()
+    local nBuyNum = OneKillGift_GetBuyNum(human)
+    local nNextBuyNum = nBuyNum + 1
+    local tConf = OnekillConf.Sheet1[nNextBuyNum]
+    if not tConf then
+        print("[OneKillGift_SendMsg] 不存在对应的配置 nBuyNum = "..nBuyNum.." nNextBuyNum = "..nNextBuyNum)
+        return
+    end
+
+    local tMsgData = Msg.gc.GC_ONEKILLGIFT_QUERY
+    tMsgData.nBuyNum = nBuyNum
+    tMsgData.bIsOpen = bIsOpen
+    tMsgData.nLeftTime = OneKillGift_GetEndTime(human) - nNowTime
+
+    print("[OneKillGift_SendMsg] nBuyNum = "..tMsgData.nBuyNum.." bIsOpen = "..tMsgData.bIsOpen.." nLeftTime = "..tMsgData.nLeftTime)
+    BuyLogic.fontBuyItem(human, tMsgData.buyItem, tConf.nBuyID)
+
+    --table.print_lua_table(tMsgData.buyItem)
+    tMsgData.tList[0] = #tConf.tPrize
+    for i, v in ipairs(tConf.tPrize) do
+        print("[OneKillGift_SendMsg] i = "..i.." nGoodsID = "..v[1].." nGoodsNum = "..v[2])
+        Grid.makeItem(tMsgData.tList[i], v[1], v[2])
+       -- table.print_lua_table(tMsgData.tList[i])
+    end
+
+    Msg.send(tMsgData, human.fd)
+    print("[OneKillGift_SendMsg] 发送数据完成")
+end
+
+----------------------------------------- 客户端请求 -------------------------------------
+function OneKillGiftLogic_Query(human, bOperate)
+    print("[OneKillGiftLogic_Query] 收到消息")
+    local bIsOpen = ONEKILLGIFT_ONLOGIN == bOperate and 0 or 1
+
+    OneKillGift_CheckCreate(human)
+    local bShow = OneKillGift_GetShow(human)
+    if ONEKILLGIFT_NOSEND == bShow then
+        print("[OneKillGiftLogic_Query] 当前已经设置了不再展示,直接返回")
+        return
+    end
+
+    local nNowTime = os.time()
+    local nOldEndTime = OneKillGift_GetEndTime(human)
+    if nNowTime >= nOldEndTime and 0 ~= nOldEndTime then
+        print("[OneKillGiftLogic_Query] 当前结束时间不为0, 且当前时间大于结束时间,设置为不展示直接返回")
+        OneKillGift_SetShow(human, ONEKILLGIFT_NOSEND)
+        return
+    end
+
+    if ONEKILLGIFT_NOJINGBI ==  bOperate then
+        if nOldEndTime ~= 0 and nOldEndTime > nNowTime then
+            print("[OneKillGiftLogic_Query] 当前结束时间不为0, 且结束时间大于当前时间,")
+            return
+        end
+
+        local nEndTime = nNowTime + nDurationTime
+        OneKillGift_SetEndTime(human, nEndTime)
+    end
+
+    OneKillGift_SendMsg(human, bIsOpen)
+    print("[OneKillGiftLogic_Query] 发送客户端协议完成")
+end
+
+function onLogin(human)
+    print("[OneKillGift_onLogin] 玩家登录")
+    OneKillGift_CheckCreate(human)
+    
+    local nOldEndTime = OneKillGift_GetEndTime(human)
+    local nNowTime = os.time()
+    local nBeginTime = OneKillGift_GetBeginTime(human)
+
+    if true ~= Util.isSameDayByTimes(nBeginTime, nNowTime) then
+        print("[OneKillGift_onLogin] 不是同一天进行重置")
+
+        OneKillGift_ResetDB(human)
+    else
+        if nOldEndTime > nNowTime  then
+            print("[OneKillGift_onLogin] 当前结束时间大于当前时间发送数据")
+            OneKillGiftLogic_Query(human, ONEKILLGIFT_ONLOGIN)
+        else
+            if 0 < nOldEndTime then
+                OneKillGift_SetShow(human, ONEKILLGIFT_NOSEND)
+                print("[OneKillGift_onLogin] 玩家未购买且结束时间不为0直接不弹")
+            end
+        end
+    end
+end
+
+
+function onCharge(human, nBuyID)
+    local nBuyNum = OneKillGift_GetBuyNum(human)
+    local tConf = OnekillConf.Sheet1[nBuyNum + 1]
+    if tConf and tConf.nBuyID == nBuyID then
+        BagLogic.addItemList(human, tConf.tPrize, "onekillgift")
+        OneKillGift_BuyGift(human)
+        local tMsgData = Msg.gc.GC_ONEKILLGIFT_CLOSE
+        Msg.send(tMsgData, human.fd)
+    end
+end
+
+function onZero()
+     -- 遍历在线玩家
+     for uuid, human in pairs(ObjHuman.onlineUuid) do
+        local tMsgData = Msg.gc.GC_ONEKILLGIFT_CLOSE
+        Msg.send(tMsgData, human.fd)
+        OneKillGift_ResetDB(human)
+    end
+end

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

@@ -1059,4 +1059,21 @@ GC_CYCLERECHARGE_QUERY = {
 
 -- 领奖
 CG_CYCLERECHARGE_GET_AWARD = {
-}
+}
+
+---------------------------------------一元秒杀礼包----------------------------------
+-- 请求一元秒杀礼包
+CG_ONEKILLGIFT_QUERY = {
+    {"bOperate",    1,      "byte"}     -- 1 金币不足,2 打开界面
+}
+
+GC_ONEKILLGIFT_QUERY = {
+    {"nBuyNum",     1,      "int"},         -- 购买次数
+    {"nLeftTime",    1,     "int"},         -- 结束时间
+    {"bIsOpen",     1,      "byte"},        -- 是否打开界面
+    {"buyItem",     1,      BuyItem},       -- 购买礼包信息
+    {"tList",       6,      ItemData},      -- 物品信息
+}
+
+-- 关闭界面
+GC_ONEKILLGIFT_CLOSE = {}

+ 1 - 0
script/module/roleSystem/RoleSystemDefine.lua

@@ -71,6 +71,7 @@ ROLE_SYS_ID_1300 = 1300 -- 主界面竞技
 ROLE_SYS_ID_1301 = 1301 -- 竞技-冠军联赛
 ROLE_SYS_ID_1302 = 1302 -- 竞技-王者争霸
 ROLE_SYS_ID_1303 = 1303 -- 竞技-战神殿
+ROLE_SYS_ID_1304 = 1304 -- 天梯
 ROLE_SYS_ID_1401 = 1401 -- 天梯
 ROLE_SYS_ID_2001 = 2001 -- 宝具-封印之章
 ROLE_SYS_ID_2002 = 2002 -- 宝具-守护之龙

+ 7 - 0
script/module/topup/BuyLogic.lua

@@ -45,6 +45,7 @@ local VoucherShopLogic = require("voucher.VoucherShopLogic")
 local MaiDianDefine = require("MaiDian.MaiDianDefine")
 local MainDianLogic = require("MaiDian.MaiDianLogic")
 local NewFirstCharge = require("present.NewFirstChargeLogic")
+local OneKillGiftLogic = require("present.OneKillGift")
 
 BUY_CODE_NORMAL = 0   -- 正常调平台的充值接口
 BUY_CODE_WX_KEFU = 1  -- 微信小程序客服充值接口
@@ -292,6 +293,12 @@ function cmd.newfirstcharge(human, buyConf, isFirst, buyCnt)
 	NewFirstCharge.onCharge(human, nBuyID)
 end
 
+function cmd.onekillgift(human, buyConf, isFirst, buyCnt)
+	local nBuyID = buyConf.id
+	print("[cmd.onekillgift] nBuyID = "..nBuyID)
+	OneKillGiftLogic.onCharge(human, nBuyID)
+end
+
 -------------------------------- cmd结束 ----------------------------------
 
 function checkBuy(human, ret)