SCFC 1 год назад
Родитель
Сommit
1ca3307fd8

+ 15 - 0
script/module/absAct/LotteryByDiamondLogic.lua

@@ -21,6 +21,7 @@ local LOTTERYLOG = "lotteryByDiamonds" --日志标识
 local MAXPOINTS = 300               --每三百积分可以获得一次稀有抽奖次数
 local RANDMIN = 5                   --普通奖池每次抽奖获得积分随机值最小值
 local RANDMAX = 15                  --普通奖池每次抽奖获得积分随机值最大值
+local LOTTERYACTID = 31005          -- 古玉充能活动ID
 
 local lotteryCostID = 0             --普通奖池抽奖消耗道具ID
 local lottery1CostCnt = 0           --普通奖池单抽消耗道具数量
@@ -186,4 +187,18 @@ function Lottery(human, id, type)
     end
     Grid.makeItem(msgRet.lottery1cost, lotteryCostID, nLotteryCostCnt)
     Msg.send(msgRet, human.fd)
+end
+
+-- 是否有红点
+function isRed(human, YYInfo, funcConfig)
+    local tActData = human.db.absAct[LOTTERYACTID]
+    if not tActData then
+        return false
+    end
+
+    if not tActData.lastFreeTime or not Util.isSameDay(tActData.lastFreeTime) then
+        return true
+    end
+
+    return false
 end

+ 61 - 25
script/module/absAct/SpecialCustomLogic.lua

@@ -24,6 +24,9 @@ local ObjHuman = require("core.ObjHuman")
 local Lang  = require("common.Lang")
 local Broadcast = require("broadcast.Broadcast")
 
+local SPECIALCISTOMACTID = 31004        -- 活动ID
+local SPECIALCISTOMNOBUYID = 20001          -- 不使用的投放ID
+
 function isOpen(human, YYInfo, funcConfig)
     local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
     if not state then return end
@@ -39,10 +42,10 @@ function isActive(human, YYInfo, funcConfig)
 end
 
 
---���Ͷ����������
--- id �id
+--发送定制礼包数据
+-- id 活动id
 function getAndSendMsg(human,id,actID)
-    -- �δ��������
+     -- 活动未开,返回
     local state, endTime, starTime = AbsActLogic.isStarted(human, id)
     if not state then return end
     local absConfig = AbsActExcel.absActivity[id]
@@ -52,9 +55,9 @@ function getAndSendMsg(human,id,actID)
     if not absAct then
         return
     end
-    -- ��ʼ��custom����
+      -- 初始化custom数据
     absAct.custom = absAct.custom or {}
-    -- ��������
+    -- 构造数据
     local msgRet = Msg.gc.GC_ABS_ND_CUSTOM_QUERY
     local config = AbsActExcel.custom
     local len = 0
@@ -115,13 +118,13 @@ function getAndSendMsg(human,id,actID)
                 end
                 net.third[0] = warehouseLen
             end
-            -- ״̬Ϊ0����ʾδѡ����Ʒ��������Ʒ��
+           -- 状态为0,表示未选择物品,发送物品库
             if net.state == 0 then
                 net.one[0] = 0
                 net.two[0] = 0
                 net.three[0] = 0
             else
-                -- ״̬��Ϊ0����ʾ���������ѡ����Ʒ��չʾ��ѡ����Ʒ
+               -- 状态不为0,表示已卖完或已选择物品,展示已选择物品
                 Grid.makeItem(net.one[1],absAct.custom[k].selectItem[1][1],absAct.custom[k].selectItem[1][2])
                 Grid.makeItem(net.two[1],absAct.custom[k].selectItem[2][1],absAct.custom[k].selectItem[2][2])
                 net.one[0] = 1
@@ -140,11 +143,11 @@ function getAndSendMsg(human,id,actID)
     
 end
 
--- ѡ����Ʒ
+-- 选择物品
 function selectItem(human,id,giftId,first,second,third)
     local msgRet = Msg.gc.GC_ABS_ND_CUSTOM_SELECT
     msgRet.ret = 1
-    -- �δ�����޷�ѡ����Ʒ
+    -- 活动未开,无法选择物品
     local state, endTime, starTime = AbsActLogic.isStarted(human, id)
     if not state then 
         msgRet.ret = 0
@@ -166,21 +169,21 @@ function selectItem(human,id,giftId,first,second,third)
         return
     end
     
-    -- ����������޷�ѡ����Ʒ
+     -- 礼包已卖完无法选择物品
     if absAct.custom and absAct.custom[giftId] and absAct.custom[giftId].state == 2 then
         msgRet.ret = 0
         Msg.send(msgRet,human.fd)
         return
     end
 
-    -- ��ʼ������
+    -- 校验物品是否存在
     absAct.custom = absAct.custom or {}
     absAct.custom[giftId] = absAct.custom[giftId] or {}
     absAct.custom[giftId].cnt = absAct.custom[giftId].cnt or 0
     absAct.custom[giftId].state = absAct.custom[giftId].state or 0
     absAct.custom[giftId].selectItem = absAct.custom[giftId].selectItem or {}
     
-    -- У����Ʒ�Ƿ����
+   -- 将已选择物品存入数据库
     local config = AbsActExcel.custom[giftId]
     if config == nil 
        or config.first[first] == nil 
@@ -197,7 +200,7 @@ function selectItem(human,id,giftId,first,second,third)
         return
     end
     
-    -- ����ѡ����Ʒ�������ݿ�
+    -- 并非所有礼包都能选择3个物品
     absAct.custom[giftId].selectItem[1] = {}
     absAct.custom[giftId].selectItem[1][1] = config.first[first][1]
     absAct.custom[giftId].selectItem[1][2] = config.first[first][2]
@@ -205,7 +208,7 @@ function selectItem(human,id,giftId,first,second,third)
     absAct.custom[giftId].selectItem[2][1] = config.second[second][1]
     absAct.custom[giftId].selectItem[2][2] = config.second[second][2]
     
-    -- ���������������ѡ��3����Ʒ
+    -- 并非所有礼包都能选择3个物品
     if third ~= 0 then
         absAct.custom[giftId].selectItem[3] = {}
         absAct.custom[giftId].selectItem[3][1] = config.third[third][1]
@@ -216,14 +219,13 @@ function selectItem(human,id,giftId,first,second,third)
     absAct.custom[giftId].state = 1
 end
 
--- �������
-
+-- 购买礼包
 function custom(human,funcID,conf)
     customBuy(human,conf.args[1],funcID)
 end
 
 function customBuy(human,args,id)
-    -- �δ��������
+     -- 活动未开,返回
     local state, endTime, starTime = AbsActLogic.isStarted(human, id)
     if not state then return end
     local absConfig = AbsActExcel.absActivity[id]
@@ -234,23 +236,23 @@ function customBuy(human,args,id)
         return
     end
 
-    -- ����״̬��Ϊ�ɹ��򣬷���
+    -- 购买状态不为可购买,返回
     if not absAct.custom or not absAct.custom[args] or absAct.custom[args].state ~= 1 then
         return
     end
 
-    -- δѡ����Ʒ������
+    -- 未选择物品,返回
     if #absAct.custom[args].selectItem <= 0 then
         return
     end
 
-    -- �Ѵﵽ�޹�����������
+    -- 已达到限购次数,返回
     local config = AbsActExcel.custom[args]
     if absAct.custom[args].cnt >= config.limitCnt then
         return
     end
 
-    -- ��ʯ�۸�Ϊ0ʱ����ʾ��ʯ���������ж���ʯ�Ƿ��㹻
+    -- 钻石价格不为0时,表示钻石购买,则需判断钻石是否足够
     if config.price ~= 0 then
 	    if not ObjHuman.checkRMB(human, config.price) then
 	    	return Broadcast.sendErr(human, Lang.COMMON_NO_ZUANSHI)
@@ -258,13 +260,13 @@ function customBuy(human,args,id)
 	    ObjHuman.decZuanshi(human, -config.price, "abs_custom")
     end
 
-    -- �����������һ��
+     -- 购买次数增加一次
     absAct.custom[args].cnt = absAct.custom[args].cnt + 1
 
-    -- ״̬����Ϊ�����꣬��ʱ��Ϊ��ֹ�������������¿����޹��򣬹�������Ϊ�޷���������
+     -- 状态设置为已卖完,此时,为防止后续报错,导致可无限购买,故先设置为无法继续购买
     absAct.custom[args].state = 2
 
-    -- ͳ����Ʒ��������
+     -- 统计物品,并发放
     local item = {}
     for i = 1, #config.fixed do
         item[#item+1] = {config.fixed[i][1],config.fixed[i][2]}
@@ -274,7 +276,7 @@ function customBuy(human,args,id)
     end
     BagLogic.addItemList(human, item, "abs_custom")   
 
-    -- �ж��Ƿ�ﵽ�޹�������δ�ﵽ�򽫹���״̬��Ϊѡ����Ʒ
+     -- 判断是否达到限购次数,未达到则将购买状态设为选择物品
     if absAct.custom[args].cnt < config.limitCnt then 
         --absAct.custom[args].selectItem = {}
         absAct.custom[args].state = 0
@@ -283,4 +285,38 @@ function customBuy(human,args,id)
     end
 
     getAndSendMsg(human,id)
+end
+
+-- 是否有红点
+function isRed(human, YYInfo, funcConfig)
+    local tConfig = AbsActExcel.custom
+    if not isRed then
+        return false
+    end
+
+    local tActDBData = human.db.absAct[SPECIALCISTOMACTID]
+    if not tActDBData then
+        return false
+    end
+
+    local bRed = false
+    for k, v in pairs(tConfig) do
+        if 0 == v.buyID and k < SPECIALCISTOMNOBUYID then
+            if not tActDBData.custom or not  tActDBData.custom[k] then
+                bRed = true
+            else
+                if tActDBData.custom[k].state then
+                    bRed = tActDBData.custom[k].state ~= 2 and true or false
+                else
+                    bRed = true
+                end
+            end
+
+            if bRed == true then
+                break
+            end
+        end
+    end
+
+    return bRed
 end