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